逐步 去掉 主英雄设定
This commit is contained in:
@@ -39,7 +39,7 @@ export class MissionComp extends CCComp {
|
||||
wave_time_num:number = 0;
|
||||
wave_time_cd:Timer=new Timer(1);
|
||||
is_in_wave:boolean = false;
|
||||
tals:{
|
||||
tals:any={
|
||||
0:false,
|
||||
1:false,
|
||||
2:false,
|
||||
@@ -47,7 +47,11 @@ export class MissionComp extends CCComp {
|
||||
4:false,
|
||||
5:false,
|
||||
}
|
||||
|
||||
heros:any={
|
||||
0:{uuid:0,count:0},
|
||||
1:{uuid:0,count:0},
|
||||
2:{uuid:0,count:0},
|
||||
}
|
||||
onLoad(){
|
||||
this.on(GameEvent.MissionStart,this.mission_start,this)
|
||||
this.on(GameEvent.MasterCalled,this.ready_to_fight,this)
|
||||
@@ -58,7 +62,7 @@ export class MissionComp extends CCComp {
|
||||
this.on(GameEvent.MissionEnd,this.mission_end,this)
|
||||
this.on(GameEvent.DO_AD_BACK,this.do_ad,this)
|
||||
// this.on(GameEvent.CanUpdateLv,this.show_uplv_button,this)
|
||||
// this.on(GameEvent.UseEnhancement,this.hide_uplv_button,this)
|
||||
this.on(GameEvent.UseHeroCard,this.hero_called,this)
|
||||
|
||||
}
|
||||
|
||||
@@ -92,7 +96,53 @@ export class MissionComp extends CCComp {
|
||||
do_reward(){
|
||||
// 奖励发放
|
||||
}
|
||||
hero_called(event: any, data: any) {
|
||||
// 查找空位或已存在的英雄
|
||||
const heroIndex = this.findHeroSlot(data.uuid);
|
||||
|
||||
if (heroIndex !== -1) {
|
||||
// 找到英雄位置,增加数量
|
||||
this.heros[heroIndex].count += 1;
|
||||
} else {
|
||||
// 查找空位
|
||||
const emptySlot = this.findEmptySlot();
|
||||
if (emptySlot !== -1) {
|
||||
// 有空位,添加新英雄
|
||||
this.heros[emptySlot].uuid = data.uuid;
|
||||
this.heros[emptySlot].count = 1;
|
||||
} else {
|
||||
console.log("[MissionComp] 英雄已满");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找英雄位置
|
||||
* @param uuid 英雄UUID
|
||||
* @returns 英雄索引,未找到返回-1
|
||||
*/
|
||||
private findHeroSlot(uuid: number): number {
|
||||
for (let i = 0; i < 3; i++) {
|
||||
if (this.heros[i].uuid === uuid) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找空位
|
||||
* @returns 空位索引,无空位返回-1
|
||||
*/
|
||||
private findEmptySlot(): number {
|
||||
for (let i = 0; i < 3; i++) {
|
||||
if (this.heros[i].uuid === 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
count_tal(){
|
||||
let count=0
|
||||
for(let i=0;i<FightSet.TAL_NUM;i++){
|
||||
@@ -186,7 +236,6 @@ export class MissionComp extends CCComp {
|
||||
oops.message.dispatchEvent(GameEvent.FightReady)
|
||||
this.node.active=true
|
||||
this.data_init()
|
||||
// this.hart_hero_load()
|
||||
let loading=this.node.parent.getChildByName("loading")
|
||||
loading.active=true
|
||||
this.scheduleOnce(()=>{
|
||||
@@ -270,11 +319,6 @@ export class MissionComp extends CCComp {
|
||||
|
||||
}
|
||||
|
||||
//角色初始化
|
||||
hart_hero_load(){
|
||||
let hero = ecs.getEntity<Hero>(Hero);
|
||||
hero.hart_load()
|
||||
}
|
||||
|
||||
card_init(){
|
||||
oops.message.dispatchEvent(GameEvent.CardRefresh)
|
||||
|
||||
Reference in New Issue
Block a user