import { _decorator, Animation, AnimationClip, CCInteger, Component, instantiate, Label, Node, Prefab, resources, v3 } 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; @property(Prefab) hero_prefab: Prefab = null!; protected onLoad(): void { } start() { this.add_heros() } update(deltaTime: number) { } add_heros(){ let heros=smc.heros let x=0 for(let key in heros){ this.add_hero(heros[key].uuid,x) console.log("[HeroReadyCom]:add_hero",heros[key],x) x++ } } add_hero(hero:any,pos:number){ let hero_data = HeroInfo[hero] if(!this.hero_prefab) return const node = instantiate(this.hero_prefab) as unknown as Node; let anm_path=hero_data.path resources.load("game/heros/hero/"+anm_path+"/idle", AnimationClip, (err, clip) => { node.getChildByName("hero").getComponent(Animation).addClip(clip); node.getChildByName("hero").getComponent(Animation).play("idle"); }); node.parent = this.node; node.setPosition(v3(-pos*100,0,0)) } reset() { this.node.destroy() } }