feat(关卡): 添加关卡锁定和解锁功能

- 在GameEvent枚举中添加新的战斗相关事件
- 实现MissionCardComp的初始化方法处理MissionStart事件
- 添加watchAdCloseLock方法处理广告解锁逻辑
- 修复prefab中Lock节点的引用问题
This commit is contained in:
panw
2026-01-05 11:15:04 +08:00
parent e96d64a454
commit 167297820e
3 changed files with 221 additions and 204 deletions

View File

@@ -6970,7 +6970,7 @@
} }
], ],
"_prefab": { "_prefab": {
"__id__": 413 "__id__": 468
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -7985,7 +7985,9 @@
"btnClose": { "btnClose": {
"__id__": 392 "__id__": 392
}, },
"Lock": null, "Lock": {
"__id__": 413
},
"_id": "" "_id": ""
}, },
{ {
@@ -8496,17 +8498,64 @@
"nestedPrefabInstanceRoots": null "nestedPrefabInstanceRoots": null
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.Node",
"root": { "_name": "lock",
"__id__": 1 "_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 414
}, },
"asset": { "_children": [
"__id__": 0 {
"__id__": 446
}
],
"_active": true,
"_components": [
{
"__id__": 458
},
{
"__id__": 460
},
{
"__id__": 462
},
{
"__id__": 464
}
],
"_prefab": {
"__id__": 467
}, },
"fileId": "b5rAY0KLtHqYGJo3KUTeD5", "_lpos": {
"instance": null, "__type__": "cc.Vec3",
"targetOverrides": null, "x": 255,
"nestedPrefabInstanceRoots": null "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": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
@@ -8527,23 +8576,23 @@
"__id__": 431 "__id__": 431
}, },
{ {
"__id__": 439 "__id__": 413
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 462 "__id__": 439
}, },
{ {
"__id__": 464 "__id__": 441
}, },
{ {
"__id__": 466 "__id__": 443
} }
], ],
"_prefab": { "_prefab": {
"__id__": 468 "__id__": 445
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -9019,89 +9068,144 @@
"nestedPrefabInstanceRoots": null "nestedPrefabInstanceRoots": null
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.UITransform",
"_name": "lock", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_parent": { "node": {
"__id__": 414 "__id__": 414
}, },
"_children": [ "_enabled": true,
{ "__prefab": {
"__id__": 440 "__id__": 440
}
],
"_active": true,
"_components": [
{
"__id__": 452
},
{
"__id__": 454
},
{
"__id__": 456
},
{
"__id__": 458
}
],
"_prefab": {
"__id__": 461
}, },
"_lpos": { "_contentSize": {
"__type__": "cc.Vec3", "__type__": "cc.Size",
"x": 255, "width": 680,
"y": 0, "height": 300
"z": 0
}, },
"_lrot": { "_anchorPoint": {
"__type__": "cc.Quat", "__type__": "cc.Vec2",
"x": 0, "x": 0.5,
"y": 0, "y": 0.5
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
}, },
"_id": "" "_id": ""
}, },
{
"__type__": "cc.CompPrefabInfo",
"fileId": "0d3ZUv1W9OT572dSjSsBhv"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 414
},
"_enabled": true,
"__prefab": {
"__id__": 442
},
"_alignFlags": 44,
"_target": null,
"_left": 20,
"_right": 20,
"_top": 0,
"_bottom": 400,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 100,
"_originalHeight": 0,
"_alignMode": 2,
"_lockFlags": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "1fnCJK+UBBdpVvkZRD6/Zp"
},
{
"__type__": "cc.Layout",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 414
},
"_enabled": true,
"__prefab": {
"__id__": 444
},
"_resizeMode": 0,
"_layoutType": 1,
"_cellSize": {
"__type__": "cc.Size",
"width": 40,
"height": 40
},
"_startAxis": 0,
"_paddingLeft": 5,
"_paddingRight": 0,
"_paddingTop": 0,
"_paddingBottom": 0,
"_spacingX": 10,
"_spacingY": 0,
"_verticalDirection": 1,
"_horizontalDirection": 0,
"_constraint": 0,
"_constraintNum": 2,
"_affectedByScale": false,
"_isAlign": false,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "9dMh05UfNOOZ/OfBhTNU1N"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "b36TS9OE5CBbKF+DuarDv5",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "unlock", "_name": "unlock",
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 439 "__id__": 413
}, },
"_children": [ "_children": [
{ {
"__id__": 441 "__id__": 447
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 447 "__id__": 453
}, },
{ {
"__id__": 449 "__id__": 455
} }
], ],
"_prefab": { "_prefab": {
"__id__": 451 "__id__": 457
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -9138,20 +9242,20 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"_parent": { "_parent": {
"__id__": 440 "__id__": 446
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 442 "__id__": 448
}, },
{ {
"__id__": 444 "__id__": 450
} }
], ],
"_prefab": { "_prefab": {
"__id__": 446 "__id__": 452
}, },
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@@ -9188,11 +9292,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 441 "__id__": 447
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 443 "__id__": 449
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -9216,11 +9320,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 441 "__id__": 447
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 445 "__id__": 451
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@@ -9297,11 +9401,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 440 "__id__": 446
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 448 "__id__": 454
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -9325,11 +9429,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 440 "__id__": 446
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 450 "__id__": 456
}, },
"_customMaterial": null, "_customMaterial": null,
"_srcBlendFactor": 2, "_srcBlendFactor": 2,
@@ -9386,11 +9490,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 439 "__id__": 413
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 453 "__id__": 459
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
@@ -9414,11 +9518,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 439 "__id__": 413
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 455 "__id__": 461
}, },
"_alignFlags": 36, "_alignFlags": 36,
"_target": null, "_target": null,
@@ -9450,11 +9554,11 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 439 "__id__": 413
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 457 "__id__": 463
}, },
"_id": "" "_id": ""
}, },
@@ -9468,15 +9572,15 @@
"_objFlags": 0, "_objFlags": 0,
"__editorExtras__": {}, "__editorExtras__": {},
"node": { "node": {
"__id__": 439 "__id__": 413
}, },
"_enabled": true, "_enabled": true,
"__prefab": { "__prefab": {
"__id__": 459 "__id__": 465
}, },
"clickEvents": [ "clickEvents": [
{ {
"__id__": 460 "__id__": 466
} }
], ],
"_interactable": true, "_interactable": true,
@@ -9529,7 +9633,7 @@
}, },
"component": "", "component": "",
"_componentId": "b3d6eSQ8ulPP79kPpPIytqU", "_componentId": "b3d6eSQ8ulPP79kPpPIytqU",
"handler": "", "handler": "watchAdCloseLock",
"customEventData": "" "customEventData": ""
}, },
{ {
@@ -9545,108 +9649,6 @@
"targetOverrides": null, "targetOverrides": null,
"nestedPrefabInstanceRoots": null "nestedPrefabInstanceRoots": null
}, },
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 414
},
"_enabled": true,
"__prefab": {
"__id__": 463
},
"_contentSize": {
"__type__": "cc.Size",
"width": 680,
"height": 300
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "0d3ZUv1W9OT572dSjSsBhv"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 414
},
"_enabled": true,
"__prefab": {
"__id__": 465
},
"_alignFlags": 44,
"_target": null,
"_left": 20,
"_right": 20,
"_top": 0,
"_bottom": 400,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 100,
"_originalHeight": 0,
"_alignMode": 2,
"_lockFlags": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "1fnCJK+UBBdpVvkZRD6/Zp"
},
{
"__type__": "cc.Layout",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 414
},
"_enabled": true,
"__prefab": {
"__id__": 467
},
"_resizeMode": 0,
"_layoutType": 1,
"_cellSize": {
"__type__": "cc.Size",
"width": 40,
"height": 40
},
"_startAxis": 0,
"_paddingLeft": 5,
"_paddingRight": 0,
"_paddingTop": 0,
"_paddingBottom": 0,
"_spacingX": 10,
"_spacingY": 0,
"_verticalDirection": 1,
"_horizontalDirection": 0,
"_constraint": 0,
"_constraintNum": 2,
"_affectedByScale": false,
"_isAlign": false,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "9dMh05UfNOOZ/OfBhTNU1N"
},
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
@@ -9655,7 +9657,7 @@
"asset": { "asset": {
"__id__": 0 "__id__": 0
}, },
"fileId": "b36TS9OE5CBbKF+DuarDv5", "fileId": "b5rAY0KLtHqYGJo3KUTeD5",
"instance": null, "instance": null,
"targetOverrides": null, "targetOverrides": null,
"nestedPrefabInstanceRoots": null "nestedPrefabInstanceRoots": null

