import { _decorator, Animation, AnimationClip, CCInteger, Component, Label, Node, resources } from 'cc'; import { smc } from '../common/SingletonModuleComp'; import { HeroInfo } from '../common/config/heroSet'; import { GameEvent } from '../common/config/GameEvent'; import { oops } from 'db://oops-framework/core/Oops'; import { UIID } from '../common/config/GameUIConfig'; import { GameSet } from '../common/config/BoxSet'; const { ccclass, property } = _decorator; @ccclass('HeroReadyCom') export class HeroReadyCom extends Component { @property(CCInteger) slot: number=0; protected onLoad(): void { oops.message.on(GameEvent.UpdateHero,this.update_hero,this) } start() { this.update_hero() } update(deltaTime: number) { } update_hero(){ let hero = smc.fight_heros[this.slot] console.log("[HeroReadyCom]hero",hero,smc.fight_heros,this.slot) if(hero==0){ this.no_hero() return } this.node.getChildByName("icon").active=true this.node.getChildByName("add").active=false let hero_data = HeroInfo[hero] console.log("[HeroReadyCom]hero_data",smc.fight_heros,hero,smc.fight_heros[this.slot],this.slot,hero_data) let anm_path=hero_data.path resources.load("game/heros/hero/"+anm_path+"/idle", AnimationClip, (err, clip) => { this.node.getChildByName("icon").getComponent(Animation).addClip(clip); this.node.getChildByName("icon").getComponent(Animation).play("idle"); }); this.node.getChildByName("lv").active=true this.node.getChildByName("lv").getChildByName("num").getComponent(Label).string=smc.heros[hero].lv.toString() // console.log("[HeroReadyCom]clip",this.node.getChildByName("icon").getComponent(Animation)) } no_hero(){ this.node.getChildByName("lv").active=false this.node.getChildByName("add").active=true this.node.getChildByName("icon").active=false } select_hero(){ if(oops.gui.has(UIID.HeroSelect)) return oops.gui.open(UIID.HeroSelect,{slot:this.slot}) } }