84 lines
2.4 KiB
TypeScript
84 lines
2.4 KiB
TypeScript
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("-360,-60"), false);
|
|
// smc.own.loadJoystick();
|
|
|
|
// 测试玩家
|
|
var test = ecs.getEntity<Role>(Role);
|
|
test.load(this.aStarToVec3("-270,-60"), false);
|
|
var test1 = ecs.getEntity<Role>(Role);
|
|
test1.load(this.aStarToVec3("-180,-60"), false);
|
|
var test2 = ecs.getEntity<Role>(Role);
|
|
test2.load(this.aStarToVec3("-90,-60"), false);
|
|
|
|
// var test3 = ecs.getEntity<Role>(Role);
|
|
// test3.load(this.aStarToVec3("0,-60"), false);
|
|
var test4 = ecs.getEntity<Role>(Role);
|
|
test4.load(this.aStarToVec3("90,-60"), true,"monster");
|
|
var test5 = ecs.getEntity<Role>(Role);
|
|
test5.load(this.aStarToVec3("180,-60"), true,"magic");
|
|
var test6 = ecs.getEntity<Role>(Role);
|
|
test6.load(this.aStarToVec3("270,-60"), true,"heath");
|
|
var test7 = ecs.getEntity<Role>(Role);
|
|
test7.load(this.aStarToVec3("360,-60"), true);
|
|
}
|
|
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);
|
|
}
|
|
|
|
|
|
|
|
}
|