View File

@@ -29,6 +29,12 @@ export enum GameEvent {
MissionWin = "MissionWin", MissionWin = "MissionWin",
MissionStart = "MissionStart", MissionStart = "MissionStart",
FightReady = "FightReady", FightReady = "FightReady",
FightStart = "FightStart",
FightPause = "FightPause",
FightResume = "FightResume",
FightEnd = "FightEnd",
MissionEnd = "MissionEnd",
MissionComplete = "MissionComplete",//战斗结算完成
HeroSkillSelect = "HeroSkillSelect", HeroSkillSelect = "HeroSkillSelect",
HeroSkillSelectEnd = "HeroSkillSelectEnd", HeroSkillSelectEnd = "HeroSkillSelectEnd",
HeroSelect = "HeroSelect", HeroSelect = "HeroSelect",
@@ -36,12 +42,6 @@ export enum GameEvent {
CanUpdateLv = "CanUpdateLv", CanUpdateLv = "CanUpdateLv",
UseEnhancement = "UseEnhancement", UseEnhancement = "UseEnhancement",
MasterCalled = "MasterCalled", MasterCalled = "MasterCalled",
FightStart = "FightStart",
FightPause = "FightPause",
FightResume = "FightResume",
FightEnd = "FightEnd",
MissionEnd = "MissionEnd",
MissionComplete = "MissionComplete",//战斗结算完成
CastHeroSkill = "CastHeroSkill", CastHeroSkill = "CastHeroSkill",
EquipAdd = "EquipAdd", EquipAdd = "EquipAdd",
EquipSelect = "EquipSelect", EquipSelect = "EquipSelect",

View File

@@ -49,6 +49,8 @@ export class MissionCardComp extends CCComp {
onLoad() { onLoad() {
oops.message.on(GameEvent.TalentSelect, this.onTalentSelect, this); oops.message.on(GameEvent.TalentSelect, this.onTalentSelect, this);
oops.message.on(GameEvent.ShopOpen, this.onShopOpen, this); oops.message.on(GameEvent.ShopOpen, this.onShopOpen, this);
oops.message.on(GameEvent.MissionStart, this.init, this);
} }
onDestroy() { onDestroy() {
@@ -56,11 +58,12 @@ export class MissionCardComp extends CCComp {
oops.message.off(GameEvent.ShopOpen, this.onShopOpen, this); oops.message.off(GameEvent.ShopOpen, this.onShopOpen, this);
this.ent.destroy(); this.ent.destroy();
} }
init(){
this.Lock.active=true
}
start() { start() {
// 初始隐藏或显示逻辑 // 初始隐藏或显示逻辑
this.node.active = false; this.node.active = false;
this.Lock.active = true;
this.resetCardStates(); this.resetCardStates();
} }
@@ -291,6 +294,18 @@ export class MissionCardComp extends CCComp {
} }
} }
/** 看广告关闭 Lock */
watchAdCloseLock() {
// TODO: 此处接入 IAA 广告 SDK
console.log("播放激励视频广告...");
// 模拟广告播放成功回调
if (this.Lock) {
this.Lock.active = false;
oops.gui.toast("解锁成功");
}
}
/** /**
* 关闭界面 * 关闭界面
*/ */