feat: 实现战斗准备阶段英雄复活与入场动画
在准备阶段开始时,通过 PhasePrepareStart 事件触发英雄状态重置: - 死亡英雄复活并恢复满血,播放下落入场动画 - 英雄实体在死亡时移至墓地并禁用碰撞,避免战斗逻辑干扰 - 更新英雄数量UI以反映复活后的状态
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
* - FightSet —— 战斗常量(MERGE_NEED / MERGE_MAX)
|
||||
* - oneCom —— 一次性特效组件(控制爆点特效生命周期)
|
||||
*/
|
||||
import { _decorator, instantiate, Prefab, v3, Vec3 } from "cc";
|
||||
import { _decorator, instantiate, Prefab, v3, Vec3, BoxCollider2D } from "cc";
|
||||
import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
|
||||
import { Hero } from "../hero/Hero";
|
||||
@@ -35,8 +35,9 @@ import { GameEvent } from "../common/config/GameEvent";
|
||||
import { HeroInfo, HeroPos, HType } from "../common/config/heroSet";
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { FacSet, FightSet } from "../common/config/GameSet";
|
||||
import { FacSet, FightSet, BoxSet } from "../common/config/GameSet";
|
||||
import { oneCom } from "../skill/oncend";
|
||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
const { ccclass } = _decorator;
|
||||
|
||||
/**
|
||||
@@ -89,11 +90,13 @@ export class MissionHeroCompComp extends CCComp {
|
||||
this.on(GameEvent.MissionEnd,this.clear_heros,this)
|
||||
// 注册全局消息
|
||||
oops.message.on(GameEvent.CallHero,this.call_hero,this)
|
||||
oops.message.on("PhasePrepareStart",this.fight_ready,this)
|
||||
}
|
||||
|
||||
onDestroy(){
|
||||
// 清理全部监听
|
||||
oops.message.off(GameEvent.CallHero,this.call_hero,this)
|
||||
oops.message.off("PhasePrepareStart",this.fight_ready,this)
|
||||
oops.message.off(GameEvent.FightReady,this.fight_ready,this)
|
||||
oops.message.off(GameEvent.Zhaohuan,this.zhao_huan,this)
|
||||
oops.message.off(GameEvent.MissionEnd,this.clear_heros,this)
|
||||
@@ -104,17 +107,36 @@ export class MissionHeroCompComp extends CCComp {
|
||||
|
||||
// ======================== 事件处理 ========================
|
||||
|
||||
/** 关卡结束时清理全部存活英雄 ECS 实体 */
|
||||
/** 关卡结束时清理全部英雄 ECS 实体 */
|
||||
clear_heros(){
|
||||
const heroes = this.getAliveHeroes();
|
||||
const heroes = this.getAllHeroes();
|
||||
for (let i = 0; i < heroes.length; i++) {
|
||||
heroes[i].destroy();
|
||||
}
|
||||
}
|
||||
|
||||
/** 战斗准备阶段:重置出战英雄计数 */
|
||||
/** 战斗准备阶段:重置出战英雄计数,恢复满血重新登场 */
|
||||
fight_ready(){
|
||||
smc.vmdata.mission_data.hero_num=0
|
||||
const heroes = this.getAllHeroes();
|
||||
smc.vmdata.mission_data.hero_num = heroes.length;
|
||||
for (let i = 0; i < heroes.length; i++) {
|
||||
const hero = heroes[i];
|
||||
const model = hero.get(HeroAttrsComp);
|
||||
const view = hero.get(HeroViewComp);
|
||||
if (model && view) {
|
||||
if (model.is_dead) {
|
||||
view.alive();
|
||||
const landingPos = this.resolveHeroLandingPos(model.hero_uuid);
|
||||
// 不再直接设置位置,而是播放下落入场动画
|
||||
// 计算出出生点(空中)
|
||||
const spawnPos: Vec3 = v3(landingPos.x, landingPos.y + MissionHeroCompComp.HERO_DROP_HEIGHT, 0);
|
||||
view.node.setPosition(spawnPos);
|
||||
hero.playDropAnim(spawnPos, landingPos.y);
|
||||
}
|
||||
model.hp = model.hp_max;
|
||||
model.dirty_hp = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 预留:召唤事件扩展入口 */
|
||||
@@ -219,14 +241,13 @@ export class MissionHeroCompComp extends CCComp {
|
||||
|
||||
// ======================== 英雄查询 ========================
|
||||
|
||||
/** 获取当前全部存活友方英雄 ECS 实体列表 */
|
||||
private getAliveHeroes(): Hero[] {
|
||||
/** 获取当前全部友方英雄 ECS 实体列表(包括存活和墓地) */
|
||||
private getAllHeroes(): Hero[] {
|
||||
const heroes: Hero[] = [];
|
||||
ecs.query(ecs.allOf(HeroAttrsComp)).forEach((entity: ecs.Entity) => {
|
||||
const model = entity.get(HeroAttrsComp);
|
||||
if (!model) return;
|
||||
if (model.fac !== FacSet.HERO) return;
|
||||
if (model.is_dead) return;
|
||||
heroes.push(entity as Hero);
|
||||
});
|
||||
return heroes;
|
||||
@@ -321,7 +342,7 @@ export class MissionHeroCompComp extends CCComp {
|
||||
this.addHero(uuid, hero_lv, pool_lv);
|
||||
if (!this.canMergeLevel(hero_lv)) return;
|
||||
const needCount = this.getMergeNeedCount();
|
||||
const aliveHeroes = this.getAliveHeroes();
|
||||
const aliveHeroes = this.getAllHeroes();
|
||||
const mergeHeroes = this.pickMergeHeroes(aliveHeroes, uuid, hero_lv, needCount);
|
||||
if (mergeHeroes.length !== needCount) return;
|
||||
this.is_merging = true;
|
||||
@@ -442,7 +463,7 @@ export class MissionHeroCompComp extends CCComp {
|
||||
if (!this.canMergeLevel(checkLv)) {
|
||||
break;
|
||||
}
|
||||
const aliveHeroes = this.getAliveHeroes();
|
||||
const aliveHeroes = this.getAllHeroes();
|
||||
const sameCount = this.countMergeHeroes(aliveHeroes, uuid, checkLv);
|
||||
if (sameCount < needCount) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user