feat(hero, map): 修复FlashSprite查找逻辑,新增英雄升级触发特效
优化HeroViewComp中的FlashSprite查找逻辑,统一为先查找自身节点再遍历子节点 将HeroViewComp的lv_up方法改为公有以支持外部调用 在MissionHeroComp的英雄升级流程中添加升级特效触发代码
This commit is contained in:
@@ -112,7 +112,13 @@ export class HeroViewComp extends CCComp {
|
|||||||
this.hp_show();
|
this.hp_show();
|
||||||
|
|
||||||
// 根据英雄模型中的等级数据设置描边
|
// 根据英雄模型中的等级数据设置描边
|
||||||
const flashSprite = this.node.getComponent(FlashSprite);
|
// 注意:HeroViewComp 是挂在 node 上的,而 FlashSprite 可能挂在子节点(如 Sprite/anm 节点)
|
||||||
|
let flashSprite = this.node.getComponent(FlashSprite);
|
||||||
|
if (!flashSprite) {
|
||||||
|
// 如果当前节点没有,尝试在所有子节点中查找
|
||||||
|
flashSprite = this.node.getComponentInChildren(FlashSprite);
|
||||||
|
}
|
||||||
|
|
||||||
if (flashSprite) {
|
if (flashSprite) {
|
||||||
flashSprite.setOutlineByLevel(this.model.lv);
|
flashSprite.setOutlineByLevel(this.model.lv);
|
||||||
}
|
}
|
||||||
@@ -246,12 +252,15 @@ export class HeroViewComp extends CCComp {
|
|||||||
|
|
||||||
|
|
||||||
/** 升级特效 */
|
/** 升级特效 */
|
||||||
private lv_up() {
|
public lv_up() {
|
||||||
this.spawnTimedFx("game/skill/buff/buff_lvup", this.node, 1.0);
|
this.spawnTimedFx("game/skill/buff/buff_lvup", this.node, 1.0);
|
||||||
|
|
||||||
// 升级时同步更新描边
|
// 升级时同步更新描边
|
||||||
if (this.model) {
|
if (this.model) {
|
||||||
const flashSprite = this.node.getComponent(FlashSprite);
|
let flashSprite = this.node.getComponent(FlashSprite);
|
||||||
|
if (!flashSprite) {
|
||||||
|
flashSprite = this.node.getComponentInChildren(FlashSprite);
|
||||||
|
}
|
||||||
if (flashSprite) {
|
if (flashSprite) {
|
||||||
flashSprite.setOutlineByLevel(this.model.lv);
|
flashSprite.setOutlineByLevel(this.model.lv);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -262,6 +262,13 @@ export class MissionHeroCompComp extends CCComp {
|
|||||||
model.hp_max = Math.max(1, hp_max);
|
model.hp_max = Math.max(1, hp_max);
|
||||||
model.hp = model.hp_max;
|
model.hp = model.hp_max;
|
||||||
model.dirty_hp = true;
|
model.dirty_hp = true;
|
||||||
|
|
||||||
|
// 获取视图组件触发升级特效(包含描边更新)
|
||||||
|
const view = hero.get(HeroViewComp);
|
||||||
|
if (view && typeof view['lv_up'] === 'function') {
|
||||||
|
view['lv_up']();
|
||||||
|
}
|
||||||
|
|
||||||
oops.message.dispatchEvent(GameEvent.MasterCalled, {
|
oops.message.dispatchEvent(GameEvent.MasterCalled, {
|
||||||
eid: hero.eid,
|
eid: hero.eid,
|
||||||
model: model
|
model: model
|
||||||
|
|||||||
Reference in New Issue
Block a user