添加2个游戏层,敌方精灵随机出现在3个层内
This commit is contained in:
58
assets/script/game/player/Hero.ts
Normal file
58
assets/script/game/player/Hero.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
|
||||
/*
|
||||
* @Author: dgflash
|
||||
* @Date: 2021-11-18 17:47:56
|
||||
* @LastEditors: dgflash
|
||||
* @LastEditTime: 2022-08-04 15:43:04
|
||||
*/
|
||||
import { instantiate, Node, Prefab, tween, Vec3,Label } from "cc";
|
||||
import { UICallbacks } from "../../../../extensions/oops-plugin-framework/assets/core/gui/layer/Defines";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { UIID } from "../common/config/GameUIConfig";
|
||||
import { smc } from "../common/SingletonModuleComp";
|
||||
import { HeroModelComp } from "./HeroModelComp";
|
||||
import { HeroSpine } from "./HeroSpine";
|
||||
import { HeroViewComp } from "./HeroViewComp";
|
||||
|
||||
/** 角色实体 */
|
||||
@ecs.register(`Hero`)
|
||||
export class Hero extends ecs.Entity {
|
||||
// 数据层
|
||||
HeroModel!: HeroModelComp;
|
||||
// 视图层
|
||||
HeroView!: HeroViewComp;
|
||||
|
||||
protected init() {
|
||||
this.addComponents<ecs.Comp>(
|
||||
HeroModelComp);
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
this.remove(HeroViewComp);
|
||||
super.destroy();
|
||||
}
|
||||
|
||||
/** 加载角色 */
|
||||
load(pos: Vec3 = Vec3.ZERO,profession:string = "war") {
|
||||
var path = "game/heros/"+profession;
|
||||
var prefab: Prefab = oops.res.get(path, Prefab)!;
|
||||
var node = instantiate(prefab);
|
||||
let label =node.getChildByName("top").getChildByName("lab_name")
|
||||
label.getComponent(Label)!.string = profession;
|
||||
var scene = smc.map.MapView.scene;
|
||||
node.parent = scene.entityLayer!.node!;
|
||||
var as = node.getComponent(HeroSpine);
|
||||
node.setPosition(pos)
|
||||
node.setScale(1, 1, 1);
|
||||
var mv = node.getComponent(HeroViewComp)!;
|
||||
mv.speed=smc.heros[0].speed;
|
||||
this.add(mv);
|
||||
|
||||
//移除全局列表
|
||||
|
||||
// console.log(ecs.query(ecs.allOf(HeroViewComp)))
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user