first
This commit is contained in:
94
assets/script/game/map/view/MapViewScene.ts
Normal file
94
assets/script/game/map/view/MapViewScene.ts
Normal file
@@ -0,0 +1,94 @@
|
||||
import { Camera, CCBoolean, Component, EventTouch, Node, screen, Size, Texture2D, UITransform, Vec2, Vec3, view, _decorator } from "cc";
|
||||
import { oops } from "../../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import MapData from "./map/base/MapData";
|
||||
import { MapLoadModel } from "./map/base/MapLoadModel";
|
||||
import MapParams from "./map/base/MapParams";
|
||||
import Charactor from "./map/charactor/Charactor";
|
||||
import EntityLayer from "./map/layer/EntityLayer";
|
||||
import MapLayer from "./map/layer/MapLayer";
|
||||
import IRoadSeeker from "./map/road/IRoadSeeker";
|
||||
import RoadNode from "./map/road/RoadNode";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**
|
||||
* 地图场景逻辑
|
||||
* 1、地图摄像机跟随角色位置移动
|
||||
*/
|
||||
@ccclass('MapViewScene')
|
||||
export class MapViewScene extends Component {
|
||||
@property(Camera)
|
||||
public camera: Camera | null = null;
|
||||
|
||||
@property(Node)
|
||||
public layer: Node | null = null;
|
||||
|
||||
@property(MapLayer)
|
||||
public mapLayer: MapLayer | null = null;
|
||||
|
||||
@property(Node)
|
||||
public floorLayer: Node | null = null;
|
||||
|
||||
@property(EntityLayer)
|
||||
public entityLayer: EntityLayer | null = null;
|
||||
|
||||
@property(CCBoolean)
|
||||
public isFollowPlayer: boolean = true;
|
||||
|
||||
/** 2D转3D位置比例值 */
|
||||
ratio: Vec2 = new Vec2();
|
||||
|
||||
private _roadDic: { [key: string]: RoadNode } = {};
|
||||
private _roadSeeker!: IRoadSeeker;
|
||||
private _mapParams: MapParams | null = null;
|
||||
|
||||
private player: Charactor | null = null; // 主角玩家
|
||||
private targetPos: Vec3 = new Vec3(); // 摄像机位置
|
||||
private winSize!: Size; // 屏幕尺寸
|
||||
private screenCenter: Vec3 = new Vec3(); // 屏幕中心位置
|
||||
private boundary: Vec2 = new Vec2(); // 边界位置
|
||||
|
||||
setPlayer(value: Charactor | Vec3) {
|
||||
if (value instanceof Charactor) {
|
||||
this.enabled = true;
|
||||
this.player = value;
|
||||
}
|
||||
else {
|
||||
this.player!.pos = value;
|
||||
}
|
||||
}
|
||||
|
||||
onLoad() {
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
private reset() {
|
||||
this.floorLayer!.removeAllChildren(); // 清除地面显示对象
|
||||
this.entityLayer!.clear(); // 清除游戏实体对象
|
||||
this.mapLayer!.clear(); // 清除地图瓦片显示对象
|
||||
this._roadDic = {};
|
||||
|
||||
|
||||
}
|
||||
|
||||
public init(mapData: MapData, bgTex: Texture2D, mapLoadModel: MapLoadModel = 1) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
update(dt: number) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user