This commit is contained in:
2025-08-13 23:52:44 +08:00
parent 672e987c70
commit 66acc50c49
14 changed files with 21201 additions and 4322 deletions

View File

@@ -55,6 +55,9 @@ export class SingletonModuleComp extends ecs.Comp {
score:0,//分数
diamond:0,//钻石
mission:1,//关卡
chapter:1,//章节
level:1,//关卡等级
max_mission:10,//最大关卡
meat:0,//肉
mon_num:0,//怪物数量
hero_num:0,//英雄数量
@@ -407,6 +410,11 @@ export class SingletonModuleComp extends ecs.Comp {
this.vmdata.mission_data.diamond=this.getGameProperty("diamond", 0)
this.vmdata.mission_data.mission=this.getGameProperty("mission", 1)
this.vmdata.mission_data.score=this.getGameProperty("score", 0)
// 计算章节和关卡等级
const currentMission = this.getGameProperty("mission", 1)
this.vmdata.mission_data.chapter = Math.floor((currentMission - 1) / 10) + 1
this.vmdata.mission_data.level = ((currentMission - 1) % 10) + 1
}
initReward(){
this.vmdata.reward.gold=0
@@ -493,6 +501,22 @@ export class SingletonModuleComp extends ecs.Comp {
}
}
/**
* 增加关卡进度
* @param amount 增加的关卡数 (默认1)
* @param autoSave 是否自动保存 (默认true)
*/
addMission(amount: number = 1, autoSave: boolean = true) {
const currentMission = this.getGameProperty("mission", 1);
const newMission = currentMission + amount;
this.setGameProperty("mission", newMission, autoSave);
console.log(`[SMC]: 关卡进度增加: ${currentMission} -> ${newMission} (+${amount})`);
// 计算章节和关卡等级
this.vmdata.mission_data.chapter = Math.floor((newMission - 1) / 10) + 1
this.vmdata.mission_data.level = ((newMission - 1) % 10) + 1
return newMission;
}
/**
* 获取当前关卡进度
*/

View File

@@ -50,7 +50,7 @@ export class MissionComp extends CCComp {
smc.vmdata.mission_data.mon_num--
console.log("[MissionComp] do_mon_dead",smc.vmdata.mission_data.mon_num)
if(smc.vmdata.mission_data.mon_num<=0) {
smc.setGameProperty("mission",smc.data.mission+1,true)
smc.addMission()
oops.message.dispatchEvent(GameEvent.FightEnd,{victory:true})
}
}

View File

@@ -31,22 +31,51 @@ export class MissionHomeComp extends CCComp {
home_active(){
this.uodate_data()
this.node.active=true
this.btn_func("","fight")
oops.message.dispatchEvent(GameEvent.UpdateHero, {})
}
uodate_data(){
smc.syncData()
}
btn_func(e:string,data:any){
let btns=this.node.getChildByName("btns")
let btn=btns.getChildByName(data)
let act=btn.getChildByName("act")
console.log("[MissionHomeComp]:btn_func",e,data)
if(act.active){
act.active=false
}else{
act.active=true
let btns=this.node.getChildByName("btns")
let shop =btns.getChildByName("shop")
let heros =btns.getChildByName("heros")
let fight =btns.getChildByName("fight")
let skill =btns.getChildByName("skill")
let set =btns.getChildByName("set")
shop.getChildByName("act").active=false
heros.getChildByName("act").active=false
fight.getChildByName("act").active=false
skill.getChildByName("act").active=false
set.getChildByName("act").active=false
this.node.getChildByName("shop").active=false
// this.node.getChildByName("heros").active=false
// this.node.getChildByName("fight").active=false
// this.node.getChildByName("skill").active=false
// this.node.getChildByName("set").active=false
switch(data){
case "shop":
this.node.getChildByName("shop").active=true
shop.getChildByName("act").active=true
break
case "heros":
heros.getChildByName("act").active=true
break
case "fight":
fight.getChildByName("act").active=true
break
case "skill":
skill.getChildByName("act").active=true
break
case "set":
set.getChildByName("act").active=true
break
default:
fight.getChildByName("act").active=true
break
}
}