This commit is contained in:
2025-06-17 00:00:56 +08:00
parent 843d03ac20
commit 3ad905cd59
5 changed files with 83 additions and 17 deletions

View File

@@ -10,6 +10,7 @@ import { HeroViewComp } from "../hero/HeroViewComp";
import { oops } from "db://oops-framework/core/Oops";
import { HeroPos } from "../common/config/heroSet";
import { FightSet } from "../common/config/Mission";
import { FriendModelComp } from "../hero/FriendModel";
const { ccclass, property } = _decorator;
/** 视图层对象 */
@@ -21,14 +22,18 @@ export class MissionHeroCompComp extends CCComp {
Friend_is_dead:boolean=false
current_hero_uuid:number=0
onLoad(){
this.on(GameEvent.UseHeroCard,this.call_hero,this)
this.on(GameEvent.UseHeroCard,this.call_friend,this)
this.on(GameEvent.ChangeATK_FRIEND_LIVE_CD,this.change_friend_alive_cd,this)
this.on(GameEvent.FightReady,this.fight_ready,this)
}
start() {
// this.test_call()
this.node.getChildByName("location").active=false
}
fight_ready(){
this.Friend_alive_cd=new Timer(FightSet.FRIEND_LIVE_CD)
}
protected update(dt: number): void {
if(smc.mission.status != 1) return
if(this.Friend_is_dead){
@@ -38,17 +43,34 @@ export class MissionHeroCompComp extends CCComp {
}
}
change_friend_alive_cd(e:GameEvent,data:any){
console.log("change_friend_alive_cd",data)
this.Friend_alive_cd=new Timer(FightSet.FRIEND_LIVE_CD-data)
}
init(){
private call_friend(event: string, args: any,freind_pos:number=0){
console.log("call_hero addHero",args.uuid)
let info:any={ap:0,hp:0,lv:0}
let hero = ecs.getEntity<Hero>(Hero);
let scale = 1
let pos:Vec3 = HeroPos[freind_pos].pos;
hero.load(pos,scale,args.uuid,info,freind_pos);
oops.message.dispatchEvent(GameEvent.HeroSelectEnd)
console.log("call_friend",hero)
}
test_call(){
this.addHero(5010)
alive_friend(){
this.Friend_is_dead=false
let heros = ecs.query(ecs.allOf(FriendModelComp))
for(let hero of heros){
let hv = hero.get(HeroViewComp)
if(hv.is_dead){
hv.to_alive()
}
}
}
// show_heros_pos(event: string, args: any){
// console.log("show_heros_pos",args)
// this.current_hero_uuid=args.uuid
@@ -88,17 +110,19 @@ export class MissionHeroCompComp extends CCComp {
// }
// }
call_hero(event: string, args: any){
// this.node.getChildByName("location").active=false
// 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)
}
// call_hero(event: string, args: any){
// // this.node.getChildByName("location").active=false
// // 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)
// }
/** 添加英雄 */
private addHero(uuid:number=1001,freind_pos:number=0) {