53 lines
2.3 KiB
TypeScript
53 lines
2.3 KiB
TypeScript
import { _decorator, Animation, AnimationClip, Color, Component, Label, Node, resources, Sprite, SpriteAtlas } from 'cc';
|
|
import { HeroInfo } from '../common/config/heroSet';
|
|
import { oops } from '../../../../extensions/oops-plugin-framework/assets/core/Oops';
|
|
import { UIID } from '../common/config/GameUIConfig';
|
|
import { Items } from '../common/config/Items';
|
|
import { ColorSet, getColor } from '../common/config/BoxSet';
|
|
import { smc } from '../common/SingletonModuleComp';
|
|
import { GameEvent } from '../common/config/GameEvent';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
@ccclass('HChipComp')
|
|
export class HChipComp extends Component {
|
|
h_uuid:number=0
|
|
num:number=0
|
|
lv:number=0
|
|
start() {
|
|
oops.message.on(GameEvent.UpdateHero,this.update_hero,this)
|
|
}
|
|
|
|
update(deltaTime: number) {
|
|
|
|
}
|
|
show_info(){
|
|
// oops.gui.open(UIID.ItemInfo, {uuid:this.h_uuid,type:2});
|
|
}
|
|
update_hero(e:string,data:any){
|
|
if(this.h_uuid==data.uuid){
|
|
this.update_data(data.uuid)
|
|
}
|
|
}
|
|
update_data(uuid:number){
|
|
this.h_uuid=uuid
|
|
let hero_data = HeroInfo[uuid]
|
|
let hero= this.node.getChildByName("hero")
|
|
let anm_path=hero_data.path
|
|
resources.load("game/heros/hero/"+anm_path+"/idle", AnimationClip, (err, clip) => {
|
|
hero.getComponent(Animation).addClip(clip);
|
|
hero.getComponent(Animation).play("idle");
|
|
});
|
|
this.node.getChildByName("name").getComponent(Label).string=hero_data.name
|
|
this.node.getChildByName("lv").getChildByName("num").getComponent(Label).string=smc.heros[uuid].lv.toString()
|
|
this.node.getChildByName("slv").getChildByName("lv1").active=smc.heros[uuid].slv>=1
|
|
this.node.getChildByName("slv").getChildByName("lv2").active=smc.heros[uuid].slv>=2
|
|
this.node.getChildByName("slv").getChildByName("lv3").active=smc.heros[uuid].slv>=3
|
|
this.node.getChildByName("slv").getChildByName("lv4").active=smc.heros[uuid].slv>=4
|
|
this.node.getChildByName("slv").getChildByName("lv5").active=smc.heros[uuid].slv>=5
|
|
this.node.getChildByName("bg").getComponent(Sprite).color=Color[getColor(hero_data.quality)[0]]
|
|
this.node.getChildByName("bgg").getComponent(Sprite).color=Color[getColor(hero_data.quality)[1]]
|
|
}
|
|
}
|
|
|
|
|