英雄召唤基本完成 下一步 满3个英雄后 不再出现其他英雄

This commit is contained in:
2025-08-05 22:28:24 +08:00
parent 6f9529ada2
commit 97bba4edb7
8 changed files with 3112 additions and 1365 deletions

View File

@@ -20,17 +20,27 @@ export class MissionHeroCompComp extends CCComp {
timer:Timer=new Timer(2)
Friend_is_dead:boolean=false
current_hero_uuid:number=0
current_hero_num:number=-1
heros:any=[]
onLoad(){
this.on(GameEvent.UseHeroCard,this.call_hero,this)
this.on(GameEvent.ChangeATK_EQUIP_SPECIAL_ATTR,this.change_equip_qpecial_attr,this)
this.on(GameEvent.FightReady,this.fight_ready,this)
this.on(GameEvent.Zhaohuan,this.zhao_huan,this)
}
start() {
// this.test_call()
}
fight_ready(){
this.heros=[]
for(let i=0;i<FightSet.HERO_MAX_NUM;i++){
this.heros.push({
uuid:0,
count:0,
quality:0,
})
}
this.current_hero_num=-1
this.current_hero_uuid=0
}
protected update(dt: number): void {
if(smc.mission.status != 1) return
@@ -38,9 +48,8 @@ export class MissionHeroCompComp extends CCComp {
}
change_equip_qpecial_attr(e:GameEvent,data:any){
}
private zhao_huan(event: string, args: any){
console.log("[MissionHeroComp]:zhaohuan",args)
this.addHero(args.uuid,false)
@@ -50,14 +59,48 @@ export class MissionHeroCompComp extends CCComp {
call_hero(event: string, args: any){
// console.log("call_hero",args)
// let fight_pos=args
// this.timer.reset()
// let hero_list =HeroList
// let x=RandomManager.instance.getRandomInt(0,hero_list.length,1)
// // let uuid=args.uuid
// // console.log("call_hero",uuid)
this.addHero(args.uuid,false)
console.log("[MissionHeroComp]:call_hero",this.heros,this.current_hero_num,args)
// 尝试升级现有英雄
if (this.tryUpgradeExistingHero(args.uuid)) {
return
}
// 添加新英雄
this.addNewHero(args.uuid)
}
/**
* 尝试升级现有英雄
* @param uuid 英雄UUID
* @returns 是否成功升级
*/
private tryUpgradeExistingHero(uuid: number): boolean {
for (let i = 0; i < this.heros.length; i++) {
console.log("[MissionHeroComp]:tryUpgradeExistingHero",this.heros,i,uuid)
if (this.heros[i].uuid === uuid) {
this.heros[i].count++
smc.vmdata[`hero${i+1}`].count=this.heros[i].count
oops.message.dispatchEvent(GameEvent.HeroLvUp, { uuid: uuid })
return true
}
}
return false
}
/**
* 添加新英雄到当前槽位
* @param uuid 英雄UUID
*/
private addNewHero(uuid: number) {
this.current_hero_num++
if(this.current_hero_num >= FightSet.HERO_MAX_NUM) return
this.current_hero_uuid = uuid
this.heros[this.current_hero_num].uuid = uuid
this.heros[this.current_hero_num].count = 1
this.heros[this.current_hero_num].quality = 0
this.addHero(uuid, false)
}
/** 添加英雄 */