82 lines
3.0 KiB
TypeScript
82 lines
3.0 KiB
TypeScript
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';
|
|
import { finishCurrGuide } from '../common/config/Guide';
|
|
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)
|
|
oops.message.on(GameEvent.UpdateFightHero,this.update_hero,this)
|
|
oops.message.on(GameEvent.HeroSpeek,this.to_speek,this)
|
|
}
|
|
start() {
|
|
this.hide_speek()
|
|
this.update_hero()
|
|
|
|
}
|
|
hide_speek(){
|
|
this.node.getChildByName("tooltip").active=false
|
|
}
|
|
to_speek(e:any,args:any){
|
|
console.log("[HeroReadyCom]:to_speek",args,this.slot)
|
|
if(args.slot!=this.slot) return
|
|
if(smc.fight_heros[this.slot]==0) return
|
|
this.node.getChildByName("tooltip").active=true
|
|
this.node.getChildByName("tooltip").getChildByName("words").getComponent(Label)!.string = args.words
|
|
this.scheduleOnce(()=>{
|
|
this.hide_speek()
|
|
},3)
|
|
}
|
|
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
|
|
if(smc.fight_heros[this.slot]==0) {
|
|
finishCurrGuide(8)
|
|
}
|
|
oops.gui.open(UIID.HeroSelect,{slot:this.slot})
|
|
}
|
|
reset() {
|
|
this.node.destroy()
|
|
}
|
|
|
|
}
|
|
|
|
|