feat(关卡系统): 添加关卡解锁和免广告功能

- 在MissionComp和SCDSystem中添加stop_mon_action检查逻辑
- 修改SingletonModuleComp数据结构,添加noStop和unlockCoin字段
- 为MissionCardComp添加金币解锁和免广告功能
- 调整ubtns.plist的边框值
This commit is contained in:
walkpan
2026-01-06 19:47:11 +08:00
parent bb28492550
commit 0febe02ecc
6 changed files with 4322 additions and 986 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -2968,10 +2968,10 @@
"height": 63, "height": 63,
"rawWidth": 229, "rawWidth": 229,
"rawHeight": 63, "rawHeight": 63,
"borderTop": 0, "borderTop": 20,
"borderBottom": 0, "borderBottom": 31,
"borderLeft": 0, "borderLeft": 30,
"borderRight": 0, "borderRight": 30,
"packable": true, "packable": true,
"pixelsToUnit": 100, "pixelsToUnit": 100,
"pivotX": 0.5, "pivotX": 0.5,

View File

@@ -44,8 +44,6 @@ export class SingletonModuleComp extends ecs.Comp {
in_fight:false, in_fight:false,
stop_mon_action:false, stop_mon_action:false,
}; };
guides:any=[0,0,0,0,0]
current_guide:number=0
data:any={ data:any={
score:0, score:0,
mission:1, mission:1,
@@ -53,8 +51,10 @@ export class SingletonModuleComp extends ecs.Comp {
meat:0, meat:0,
exp:0, exp:0,
task:0, task:0,
coin:0, noStop:false,
} }
guides:any=[0,0,0,0,0]
current_guide:number=0
fight_hero: number = 5001; // 单个出战英雄 fight_hero: number = 5001; // 单个出战英雄
heros:any= [5001,5002] heros:any= [5001,5002]
monsters:any = []; monsters:any = [];
@@ -71,6 +71,7 @@ export class SingletonModuleComp extends ecs.Comp {
max_mission:4,//最大关卡 max_mission:4,//最大关卡
coin:0, coin:0,
time:15*60,//游戏时间 time:15*60,//游戏时间
unlockCoin: 20,
}, },
scores: { scores: {
score: 0, // 基础得分 score: 0, // 基础得分

View File

@@ -31,6 +31,7 @@ export class SkillCDSystem extends ecs.ComblockSystem implements ecs.ISystemUpda
if (!skills) return; if (!skills) return;
const attrsCom = e.get(HeroAttrsComp); const attrsCom = e.get(HeroAttrsComp);
if (!attrsCom) return; if (!attrsCom) return;
if(smc.mission.stop_mon_action) return;
if (attrsCom.isStun() || attrsCom.isFrost()) { // 眩晕和冰冻状态不更新CD if (attrsCom.isStun() || attrsCom.isFrost()) { // 眩晕和冰冻状态不更新CD
return; return;
} }

View File

@@ -31,6 +31,10 @@ export class MissionCardComp extends CCComp {
@property(Node) @property(Node)
Lock: Node = null! Lock: Node = null!
@property(Node)
unLock: Node = null!
@property(Node)
noStop: Node = null!
card1_data:any = null! card1_data:any = null!
card2_data:any = null! card2_data:any = null!
@@ -42,6 +46,8 @@ export class MissionCardComp extends CCComp {
// 是否处于锁定状态 // 是否处于锁定状态
private isLocked: boolean = true; private isLocked: boolean = true;
// 是否永久解锁(本局)
private isAdUnlocked: boolean = false;
onLoad() { onLoad() {
if (this.btnClose) { if (this.btnClose) {
@@ -78,7 +84,9 @@ export class MissionCardComp extends CCComp {
/** 游戏开始初始化 */ /** 游戏开始初始化 */
onMissionStart() { onMissionStart() {
this.isLocked = true; this.isLocked = true;
this.isAdUnlocked = false;
if (this.Lock) this.Lock.active = false; // 初始不显示,等待 showCardType if (this.Lock) this.Lock.active = false; // 初始不显示,等待 showCardType
if(this.unLock) this.unLock.active=false
this.eventQueue = []; this.eventQueue = [];
} }
@@ -164,11 +172,23 @@ export class MissionCardComp extends CCComp {
this.Lock.active = this.isLocked; this.Lock.active = this.isLocked;
} }
// 显示 noStop 节点
if (this.noStop) {
this.noStop.active = true;
this.checkNoStop()
}
this.resetCardStates(); this.resetCardStates();
this.refCards(); this.refCards();
this.playShowAnimation(); this.playShowAnimation();
} }
checkNoStop(){
this.noStop.getChildByName("no").active=!smc.data.noStop
}
switchNoStop(){
smc.data.noStop=!smc.data.noStop
this.checkNoStop()
}
private playShowAnimation() { private playShowAnimation() {
const cards = [this.card1, this.card2, this.card3, this.card4]; const cards = [this.card1, this.card2, this.card3, this.card4];
cards.forEach((card, index) => { cards.forEach((card, index) => {
@@ -314,12 +334,49 @@ export class MissionCardComp extends CCComp {
// 模拟广告播放成功回调 // 模拟广告播放成功回调
this.isLocked = false; this.isLocked = false;
this.isAdUnlocked = true;
if (this.Lock) { if (this.Lock) {
this.Lock.active = false; this.Lock.active = false;
oops.gui.toast("解锁成功"); oops.gui.toast("解锁成功");
} }
} }
coinCloseLock(){
let cost = smc.vmdata.mission_data.unlockCoin;
if (smc.vmdata.gold >= cost) {
// 扣除金币
if (smc.updateGold(-cost)) {
this.isLocked = false;
if (this.Lock) {
this.Lock.active = false;
}
oops.gui.toast("解锁成功");
this.closeUnLock();
} else {
oops.gui.toast("交易失败");
}
} else {
oops.gui.toast("金币不足");
}
}
showUnLock(){
if (this.unLock) {
this.unLock.active = true;
this.unLock.setScale(Vec3.ZERO);
tween(this.unLock)
.to(0.2, { scale: new Vec3(1, 1, 1) }, { easing: 'backOut' })
.start();
}
}
closeUnLock(){
if (this.unLock && this.unLock.active) {
tween(this.unLock)
.to(0.2, { scale: Vec3.ZERO }, { easing: 'backIn' })
.call(() => {
this.unLock.active = false;
})
.start();
}
}
/** 放弃选择 */ /** 放弃选择 */
onGiveUp() { onGiveUp() {
if (this.hasSelected) return; if (this.hasSelected) return;
@@ -361,6 +418,16 @@ export class MissionCardComp extends CCComp {
this.Lock.active = false; this.Lock.active = false;
} }
// 关闭时隐藏 noStop 节点
if (this.noStop) {
this.noStop.active = false;
}
// 恢复锁定状态(如果没有永久解锁)
if (!this.isAdUnlocked) {
this.isLocked = true;
}
this.checkQueue(); this.checkQueue();
} }

View File

@@ -46,6 +46,7 @@ export class MissionComp extends CCComp {
if(!smc.mission.play) return if(!smc.mission.play) return
if(smc.mission.pause) return if(smc.mission.pause) return
if(smc.mission.in_fight){ if(smc.mission.in_fight){
if(smc.mission.stop_mon_action) return
smc.vmdata.mission_data.fight_time+=dt smc.vmdata.mission_data.fight_time+=dt
smc.vmdata.mission_data.time-=dt smc.vmdata.mission_data.time-=dt
} }