74 lines
3.0 KiB
TypeScript
74 lines
3.0 KiB
TypeScript
import { _decorator, Animation, AnimationClip, Component, Label, Node, resources, Sprite, SpriteFrame } from 'cc';
|
|
import { oops } from 'db://oops-framework/core/Oops';
|
|
import { UIID } from '../common/config/GameUIConfig';
|
|
import { getHeroList, getHeroStatsByLevel, getUpgradeResources, HeroInfo, HType, HTypeName, unlockHeroCost } from '../common/config/heroSet';
|
|
import { smc } from '../common/SingletonModuleComp';
|
|
import { GameEvent } from '../common/config/GameEvent';
|
|
import { NumberFormatter } from '../common/config/BoxSet';
|
|
import { Items } from '../common/config/Items';
|
|
import { finishCurrGuide, GuideConfig, startGuide } from '../common/config/Guide';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('HInfoComp')
|
|
export class HInfoComp extends Component {
|
|
h_uuid:number=0
|
|
name_node:any=null
|
|
type_node:any=null
|
|
ap_node:any=null
|
|
hp_node:any=null
|
|
def_node:any=null
|
|
start() {
|
|
this.name_node=this.node.getChildByName("hero").getChildByName("hname").getChildByName("name")
|
|
this.type_node=this.node.getChildByName("hero").getChildByName("hname").getChildByName("type")
|
|
this.ap_node=this.node.getChildByName("info").getChildByName("base").getChildByName("ap").getChildByName("num")
|
|
this.hp_node=this.node.getChildByName("info").getChildByName("base").getChildByName("hp").getChildByName("num")
|
|
this.def_node=this.node.getChildByName("info").getChildByName("base").getChildByName("def").getChildByName("num")
|
|
this.h_uuid=smc.fight_heros[0]
|
|
this.update_data(this.h_uuid)
|
|
}
|
|
update(deltaTime: number) {
|
|
|
|
}
|
|
update_data(uuid:number){
|
|
this.h_uuid=uuid
|
|
let hero_data = HeroInfo[uuid]
|
|
console.log("[HInfoComp]:update_data",uuid,hero_data,this.node)
|
|
this.name_node.getComponent(Label).string=hero_data.name
|
|
this.type_node.getComponent(Label).string=HTypeName[hero_data.type]
|
|
this.ap_node.getComponent(Label).string=hero_data.ap.toString()
|
|
this.hp_node.getComponent(Label).string=hero_data.hp.toString()
|
|
this.def_node.getComponent(Label).string=hero_data.def.toString()
|
|
let anm_path=hero_data.path
|
|
resources.load("game/heros/hero/"+anm_path+"/idle", AnimationClip, (err, clip) => {
|
|
this.node.getChildByName("hero").getComponent(Animation).addClip(clip);
|
|
this.node.getChildByName("hero").getComponent(Animation).play("idle");
|
|
});
|
|
}
|
|
next_hero(){
|
|
let heros=getHeroList()
|
|
let index = heros.indexOf(this.h_uuid);
|
|
index++
|
|
if(index==heros.length) index=0
|
|
let nextHero = heros[index];
|
|
this.update_data(nextHero)
|
|
}
|
|
prev_hero(){
|
|
let heros=getHeroList()
|
|
let index = heros.indexOf(this.h_uuid);
|
|
index--
|
|
if(index==-1) index=heros.length-1
|
|
let prevHero = heros[index];
|
|
this.update_data(prevHero)
|
|
}
|
|
close(){
|
|
finishCurrGuide(6)
|
|
startGuide(7)
|
|
oops.gui.removeByNode(this.node)
|
|
}
|
|
reset() {
|
|
this.node.destroy()
|
|
}
|
|
}
|
|
|
|
|