first
This commit is contained in:
71
assets/script/game/map/view/MapViewComp.ts
Normal file
71
assets/script/game/map/view/MapViewComp.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { v3, Vec3, _decorator } from "cc";
|
||||
import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { smc } from "../../common/SingletonModuleComp";
|
||||
import { Role } from "../../role/Role";
|
||||
// import MapRoadUtils from "./map/road/MapRoadUtils";
|
||||
import { MapViewScene } from "./MapViewScene";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('MapViewComp')
|
||||
@ecs.register('MapView', false)
|
||||
export class MapViewComp extends CCComp {
|
||||
scene: MapViewScene = null!;
|
||||
|
||||
/** 是否正在转场 */
|
||||
|
||||
|
||||
/** 当前地图数据 */
|
||||
current_map: any;
|
||||
/** 转场碰撞点对象集合 */
|
||||
|
||||
|
||||
|
||||
reset(): void {
|
||||
|
||||
}
|
||||
|
||||
start() {
|
||||
this.scene = this.getComponent(MapViewScene);
|
||||
|
||||
this.addHero();
|
||||
}
|
||||
|
||||
/** 转场 */
|
||||
|
||||
|
||||
private mapLoaded() {
|
||||
|
||||
}
|
||||
|
||||
/** 添加玩家 */
|
||||
private addHero(pos?: Vec3) {
|
||||
if (pos == null) {
|
||||
this.scene.node.active = true
|
||||
smc.own = ecs.getEntity<Role>(Role);
|
||||
smc.own.load(this.aStarToVec3("0,0"), true);
|
||||
// smc.own.loadJoystick();
|
||||
|
||||
// 测试玩家
|
||||
var test = ecs.getEntity<Role>(Role);
|
||||
test.load(this.aStarToVec3("-300,0"), false);
|
||||
var test2 = ecs.getEntity<Role>(Role);
|
||||
test2.load(this.aStarToVec3("-300,300"), false);
|
||||
}
|
||||
else {
|
||||
this.scene.setPlayer(pos);
|
||||
}
|
||||
}
|
||||
|
||||
private aStarToVec3(str: string) {
|
||||
let array = str.split(",");
|
||||
let x = parseInt(array[0]);
|
||||
let y = parseInt(array[1]);
|
||||
// let p = MapRoadUtils.instance.getPixelByDerect(x, y);
|
||||
return v3(x, y);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user