逐步 去掉 主英雄设定

This commit is contained in:
2025-08-05 10:32:18 +08:00
parent b6228f7747
commit 3db3cc78eb
6 changed files with 138 additions and 137 deletions

View File

@@ -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)

View File

@@ -46,34 +46,8 @@ export class MissionHeroCompComp extends CCComp {
this.addHero(args.uuid,false,true)
}
private call_friend(event: string, args: any,is_master:boolean=false){
console.log("[MissionHeroComp]:call_hero addHero",args.uuid,is_master)
let hero_pos=1
if(is_master){
hero_pos=0
}
let info:any={ap:0,hp:0,lv:0}
let hero = ecs.getEntity<Hero>(Hero);
let scale = 1
let heros=ecs.query(ecs.allOf(HeroViewComp))
for(let hero of heros){
let hv = hero.get(HeroViewComp)
if(hv.fight_pos==hero_pos){
hero_pos=2
break
}
}
console.log("[MissionHeroComp]:call_friend",heros)
let pos:Vec3 = HeroPos[hero_pos].pos;
if(is_master){
hero.hart_load(args.uuid)
}else{
hero.load(pos,scale,args.uuid,info,hero_pos);
}
}
call_hero(event: string, args: any){
// console.log("call_hero",args)
@@ -83,7 +57,7 @@ export class MissionHeroCompComp extends CCComp {
// let x=RandomManager.instance.getRandomInt(0,hero_list.length,1)
// // let uuid=args.uuid
// // console.log("call_hero",uuid)
this.addHero(args.uuid,args.is_master)
this.addHero(args.uuid,args.is_master,false)
}
/** 添加英雄 */
@@ -95,16 +69,11 @@ export class MissionHeroCompComp extends CCComp {
if(is_zhaohuan){
hero_pos=2
}
let info:any=this.get_info_and_remove(hero_pos,uuid)
// let info:any={ap:0,hp:0,lv:0}
let hero = ecs.getEntity<Hero>(Hero);
let scale = 1
let pos:Vec3 = HeroPos[hero_pos].pos;
if(is_master){
hero.hart_load(uuid)
}else{
hero.load(pos,scale,uuid,info,hero_pos);
}
hero.load(pos,scale,uuid);
}
get_info_and_remove(fight_pos:number,uuid:number){