refactor(game/map): 拆分任务开始和结束逻辑到独立方法
将原init方法拆分为onMissionStart和onMissionEnd方法,分别处理任务开始和结束时的逻辑 新增任务结束事件监听,清理动画和状态
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { _decorator, Label, Node, tween, Vec3, Color, Sprite } from "cc";
|
||||
import { _decorator, Label, Node, tween, Vec3, Color, Sprite, Tween } 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 { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
@@ -47,7 +47,8 @@ export class MissionCardComp extends CCComp {
|
||||
oops.message.on(GameEvent.TalentSelect, this.onTalentSelect, this);
|
||||
oops.message.on(GameEvent.HeroSkillSelect, this.onHeroSkillSelect, this);
|
||||
oops.message.on(GameEvent.ShopOpen, this.onShopOpen, this);
|
||||
oops.message.on(GameEvent.MissionStart, this.init, this);
|
||||
oops.message.on(GameEvent.MissionStart, this.onMissionStart, this);
|
||||
oops.message.on(GameEvent.MissionEnd, this.onMissionEnd, this);
|
||||
oops.message.on(GameEvent.ToCallFriend, this.onCallFriend, this);
|
||||
|
||||
}
|
||||
@@ -56,15 +57,38 @@ export class MissionCardComp extends CCComp {
|
||||
oops.message.off(GameEvent.TalentSelect, this.onTalentSelect, this);
|
||||
oops.message.off(GameEvent.HeroSkillSelect, this.onHeroSkillSelect, this);
|
||||
oops.message.off(GameEvent.ShopOpen, this.onShopOpen, this);
|
||||
oops.message.off(GameEvent.MissionStart, this.init, this);
|
||||
oops.message.off(GameEvent.MissionStart, this.onMissionStart, this);
|
||||
oops.message.off(GameEvent.MissionEnd, this.onMissionEnd, this);
|
||||
oops.message.off(GameEvent.ToCallFriend, this.onCallFriend, this);
|
||||
|
||||
this.ent.destroy();
|
||||
}
|
||||
init(){
|
||||
this.Lock.active=true
|
||||
this.onMissionStart();
|
||||
}
|
||||
|
||||
/** 游戏开始初始化 */
|
||||
onMissionStart() {
|
||||
this.Lock.active = true;
|
||||
this.eventQueue = [];
|
||||
}
|
||||
|
||||
/** 游戏结束清理 */
|
||||
onMissionEnd() {
|
||||
this.eventQueue = [];
|
||||
this.node.active = false;
|
||||
this.hasSelected = false;
|
||||
|
||||
// 停止所有卡片动画
|
||||
const cards = [this.card1, this.card2, this.card3, this.card4];
|
||||
cards.forEach(card => {
|
||||
if (card) {
|
||||
Tween.stopAllByTarget(card);
|
||||
const selected = card.getChildByName("selected");
|
||||
if (selected) Tween.stopAllByTarget(selected);
|
||||
}
|
||||
});
|
||||
}
|
||||
start() {
|
||||
// 初始隐藏或显示逻辑
|
||||
this.node.active = false;
|
||||
|
||||
Reference in New Issue
Block a user