refactor: 清理废弃资源并优化卡牌相关逻辑
1. 删除废弃的notify.prefab和TalentSet.ts.meta文件 2. 新增MSkillBox预制体资源 3. 优化MissionCardComp抽卡按钮显示逻辑 4. 格式化CardComp.ts代码格式与变量声明 5. 优化MissionComp.ts代码格式与事件绑定 6. 更新mission.prefab布局添加技能槽位
This commit is contained in:
@@ -67,19 +67,22 @@ export class CardComp extends CCComp {
|
||||
// info_node=null!
|
||||
/** 卡牌名称标签节点 */
|
||||
@property(Node)
|
||||
name_node=null!
|
||||
name_node = null!
|
||||
/** 卡牌图标节点(英雄动画 / 技能图标) */
|
||||
@property(Node)
|
||||
icon_node=null!
|
||||
icon_node = null!
|
||||
/** 费用显示节点 */
|
||||
@property(Node)
|
||||
cost_node=null!
|
||||
cost_node = null!
|
||||
/** 卡牌种类标识节点(如近战 / 远程 / 辅助等分类子节点的容器) */
|
||||
@property(Node)
|
||||
Ckind_node=null!
|
||||
Ckind_node = null!
|
||||
/** 卡牌背景底框节点(按卡池等级切换子节点显示) */
|
||||
@property(Node)
|
||||
BG_node=null!
|
||||
BG_node = null!
|
||||
/** 技能卡牌信息节点,显示技能信息*/
|
||||
@property(Node)
|
||||
info_node = null!
|
||||
|
||||
|
||||
|
||||
@@ -87,18 +90,18 @@ export class CardComp extends CCComp {
|
||||
lvl_node: Label = null! //英雄本身的等级
|
||||
|
||||
@property(Node)
|
||||
ap_node=null!
|
||||
ap_node = null!
|
||||
@property(Node)
|
||||
hp_node=null!
|
||||
hp_node = null!
|
||||
|
||||
// ======================== 运行时状态 ========================
|
||||
|
||||
/** 当前卡牌的金币费用 */
|
||||
card_cost:number=0
|
||||
card_cost: number = 0
|
||||
/** 当前卡牌类型(英雄 / 技能 / 特殊升级 / 特殊刷新) */
|
||||
card_type:CardType=CardType.Hero
|
||||
card_type: CardType = CardType.Hero
|
||||
/** 当前卡牌的唯一标识 UUID */
|
||||
card_uuid:number=0
|
||||
card_uuid: number = 0
|
||||
/** 是否处于锁定状态(锁定且有卡时,抽卡分发会被跳过) */
|
||||
private isLocked: boolean = false;
|
||||
/** 当前槽位承载的卡牌数据,null 表示空槽 */
|
||||
@@ -148,7 +151,7 @@ export class CardComp extends CCComp {
|
||||
this.applyEmptyUI();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/** 组件销毁时解绑所有事件,防止残留回调 */
|
||||
onDestroy() {
|
||||
super.onDestroy();
|
||||
@@ -156,18 +159,18 @@ export class CardComp extends CCComp {
|
||||
}
|
||||
|
||||
/** 外部初始化入口(由 MissionCardComp 调用) */
|
||||
init(){
|
||||
init() {
|
||||
this.onMissionStart();
|
||||
}
|
||||
|
||||
|
||||
/** 游戏开始初始化(预留扩展) */
|
||||
onMissionStart() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/** 游戏结束清理(预留扩展) */
|
||||
onMissionEnd() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/** 节点启动时确保可见 */
|
||||
@@ -183,7 +186,7 @@ export class CardComp extends CCComp {
|
||||
* @param card 卡牌节点引用(历史遗留参数,当前未使用)
|
||||
* @param data 卡牌配置数据
|
||||
*/
|
||||
updateCardInfo(card:Node, data: CardConfig){
|
||||
updateCardInfo(card: Node, data: CardConfig) {
|
||||
this.applyDrawCard(data);
|
||||
}
|
||||
|
||||
@@ -218,13 +221,13 @@ export class CardComp extends CCComp {
|
||||
* @param index 索引字符串(历史遗留参数)
|
||||
*/
|
||||
selectCard(e: any, index: string) {
|
||||
this.useCard();
|
||||
this.useCard();
|
||||
}
|
||||
|
||||
|
||||
/** 关闭界面(预留) */
|
||||
close() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
// ======================== 核心业务方法 ========================
|
||||
@@ -285,7 +288,7 @@ export class CardComp extends CCComp {
|
||||
useCard(): CardConfig | null {
|
||||
if (!this.cardData || this.isUsing) return null;
|
||||
const cardCost = this.card_cost;
|
||||
|
||||
|
||||
// 英雄卡特殊校验:通过 guard 对象实现"可取消"模式
|
||||
if (this.cardData.type === CardType.Hero) {
|
||||
const guard = {
|
||||
@@ -318,7 +321,7 @@ export class CardComp extends CCComp {
|
||||
|
||||
// 【评分系统 - 效率分】记录刷新后的选中卡次数(命中率分子)
|
||||
smc.vmdata.scores.refresh_hit_count++;
|
||||
|
||||
|
||||
// 标记使用中,阻止并发操作
|
||||
this.isUsing = true;
|
||||
const used = this.cardData;
|
||||
@@ -359,7 +362,7 @@ export class CardComp extends CCComp {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** 查询槽位是否有卡 */
|
||||
hasCard(): boolean {
|
||||
return !!this.cardData;
|
||||
@@ -519,7 +522,7 @@ export class CardComp extends CCComp {
|
||||
this.isLongPressed = false;
|
||||
oops.gui.remove(UIID.HInfo);
|
||||
}
|
||||
|
||||
|
||||
if (deltaY >= this.dragUseThreshold) {
|
||||
const used = this.useCard();
|
||||
if (!used) {
|
||||
@@ -527,7 +530,7 @@ export class CardComp extends CCComp {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
this.playReboundAnim();
|
||||
}
|
||||
|
||||
@@ -602,9 +605,9 @@ export class CardComp extends CCComp {
|
||||
// 递增视觉令牌,用于异步加载竞态保护
|
||||
this.iconVisualToken += 1;
|
||||
if (this.opacityComp) this.opacityComp.opacity = 255;
|
||||
|
||||
|
||||
this.node.setPosition(this.restPosition.x, this.restPosition.y, this.restPosition.z);
|
||||
|
||||
|
||||
// ---- 卡牌种类标识(近战 / 远程 / 辅助等) ----
|
||||
const kindName = CKind[this.cardData.kind];
|
||||
|
||||
@@ -633,7 +636,7 @@ export class CardComp extends CCComp {
|
||||
const widget = this.node.getComponent(Widget);
|
||||
if (widget) widget.updateAlignment();
|
||||
}
|
||||
|
||||
|
||||
if (this.BG_node) {
|
||||
const bgTrans = this.BG_node.getComponent(UITransform);
|
||||
if (bgTrans) {
|
||||
@@ -650,7 +653,7 @@ export class CardComp extends CCComp {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const hbNode = this.node.getChildByName("HB");
|
||||
if (hbNode) {
|
||||
const hbTrans = hbNode.getComponent(UITransform);
|
||||
@@ -660,7 +663,7 @@ export class CardComp extends CCComp {
|
||||
if (widget) widget.updateAlignment();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 触发布局刷新,确保其所有子节点(比如右上角的cost、名字等)依赖 Widget 的节点重新对齐
|
||||
this.node.children.forEach(child => {
|
||||
const widget = child.getComponent(Widget);
|
||||
@@ -680,7 +683,7 @@ export class CardComp extends CCComp {
|
||||
if (widget) widget.updateAlignment();
|
||||
}
|
||||
|
||||
if(this.card_type===CardType.Hero){
|
||||
if (this.card_type === CardType.Hero) {
|
||||
const hero = HeroInfo[this.card_uuid];
|
||||
const heroLv = Math.max(1, this.cardData.hero_lv ?? hero?.lv ?? 1);
|
||||
this.setLabel(this.name_node, `${hero?.name || ""}`);
|
||||
@@ -691,11 +694,11 @@ export class CardComp extends CCComp {
|
||||
}
|
||||
this.ap_node.getChildByName("val").getComponent(Label).string = `${(hero?.ap ?? 0) * heroLv}`;
|
||||
this.hp_node.getChildByName("val").getComponent(Label).string = `${(hero?.hp ?? 0) * heroLv}`;
|
||||
|
||||
|
||||
|
||||
this.ap_node.active = true;
|
||||
this.hp_node.active = true;
|
||||
}else if(this.card_type===CardType.Skill){
|
||||
} else if (this.card_type === CardType.Skill) {
|
||||
if (this.lvl_node) this.lvl_node.node.active = false;
|
||||
// 技能卡:显示技能名 + 品质后缀 + 描述
|
||||
const skill = SkillSet[this.card_uuid];
|
||||
@@ -706,7 +709,7 @@ export class CardComp extends CCComp {
|
||||
|
||||
this.ap_node.active = false;
|
||||
this.hp_node.active = false;
|
||||
}else{
|
||||
} else {
|
||||
if (this.lvl_node) this.lvl_node.node.active = false;
|
||||
// 特殊卡(升级 / 刷新):显示卡名 + 品质后缀 + 描述
|
||||
const specialCard = this.card_type === CardType.SpecialUpgrade
|
||||
@@ -728,7 +731,7 @@ export class CardComp extends CCComp {
|
||||
this.setLabel(numNode, `${this.card_cost}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (this.name_node) {
|
||||
const currentPos = this.name_node.position;
|
||||
this.name_node.setPosition(currentPos.x, -70, currentPos.z);
|
||||
@@ -841,7 +844,7 @@ export class CardComp extends CCComp {
|
||||
if (widget) widget.updateAlignment();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.node.children.forEach(child => {
|
||||
const widget = child.getComponent(Widget);
|
||||
if (widget) widget.updateAlignment();
|
||||
|
||||
@@ -603,13 +603,17 @@ export class MissionCardComp extends CCComp {
|
||||
this.cardsHideScale = new Vec3(0, 0, this.cardsBaseScale.z);
|
||||
}
|
||||
|
||||
/** 进入准备阶段:展开卡牌面板(立即恢复缩放,无动画) */
|
||||
/** 进入准备阶段:展开卡牌面板(立即恢复缩放,无动画)+ 显示抽卡按钮 */
|
||||
private enterPreparePhase() {
|
||||
if (!this.cards_node || !this.cards_node.isValid) return;
|
||||
this.initCardsPanelPos();
|
||||
this.cards_node.active = true;
|
||||
Tween.stopAllByTarget(this.cards_node);
|
||||
this.cards_node.setScale(this.cardsShowScale);
|
||||
// 准备阶段:显示抽卡按钮
|
||||
if (this.cards_chou && this.cards_chou.isValid) {
|
||||
this.cards_chou.active = true;
|
||||
}
|
||||
}
|
||||
|
||||
private enterBattlePhase() {
|
||||
@@ -625,6 +629,10 @@ export class MissionCardComp extends CCComp {
|
||||
// }
|
||||
// })
|
||||
// .start();
|
||||
// 战斗阶段:隐藏抽卡按钮
|
||||
if (this.cards_chou && this.cards_chou.isValid) {
|
||||
this.cards_chou.active = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 构建本次抽卡结果,保证最终可分发3条数据 */
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
* - CardInitCoins —— 初始金币数
|
||||
* - UIID.Victory —— 结算弹窗
|
||||
*/
|
||||
import { _decorator, Vec3,Animation, instantiate, Prefab, Node, NodeEventType, ProgressBar, Label, CCInteger, tween, v3, Tween, Widget, UIOpacity } from "cc";
|
||||
import { _decorator, Vec3, Animation, instantiate, Prefab, Node, NodeEventType, ProgressBar, Label, CCInteger, tween, v3, Tween, Widget, UIOpacity } 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 { smc } from "../common/SingletonModuleComp";
|
||||
@@ -97,17 +97,17 @@ export class MissionComp extends CCComp {
|
||||
/** 卡池升级波次配置:达到对应波次时,推送卡池升级事件 */
|
||||
@property({ type: [CCInteger], tooltip: "卡池升级波次配置,例如 [10, 20] 表示第10波升到2级,第20波升到3级" })
|
||||
cardPoolUpgradeWaves: number[] = [5, 10];
|
||||
|
||||
|
||||
// ======================== 编辑器绑定节点 ========================
|
||||
|
||||
/** 开始战斗按钮 */
|
||||
@property(Node)
|
||||
start_btn:Node = null!
|
||||
start_btn: Node = null!
|
||||
/** 时间/波数显示节点 */
|
||||
@property(Node)
|
||||
time_node:Node = null!
|
||||
time_node: Node = null!
|
||||
@property(Node)
|
||||
tooltip:Node = null!
|
||||
tooltip: Node = null!
|
||||
|
||||
/** 阶段名称映射表(用于 UI 显示) */
|
||||
private static readonly PhaseNameMap: Record<MissionPhase, string> = {
|
||||
@@ -124,19 +124,19 @@ export class MissionComp extends CCComp {
|
||||
// ======================== 运行时状态 ========================
|
||||
|
||||
/** 战斗已耗时(秒),正向计时 */
|
||||
clearTime:number = 0
|
||||
clearTime: number = 0
|
||||
/** 剩余复活次数 */
|
||||
revive_times: number = 1;
|
||||
/** 掉落奖励列表 */
|
||||
rewards:any[]=[]
|
||||
rewards: any[] = []
|
||||
/** 累计游戏数据 */
|
||||
game_data:any={
|
||||
exp:0,
|
||||
gold:0,
|
||||
diamond:0
|
||||
game_data: any = {
|
||||
exp: 0,
|
||||
gold: 0,
|
||||
diamond: 0
|
||||
}
|
||||
/**秒计时 */
|
||||
PhaseTime:Timer= new Timer(1)
|
||||
PhaseTime: Timer = new Timer(1)
|
||||
/** 上一次显示的时间字符串(避免重复设置) */
|
||||
private lastTimeStr: string = "";
|
||||
/** 上一次显示的秒数(避免重复计算) */
|
||||
@@ -180,18 +180,18 @@ export class MissionComp extends CCComp {
|
||||
private skillViewMatcher: any = null;
|
||||
/** 匹配拥有 HeroAttrsComp 的实体(英雄/怪物属性) */
|
||||
private heroAttrsMatcher: any = null;
|
||||
|
||||
|
||||
// ======================== 生命周期 ========================
|
||||
|
||||
onLoad(){
|
||||
onLoad() {
|
||||
this.heroViewMatcher = ecs.allOf(HeroViewComp);
|
||||
this.skillViewMatcher = ecs.allOf(SkillView);
|
||||
this.heroAttrsMatcher = ecs.allOf(HeroAttrsComp);
|
||||
this.showMemoryPanel = false
|
||||
// 注册生命周期事件
|
||||
this.on(GameEvent.MissionEnd,this.mission_end,this)
|
||||
this.on(GameEvent.NewWave,this.onNewWave,this)
|
||||
this.on(GameEvent.DO_AD_BACK,this.do_ad,this)
|
||||
this.on(GameEvent.MissionEnd, this.mission_end, this)
|
||||
this.on(GameEvent.NewWave, this.onNewWave, this)
|
||||
this.on(GameEvent.DO_AD_BACK, this.do_ad, this)
|
||||
this.start_btn?.on(NodeEventType.TOUCH_END, this.onStartFightBtnClick, this)
|
||||
this.removeMemoryPanel()
|
||||
}
|
||||
@@ -206,7 +206,7 @@ export class MissionComp extends CCComp {
|
||||
smc.map.MapView.scene.mapLayer.stopAnimations();
|
||||
}
|
||||
|
||||
onDestroy(){
|
||||
onDestroy() {
|
||||
smc.map.MapView.scene.mapLayer.playAnimations()
|
||||
super.onDestroy();
|
||||
if (this.start_btn && this.start_btn.isValid) {
|
||||
@@ -220,10 +220,10 @@ export class MissionComp extends CCComp {
|
||||
* - 战斗中 → 同步怪物状态、更新计时器
|
||||
*/
|
||||
protected update(dt: number): void {
|
||||
if(!smc.mission.play) return
|
||||
if (!smc.mission.play) return
|
||||
|
||||
// 如果是暂停状态,且不在 BattleEnd 阶段(全灭时需要播放完 fend 技能动画并自动流转),才真正停止 update 逻辑
|
||||
if(smc.mission.pause && this.currentPhase !== MissionPhase.BattleEnd) return
|
||||
if (smc.mission.pause && this.currentPhase !== MissionPhase.BattleEnd) return
|
||||
|
||||
// 处理过渡阶段的计时
|
||||
if (this.currentPhase === MissionPhase.PrepareStart ||
|
||||
@@ -235,10 +235,10 @@ export class MissionComp extends CCComp {
|
||||
}
|
||||
}
|
||||
|
||||
if(this.currentPhase === MissionPhase.Battle){
|
||||
if (this.currentPhase === MissionPhase.Battle) {
|
||||
this.syncMonsterSpawnState(dt)
|
||||
if(smc.mission.stop_mon_action) return
|
||||
smc.vmdata.mission_data.fight_time+=dt
|
||||
if (smc.mission.stop_mon_action) return
|
||||
smc.vmdata.mission_data.fight_time += dt
|
||||
this.clearTime += dt
|
||||
this.update_time();
|
||||
}
|
||||
@@ -247,14 +247,14 @@ export class MissionComp extends CCComp {
|
||||
// ======================== 时间显示 ========================
|
||||
|
||||
/** 更新时间/波数显示(仅在秒数变化时更新以减少 Label 操作) */
|
||||
update_time(){
|
||||
update_time() {
|
||||
const remainSecond = Math.floor(this.clearTime);
|
||||
if (remainSecond === this.lastTimeSecond) return;
|
||||
this.lastTimeSecond = remainSecond;
|
||||
let m = Math.floor(remainSecond / 60);
|
||||
let s = remainSecond % 60;
|
||||
let str = `${m.toString().padStart(2, '0')}:${s.toString().padStart(2, '0')}`;
|
||||
if(str != this.lastTimeStr){
|
||||
if (str != this.lastTimeStr) {
|
||||
if (this.time_node && this.time_node.isValid) {
|
||||
const timeChild = this.time_node.getChildByName("time");
|
||||
if (timeChild) {
|
||||
@@ -269,24 +269,24 @@ export class MissionComp extends CCComp {
|
||||
// ======================== 奖励与广告 ========================
|
||||
|
||||
/** 奖励发放(预留) */
|
||||
do_reward(){
|
||||
do_reward() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 广告回调处理:
|
||||
* 成功 → 增加刷新次数;失败 → 分发失败事件。
|
||||
*/
|
||||
do_ad(){
|
||||
if(this.ad_back()){
|
||||
do_ad() {
|
||||
if (this.ad_back()) {
|
||||
oops.message.dispatchEvent(GameEvent.AD_BACK_TRUE)
|
||||
smc.vmdata.mission_data.refresh_count+=FightSet.MORE_RC
|
||||
}else{
|
||||
smc.vmdata.mission_data.refresh_count += FightSet.MORE_RC
|
||||
} else {
|
||||
oops.message.dispatchEvent(GameEvent.AD_BACK_FALSE)
|
||||
}
|
||||
}
|
||||
|
||||
/** 广告观看结果(预留,默认返回 true) */
|
||||
ad_back(){
|
||||
ad_back() {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -300,18 +300,18 @@ export class MissionComp extends CCComp {
|
||||
* 4. 分发 FightReady 事件。
|
||||
* 5. 进入准备阶段并显示 loading。
|
||||
*/
|
||||
async mission_start(){
|
||||
async mission_start() {
|
||||
this.unscheduleAllCallbacks();
|
||||
this.cleanComponents();
|
||||
this.data_init()
|
||||
oops.message.dispatchEvent(GameEvent.FightReady)
|
||||
this.changePhase(MissionPhase.Prepare)
|
||||
let loading=this.node.getChildByName("loading")
|
||||
let loading = this.node.getChildByName("loading")
|
||||
if (loading) {
|
||||
loading.active=true
|
||||
this.scheduleOnce(()=>{
|
||||
loading.active=false
|
||||
},0.5)
|
||||
loading.active = true
|
||||
this.scheduleOnce(() => {
|
||||
loading.active = false
|
||||
}, 0.5)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,8 +389,8 @@ export class MissionComp extends CCComp {
|
||||
const phaseName = MissionComp.PhaseNameMap[targetPhase] || "未知";
|
||||
|
||||
// 播放状态切换提示栏动效(过滤掉 None、Prepare 准备阶段、Battle 战斗中阶段)
|
||||
if (targetPhase !== MissionPhase.None &&
|
||||
targetPhase !== MissionPhase.Prepare &&
|
||||
if (targetPhase !== MissionPhase.None &&
|
||||
targetPhase !== MissionPhase.Prepare &&
|
||||
targetPhase !== MissionPhase.Battle) {
|
||||
this.playTooltipAnim(phaseName);
|
||||
}
|
||||
@@ -404,7 +404,7 @@ export class MissionComp extends CCComp {
|
||||
const wave = Math.max(1, this.currentWave || (smc.vmdata && smc.vmdata.mission_data ? smc.vmdata.mission_data.level : 1) || 1);
|
||||
label.string = `第 ${wave}/15 波`;
|
||||
}
|
||||
|
||||
|
||||
// 阶段切换动感表现:只在进入战斗阶段跳动一下,让流程充满心流体验
|
||||
if (targetPhase === MissionPhase.BattleStart) {
|
||||
Tween.stopAllByTarget(this.time_node);
|
||||
@@ -449,6 +449,10 @@ export class MissionComp extends CCComp {
|
||||
smc.mission.stop_spawn_mon = false;
|
||||
smc.mission.in_fight = true;
|
||||
smc.vmdata.mission_data.in_fight = true;
|
||||
// 战斗阶段:隐藏开始按钮
|
||||
if (this.start_btn && this.start_btn.isValid) {
|
||||
this.start_btn.active = false;
|
||||
}
|
||||
oops.message.dispatchEvent(GameEvent.FightStart);
|
||||
break;
|
||||
|
||||
@@ -462,7 +466,7 @@ export class MissionComp extends CCComp {
|
||||
smc.vmdata.scores.wave_win_count++;
|
||||
// 【评分系统 - 战绩分】记录每回合结束时场上留存的敌人数量(扣分项)
|
||||
smc.vmdata.scores.wave_remain_monsters += smc.vmdata.mission_data.mon_num;
|
||||
|
||||
|
||||
let allAlive = true;
|
||||
let hasHero = false;
|
||||
ecs.query(this.heroAttrsMatcher).forEach(entity => {
|
||||
@@ -485,7 +489,7 @@ export class MissionComp extends CCComp {
|
||||
|
||||
// 触发战斗结束技能(fend)
|
||||
this.triggerHeroBattleSkills(false);
|
||||
|
||||
|
||||
// 战斗结束阶段,给予所有英雄恢复70%血量的技能效果
|
||||
this.healAllHeroes();
|
||||
break;
|
||||
@@ -496,7 +500,7 @@ export class MissionComp extends CCComp {
|
||||
smc.mission.stop_spawn_mon = true;
|
||||
// 不隐藏开始按钮
|
||||
break;
|
||||
|
||||
|
||||
case MissionPhase.None:
|
||||
smc.mission.in_fight = false;
|
||||
smc.vmdata.mission_data.in_fight = false;
|
||||
@@ -529,7 +533,7 @@ export class MissionComp extends CCComp {
|
||||
this.changePhase(MissionPhase.PrepareStart);
|
||||
} else {
|
||||
this.changePhase(MissionPhase.Settle);
|
||||
|
||||
|
||||
// 此时已经经过了 2s,可以真正执行结算弹窗或清理逻辑
|
||||
if (smc.mission.play) {
|
||||
// 如果游戏还在运行中,说明是通过 open_Victory 进来的
|
||||
@@ -559,7 +563,7 @@ export class MissionComp extends CCComp {
|
||||
* - 分发 FightStart 事件
|
||||
* - 触发英雄战斗开始技能
|
||||
*/
|
||||
to_fight(){
|
||||
to_fight() {
|
||||
this.changePhase(MissionPhase.PrepareEnd);
|
||||
}
|
||||
|
||||
@@ -609,14 +613,14 @@ export class MissionComp extends CCComp {
|
||||
const attrs = entity.get(HeroAttrsComp);
|
||||
const view = entity.get(HeroViewComp);
|
||||
if (!attrs || !view || attrs.fac !== FacSet.HERO) return;
|
||||
|
||||
|
||||
// 计算恢复量:基于配置的百分比(如 70%)的最大生命值
|
||||
const healAmount = Math.floor(attrs.hp_max * finalHealRate);
|
||||
|
||||
|
||||
// 应用恢复量,不超过最大生命值
|
||||
attrs.hp = Math.min(attrs.hp_max, attrs.hp + healAmount);
|
||||
attrs.dirty_hp = true;
|
||||
|
||||
|
||||
// 重置复活次数,使得下回合可以继续复活
|
||||
attrs.revived_count = 0;
|
||||
|
||||
@@ -642,7 +646,7 @@ export class MissionComp extends CCComp {
|
||||
* @param e 事件对象(未使用)
|
||||
* @param is_hero_dead 是否因英雄全灭触发
|
||||
*/
|
||||
open_Victory(e:any,is_hero_dead: boolean = false){
|
||||
open_Victory(e: any, is_hero_dead: boolean = false) {
|
||||
// 战斗失败或胜利,标记暂停状态以切断波次流转逻辑
|
||||
smc.mission.pause = true;
|
||||
// 直接切入 BattleEnd,触发 fend 表现
|
||||
@@ -652,9 +656,9 @@ export class MissionComp extends CCComp {
|
||||
|
||||
|
||||
/** 战斗结束:延迟清理组件和对象池 */
|
||||
fight_end(){
|
||||
fight_end() {
|
||||
// 这里只是强制清理关卡,为了防止重复弹窗,标记 play = false
|
||||
smc.mission.play=false
|
||||
smc.mission.play = false
|
||||
this.changePhase(MissionPhase.BattleEnd);
|
||||
}
|
||||
|
||||
@@ -665,9 +669,9 @@ export class MissionComp extends CCComp {
|
||||
* - 清理组件和对象池
|
||||
* - 隐藏节点
|
||||
*/
|
||||
mission_end(){
|
||||
mission_end() {
|
||||
this.unscheduleAllCallbacks();
|
||||
smc.mission.play=false
|
||||
smc.mission.play = false
|
||||
smc.mission.pause = false;
|
||||
this.changePhase(MissionPhase.None);
|
||||
this.cleanComponents()
|
||||
@@ -682,7 +686,7 @@ export class MissionComp extends CCComp {
|
||||
* - 奖励列表 / 复活次数
|
||||
* - 性能监控基准值
|
||||
*/
|
||||
data_init(){
|
||||
data_init() {
|
||||
if (!this.PhaseTime) {
|
||||
this.PhaseTime = new Timer(1);
|
||||
}
|
||||
@@ -690,16 +694,16 @@ export class MissionComp extends CCComp {
|
||||
smc.mission.pause = false;
|
||||
smc.mission.stop_mon_action = false;
|
||||
smc.mission.stop_spawn_mon = false;
|
||||
smc.vmdata.mission_data.in_fight=false
|
||||
smc.vmdata.mission_data.fight_time=0
|
||||
smc.vmdata.mission_data.in_fight = false
|
||||
smc.vmdata.mission_data.fight_time = 0
|
||||
this.clearTime = 0
|
||||
smc.vmdata.mission_data.mon_num=0
|
||||
smc.vmdata.mission_data.mon_num = 0
|
||||
smc.vmdata.mission_data.level = 1
|
||||
smc.vmdata.mission_data.mon_max = Math.max(1, Math.floor(this.maxMonsterCount))
|
||||
this.currentPhase = MissionPhase.None;
|
||||
this.currentWave = 1;
|
||||
this.isBossWave = false;
|
||||
this.rewards=[]
|
||||
this.rewards = []
|
||||
this.revive_times = 1;
|
||||
this.lastTimeStr = "";
|
||||
this.lastTimeSecond = -1;
|
||||
@@ -714,9 +718,9 @@ export class MissionComp extends CCComp {
|
||||
this.heapTrendBaseMB = -1;
|
||||
this.monsterCountSyncTimer = 0;
|
||||
this.lastPrepareCoinWave = 0;
|
||||
|
||||
|
||||
spawningEngine.reset();
|
||||
|
||||
|
||||
// 重置所有的战局得分数据,防止上一局的数据污染
|
||||
smc.resetScores();
|
||||
|
||||
@@ -740,9 +744,9 @@ export class MissionComp extends CCComp {
|
||||
private onNewWave(event: string, data: any) {
|
||||
const wave = Number(data?.wave ?? 0);
|
||||
if (wave <= 0) return;
|
||||
|
||||
|
||||
this.isBossWave = !!data?.bossWave;
|
||||
|
||||
|
||||
if (wave > 1) {
|
||||
// 在新一波到来时,先进入 BattleEnd,触发上一波的战斗结束技能 (fend),2秒后自动进入下一波的准备阶段
|
||||
this.changePhase(MissionPhase.BattleEnd);
|
||||
@@ -773,7 +777,7 @@ export class MissionComp extends CCComp {
|
||||
if (upgradeIndex !== -1) {
|
||||
// 根据配置的索引,计算目标等级(初始等级 + index + 1)
|
||||
// 例如 index=0,对应等级为2;index=1,对应等级为3
|
||||
const targetLv = upgradeIndex + 2;
|
||||
const targetLv = upgradeIndex + 2;
|
||||
oops.message.dispatchEvent(GameEvent.CardPoolUpgrade, { wave, targetLv });
|
||||
mLogger.log(this.debugMode, 'MissionComp', "card pool upgrade event pushed", { wave, targetLv });
|
||||
}
|
||||
@@ -836,7 +840,7 @@ export class MissionComp extends CCComp {
|
||||
}
|
||||
});
|
||||
this.handleHeroWipe(heroCount);
|
||||
|
||||
|
||||
// 怪物全灭检测:如果战斗阶段场上没有任何活着的怪物,且待刷新的怪物队列也为空,直接结束战斗进入下一波的准备阶段
|
||||
const pendingCount = smc.vmdata.mission_data.pending_mon_num || 0;
|
||||
if (monsterCount === 0 && pendingCount === 0 && smc.mission.play && !smc.mission.pause && this.currentPhase === MissionPhase.Battle) {
|
||||
@@ -844,7 +848,7 @@ export class MissionComp extends CCComp {
|
||||
// 如果能获取当前已部署英雄数最好,这里简化处理,大于 4 个就算高存活
|
||||
heroesAliveRatio = Math.min(1.0, heroCount / 4.0);
|
||||
spawningEngine.updateAdaptive(heroesAliveRatio, this.clearTime);
|
||||
|
||||
|
||||
if (this.currentWave >= 15) {
|
||||
// 15 波通关
|
||||
this.open_Victory(null, false);
|
||||
@@ -853,7 +857,7 @@ export class MissionComp extends CCComp {
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
smc.vmdata.mission_data.mon_num = monsterCount;
|
||||
const { max, resume } = this.getMonsterThresholds();
|
||||
smc.vmdata.mission_data.mon_max = max;
|
||||
@@ -938,7 +942,7 @@ export class MissionComp extends CCComp {
|
||||
skillNodes: skillRoot?.children.length || 0
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// ======================== 性能监控面板 ========================
|
||||
|
||||
/** 性能监控相关代码 */
|
||||
|
||||
Reference in New Issue
Block a user