技能碰撞改回物理碰撞
This commit is contained in:
68
assets/script/game/hero/HeroInfoComp.ts
Normal file
68
assets/script/game/hero/HeroInfoComp.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { _decorator, Label, resources, Sprite, SpriteAtlas } 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 { HeroModelComp } from "./HeroModelComp";
|
||||
import { HeroViewComp } from "./HeroViewComp";
|
||||
import { HeroInfo, HeroPos, HeroSet } from "../common/config/heroSet";
|
||||
import { MissionComp } from "../map/MissionComp";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@ccclass('HeroInfoCompComp')
|
||||
@ecs.register('HeroInfoComp', false)
|
||||
export class HeroInfoCompComp extends CCComp {
|
||||
@property(Number)
|
||||
c_id:number=0
|
||||
@property(Boolean)
|
||||
is_Change:boolean=false
|
||||
|
||||
has_hero:boolean=false
|
||||
/** 视图层逻辑代码分离演示 */
|
||||
start() {
|
||||
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
|
||||
// this.on(ModuleEvent.Cmd, this.onHandler, this);
|
||||
this.init()
|
||||
}
|
||||
init(){
|
||||
this.has_hero=false
|
||||
}
|
||||
update(dt: number): void {
|
||||
if(!smc.mission.play) return
|
||||
this.update_info()
|
||||
}
|
||||
update_info(){
|
||||
let heros=ecs.query(ecs.allOf(HeroModelComp))
|
||||
for(let hero of heros){
|
||||
let info=hero.get(HeroViewComp)
|
||||
if(info.node.position.x==HeroPos[this.c_id].pos.x){
|
||||
this.has_hero=true
|
||||
this.node.getChildByName("info").getChildByName("ap").getChildByName("num").getComponent(Label).string=info.ap.toString()
|
||||
this.node.getChildByName("info").getChildByName("hp").getChildByName("num").getComponent(Label).string=info.hp.toString()
|
||||
this.node.getChildByName("name").getComponent(Label).string=HeroInfo[info.hero_uuid].name
|
||||
var icon_path = "game/heros/herois"
|
||||
resources.load(icon_path, SpriteAtlas, (err: any, atlas) => {
|
||||
const sprite = this.node.getChildByName("mask").getChildByName("icon").getComponent(Sprite);
|
||||
sprite.spriteFrame = atlas.getSpriteFrame(HeroInfo[info.hero_uuid].path);
|
||||
});
|
||||
}
|
||||
}
|
||||
if(this.is_Change){
|
||||
this.node.getChildByName("change").active=this.has_hero
|
||||
this.node.getChildByName("select").active=!this.has_hero
|
||||
}
|
||||
}
|
||||
/** 全局消息逻辑处理 */
|
||||
// private onHandler(event: string, args: any) {
|
||||
// switch (event) {
|
||||
// case ModuleEvent.Cmd:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user