From e695b9bdac3d7c6e9020386bedf55ae02f95de72 Mon Sep 17 00:00:00 2001 From: panw Date: Thu, 29 May 2025 16:45:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E6=B5=81=E7=A8=8B=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E9=80=9A=E8=BF=87=E8=8A=82=E7=82=B9=E9=97=B4=20?= =?UTF-8?q?=E9=80=9A=E4=BF=A1=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/resources/gui/role_controller.prefab | 10 +- assets/script/game/common/config/GameEvent.ts | 9 +- assets/script/game/hero/HeroViewComp.ts | 2 +- assets/script/game/map/MissionComp.ts | 91 +++++++------------ assets/script/game/map/MissionHomeComp.ts | 12 +-- assets/script/game/map/VictoryComp.ts | 31 +++++-- assets/script/game/skill/HeroSkillSystem.ts | 2 +- 7 files changed, 75 insertions(+), 82 deletions(-) diff --git a/assets/resources/gui/role_controller.prefab b/assets/resources/gui/role_controller.prefab index 332183ac..ad2c5f36 100644 --- a/assets/resources/gui/role_controller.prefab +++ b/assets/resources/gui/role_controller.prefab @@ -7602,7 +7602,7 @@ }, "component": "", "_componentId": "e7482dUVpJEJZzHkqJl1ZWP", - "handler": "mission_end", + "handler": "to_end_fight", "customEventData": "" }, { @@ -7803,7 +7803,7 @@ "__id__": 488 } ], - "_active": false, + "_active": true, "_components": [ { "__id__": 572 @@ -7827,7 +7827,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": 0, - "y": 640, + "y": -1000, "z": 0 }, "_lrot": { @@ -12509,8 +12509,8 @@ "_target": null, "_left": 0, "_right": 0, - "_top": 0, - "_bottom": 0, + "_top": 1640, + "_bottom": -1640, "_horizontalCenter": 0, "_verticalCenter": 0, "_isAbsLeft": false, diff --git a/assets/script/game/common/config/GameEvent.ts b/assets/script/game/common/config/GameEvent.ts index 12157179..b0eb0db2 100644 --- a/assets/script/game/common/config/GameEvent.ts +++ b/assets/script/game/common/config/GameEvent.ts @@ -12,8 +12,6 @@ export enum GameEvent { /** 登陆成功 */ LoginSuccess = "LoginSuccess", MSSelected = "MSSelected", - MissionStart = "MissionStart", - MissionEnd = "MissionEnd", CastSkill = "CastSkill", CardRefresh = "CardRefresh", UseCard = "UseCard", @@ -23,5 +21,12 @@ export enum GameEvent { MissionSkill = "MissionSkill", MissionLoss = "MissionLoss", MissionWin = "MissionWin", + MissionStart = "MissionStart", + FightStart = "FightStart", + FightPause = "FightPause", + FightResume = "FightResume", + FightEnd = "FightEnd", + MissionEnd = "MissionEnd", + MissionComplete = "MissionComplete",//战斗结算完成 } \ No newline at end of file diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index 909e891c..1d2648fb 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -265,7 +265,7 @@ export class HeroViewComp extends CCComp { console.log("角色死亡",this.hero_uuid) if(this.hero_uuid == 9999){ console.log("任务失败") - oops.message.dispatchEvent(GameEvent.MissionLoss,this) + oops.message.dispatchEvent(GameEvent.FightEnd,this) } } do_atked(remainingDamage:number){ diff --git a/assets/script/game/map/MissionComp.ts b/assets/script/game/map/MissionComp.ts index 1c90f473..5f116a7b 100644 --- a/assets/script/game/map/MissionComp.ts +++ b/assets/script/game/map/MissionComp.ts @@ -19,17 +19,8 @@ const { ccclass, property } = _decorator; @ecs.register('Mission', false) export class MissionComp extends CCComp { VictoryComp:any = null; - mon_list:any = [] - call_hero_timer: Timer = new Timer(0.3); - target_timer: Timer = new Timer(0.1); reward:number = 0; reward_num:number = 0; - game_over:boolean = false; - fight_start:boolean = false; - heros_node:any=null - heros_node_pos:any=v3(0,0,0) - herosc_node:any=null - hero_args:any=null mission_data:any={ gold:10,//金币 refresh_gold:1,//刷新金币 @@ -42,69 +33,45 @@ export class MissionComp extends CCComp { ap:0,//攻击 } onLoad(){ - this.on(GameEvent.MissionLoss,this.mission_end,this) - this.on(GameEvent.MissionWin,this.mission_end,this) + this.on(GameEvent.MissionStart,this.mission_start,this) + this.on(GameEvent.FightEnd,this.fight_end,this) + this.on(GameEvent.MissionEnd,this.mission_end,this) } - start() { - - } - protected update(dt: number): void { if(!smc.mission.play||smc.mission.pause){ return } - // if (this.game_timer.update(dt)) { - // smc.vmdata.game.g_time += 1; - // } + + } + + to_end_fight(){ + oops.message.dispatchEvent(GameEvent.FightEnd) } - call_hero(event: string, args: any){ - console.log("召唤英雄",args) - oops.message.dispatchEvent(GameEvent.CallHero,{uuid:this.hero_args.uuid,pos:args}) - this.hero_args=null - } mission_start(){ /* todo 关卡设定完善*/ console.log("战斗开始 关卡怪物:",Missions[smc.mission.lv]) - smc.mission.status=1 - this.colose_victory() - this.mission_init() - + this.node.active=true + this.data_init() + this.hero_init() } - - mission_end(){ + fight_end(){ + console.log("任务结束") // 延迟0.5秒后执行任务结束逻辑 this.scheduleOnce(() => { - oops.message.dispatchEvent(GameEvent.MissionEnd) smc.mission.play=false smc.mission.pause=false this.cleanComponents() - // this.to_mission_home() - this.open_victory() }, 0.5) } - private cleanComponents() { - ecs.query(ecs.allOf(HeroSkillsComp)).forEach(entity => {entity.remove(HeroSkillsComp);entity.destroy()}); - ecs.query(ecs.allOf(HeroViewComp)).forEach(entity => {entity.remove(HeroViewComp);entity.destroy()}); + mission_end(){ + this.node.active=false } - - open_victory(){ - this.node.getChildByName("victory").active=true - this.node.getChildByName("victory").getComponent(VictoryComp).open() - } - colose_victory(){ - this.node.getChildByName("victory").active=false - } - to_mission_home(){ - this.colose_victory() - let home =this.node.parent.getComponent(CardControllerComp); - home.mission_to_mission_home() - } - - mission_init(){ + data_init(){ //局内数据初始化 - this.fight_start=false + smc.mission.status=1 + smc.mission.play = true; smc.mission.is_victory=false smc.mission.is_defeat=false smc.vmdata.mission_data ={ @@ -118,20 +85,28 @@ export class MissionComp extends CCComp { hp:0,//血量 ap:0,//攻击 } + } + + //角色初始化 + hero_init(){ let hero = ecs.getEntity(Hero); hero.hart_load() this.scheduleOnce(() => { - this.card_refresh() - }, 0.5) + this.card_init() + }, 0.3) + } + card_init(){ + oops.message.dispatchEvent(GameEvent.CardRefresh) } - - card_refresh(){ oops.message.dispatchEvent(GameEvent.CardRefresh) } - - - + + private cleanComponents() { + ecs.query(ecs.allOf(HeroSkillsComp)).forEach(entity => {entity.remove(HeroSkillsComp);entity.destroy()}); + ecs.query(ecs.allOf(HeroViewComp)).forEach(entity => {entity.remove(HeroViewComp);entity.destroy()}); + } + /** 视图层逻辑代码分离演示 */ diff --git a/assets/script/game/map/MissionHomeComp.ts b/assets/script/game/map/MissionHomeComp.ts index e554f916..ccdc4e92 100644 --- a/assets/script/game/map/MissionHomeComp.ts +++ b/assets/script/game/map/MissionHomeComp.ts @@ -20,6 +20,7 @@ export class MissionHomeComp extends CCComp { {uuid:0,px:-300}, ] protected onLoad(): void { + this.on(GameEvent.MissionEnd,this.mission_end,this) } /** 视图层逻辑代码分离演示 */ start() { @@ -28,9 +29,11 @@ export class MissionHomeComp extends CCComp { this.load_ui_heros() } + to_start(){ } + start_mission() { for(let i=0;i void }> = []; init(): void { - oops.message.on(GameEvent.MissionEnd, this.clear_timer, this); + oops.message.on(GameEvent.FightEnd, this.clear_timer, this); } filter(): ecs.IMatcher { return ecs.allOf(HeroViewComp);