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:
pan
2026-06-03 14:39:31 +08:00
parent 15c771c58c
commit 55c277016d
10 changed files with 6228 additions and 1565 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.50",
"importer": "prefab",
"imported": true,
"uuid": "053b0528-ec69-4ff8-85d7-99f128440121",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "MSkillBox"
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,753 +0,0 @@
[
{
"__type__": "cc.Prefab",
"_name": "notify",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false
},
{
"__type__": "cc.Node",
"_name": "notify",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 16
}
],
"_active": true,
"_components": [
{
"__id__": 26
},
{
"__id__": 28
},
{
"__id__": 30
},
{
"__id__": 32
}
],
"_prefab": {
"__id__": 34
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 365,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "popup",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 3
}
],
"_active": true,
"_components": [
{
"__id__": 9
},
{
"__id__": 11
},
{
"__id__": 13
}
],
"_prefab": {
"__id__": 15
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "UI_Social_Chat_02",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 4
},
{
"__id__": 6
}
],
"_prefab": {
"__id__": 8
},
"_lpos": {
"__type__": "cc.Vec3",
"x": -273.146,
"y": 66.71,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1.4,
"y": 1.4,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 3
},
"_enabled": true,
"__prefab": {
"__id__": 5
},
"_contentSize": {
"__type__": "cc.Size",
"width": 62,
"height": 52
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "8ef/z8CxNF5ovlgfNhCsbG"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 3
},
"_enabled": true,
"__prefab": {
"__id__": 7
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "6165ffc9-a838-4a33-b569-bdbaaab0e6b4@f67e4",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "378RDROUtFXLvCWnit6NVv"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "02OWPoHNdItqTNJdj8BAHB",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 10
},
"_contentSize": {
"__type__": "cc.Size",
"width": 680,
"height": 120
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "f1F5aeubtIh4vPjIyM/hBn"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 12
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": {
"__uuid__": "6165ffc9-a838-4a33-b569-bdbaaab0e6b4@091ff",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 1,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": {
"__uuid__": "6165ffc9-a838-4a33-b569-bdbaaab0e6b4",
"__expectedType__": "cc.SpriteAtlas"
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "11UvQ+qU5EA5SfGlH10ds3"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 14
},
"_alignFlags": 40,
"_target": null,
"_left": 10,
"_right": 10,
"_top": 0,
"_bottom": 0,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 428,
"_originalHeight": 0,
"_alignMode": 2,
"_lockFlags": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "fckVe8qU5PTaaYD87gPIGO"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "583RDgRFFMB4HdtU7jAQMx",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_name": "lab_content",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 17
},
{
"__id__": 19
},
{
"__id__": 21
},
{
"__id__": 23
}
],
"_prefab": {
"__id__": 25
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 15,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 16
},
"_enabled": true,
"__prefab": {
"__id__": 18
},
"_contentSize": {
"__type__": "cc.Size",
"width": 610,
"height": 70
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "99X9v0jUlJNZIh0XrXacci"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 16
},
"_enabled": true,
"__prefab": {
"__id__": 20
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_string": "信息",
"_horizontalAlign": 0,
"_verticalAlign": 1,
"_actualFontSize": 31,
"_fontSize": 30,
"_fontFamily": "Arial",
"_lineHeight": 40,
"_overflow": 2,
"_enableWrapText": true,
"_font": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_isItalic": false,
"_isBold": false,
"_isUnderline": false,
"_underlineHeight": 2,
"_cacheMode": 1,
"_enableOutline": true,
"_outlineColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_outlineWidth": 2,
"_enableShadow": false,
"_shadowColor": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_shadowOffset": {
"__type__": "cc.Vec2",
"x": 2,
"y": 2
},
"_shadowBlur": 2,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "16EtbFHdZJE6XKV6ws1G8+"
},
{
"__type__": "110c8vEd5NEPL/N9meGQnaX",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 16
},
"_enabled": true,
"__prefab": {
"__id__": 22
},
"_params": [],
"_dataID": "",
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "e0rVPeXXFGD6gzXeFEDtBF"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 16
},
"_enabled": true,
"__prefab": {
"__id__": 24
},
"_alignFlags": 45,
"_target": null,
"_left": 60,
"_right": 30,
"_top": 40,
"_bottom": 40,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 600,
"_originalHeight": 54.4,
"_alignMode": 2,
"_lockFlags": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "44Zwb3Q1FBg6aZ5M45F97+"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "ddsPDrtFpNTpbV/TewBYOo",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 27
},
"_contentSize": {
"__type__": "cc.Size",
"width": 700,
"height": 150
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "51DJ7yv09KnoNkqSbMfoJS"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 29
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_spriteFrame": null,
"_type": 1,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "23CbWnuJdPJYsCIbhHA6dc"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 31
},
"_alignFlags": 1,
"_target": null,
"_left": 0,
"_right": 0,
"_top": 200,
"_bottom": 0,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_alignMode": 2,
"_lockFlags": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "a2zw+Or45DsIUs9Ufp1kbN"
},
{
"__type__": "9a391lhQiBIG6lwpx34Nsvf",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 33
},
"lab_content": {
"__id__": 19
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "59S+ZqGoRPtZH794iLrIQn"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "4fj6jVgO1KzKob1u6D65Ik",
"instance": null,
"targetOverrides": null
}
]

View File

@@ -1 +0,0 @@
{"ver":"1.1.50","importer":"prefab","imported":true,"uuid":"4f87bee5-d246-4e72-827a-3747a9b5bfd7","files":[".json"],"subMetas":{},"userData":{"syncNodeName":"notify"}}

View File

@@ -1,9 +0,0 @@
{
"ver": "4.0.24",
"importer": "typescript",
"imported": true,
"uuid": "76a850b1-5eda-481f-a6e1-8e12e41db6c8",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -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 表示空槽 */
@@ -156,7 +159,7 @@ export class CardComp extends CCComp {
}
/** 外部初始化入口(由 MissionCardComp 调用) */
init(){
init() {
this.onMissionStart();
}
@@ -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);
}
@@ -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 || ""}`);
@@ -695,7 +698,7 @@ export class CardComp extends CCComp {
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

View File

@@ -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条数据 */

View File

@@ -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";
@@ -102,12 +102,12 @@ export class MissionComp extends CCComp {
/** 开始战斗按钮 */
@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 = "";
/** 上一次显示的秒数(避免重复计算) */
@@ -183,15 +183,15 @@ export class MissionComp extends CCComp {
// ======================== 生命周期 ========================
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)
}
}
@@ -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;
@@ -559,7 +563,7 @@ export class MissionComp extends CCComp {
* - 分发 FightStart 事件
* - 触发英雄战斗开始技能
*/
to_fight(){
to_fight() {
this.changePhase(MissionPhase.PrepareEnd);
}
@@ -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;