再来一局 完善, todo : mission 添加自定义的 定时运行队列 方便销毁

This commit is contained in:
2025-08-06 10:56:50 +08:00
parent 228014bc8f
commit d0f79c9207
6 changed files with 4633 additions and 3979 deletions

View File

@@ -2223,7 +2223,7 @@
"__id__": 95 "__id__": 95
} }
], ],
"_active": true, "_active": false,
"_components": [ "_components": [
{ {
"__id__": 101 "__id__": 101

File diff suppressed because it is too large Load Diff

View File

@@ -387,9 +387,9 @@ export class HeroViewComp extends CCComp {
add_ap(ap: number,is_num:boolean=true){ add_ap(ap: number,is_num:boolean=true){
// console.log("[HeroViewComp]:add_ap add:",ap,this.ap) // console.log("[HeroViewComp]:add_ap add:",ap,this.ap)
if(is_num){ if(is_num){
this.ap += Math.floor(ap); this.ap_base += Math.floor(ap);
}else{ }else{
this.ap += Math.floor(ap); this.ap_base += Math.floor(ap/100*this.ap_base);
} }
this.count_atrr(BuffAttr.ATK) this.count_atrr(BuffAttr.ATK)
// this.BUFFCOMP.tooltip(TooltipTypes.apup,diff.toFixed(0)); // this.BUFFCOMP.tooltip(TooltipTypes.apup,diff.toFixed(0));
@@ -398,9 +398,9 @@ export class HeroViewComp extends CCComp {
de_ap(ap: number,is_num:boolean=true){ de_ap(ap: number,is_num:boolean=true){
//console.log("[HeroViewComp]:de_ap de:",ap,this.ap) //console.log("[HeroViewComp]:de_ap de:",ap,this.ap)
if(is_num){ if(is_num){
this.ap -= Math.floor(ap); this.ap_base -= Math.floor(ap);
}else{ }else{
this.ap -= Math.floor(ap/100*this.ap); this.ap_base -= Math.floor(ap/100*this.ap_base);
} }
this.count_atrr(BuffAttr.ATK) this.count_atrr(BuffAttr.ATK)
} }

View File

@@ -33,13 +33,18 @@ export class HeroUiComp extends CCComp {
onLoad() { onLoad() {
this.on(GameEvent.FightReady,this.fight_ready,this) this.on(GameEvent.FightReady,this.fight_ready,this)
this.on(GameEvent.UseHeroCard,this.get_hero,this) this.on(GameEvent.UseHeroCard,this.get_hero,this)
this.on(GameEvent.FightEnd,this.fight_end,this)
// this.node.getChildByName("icon").getChildByName("cd").active=false // this.node.getChildByName("icon").getChildByName("cd").active=false
} }
start(){ start(){
this.fight_ready() this.fight_ready()
} }
fight_end(){
this.heroes=[]
this.clearAllHeroIcons()
}
fight_ready(){ fight_ready(){
console.log("[HeroUiComp]: fight_ready",this.node) console.log("[HeroUiComp]: fight_ready",this.node)
this.heroes = [] this.heroes = []
@@ -201,6 +206,30 @@ export class HeroUiComp extends CCComp {
.start() .start()
} }
/**
* 清空英雄图标
* @param heroIndex 英雄索引
*/
private clearHeroIcon(heroIndex: number) {
const heroNodeName = this.HERO_NODE_NAMES[heroIndex]
const heroNode = this.node.getChildByName(heroNodeName)
if (!heroNode) return
const iconNode = heroNode.getChildByName("icon")
if (iconNode) {
iconNode.active = false
}
}
/**
* 清空所有英雄图标
*/
public clearAllHeroIcons() {
for (let i = 0; i < this.MAX_HEROES; i++) {
this.clearHeroIcon(i)
}
}

View File

@@ -3,7 +3,7 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp";
import { smc } from "../common/SingletonModuleComp"; import { smc } from "../common/SingletonModuleComp";
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops"; import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
import { FightSet, MissionData, VmInfo} from "../common/config/Mission"; import { FightSet, HeroUI, MissionData, VmInfo} from "../common/config/Mission";
import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer"; import { Timer } from "../../../../extensions/oops-plugin-framework/assets/core/common/timer/Timer";
import { GameEvent } from "../common/config/GameEvent"; import { GameEvent } from "../common/config/GameEvent";
import { HeroViewComp } from "../hero/HeroViewComp"; import { HeroViewComp } from "../hero/HeroViewComp";
@@ -233,6 +233,12 @@ export class MissionComp extends CCComp {
async mission_start(){ async mission_start(){
console.log("[MissionComp] ** 1 ** mission_start")
// 撤销所有正在运行的scheduleOnce函数
this.unscheduleAllCallbacks()
this.node.getChildByName("ending").getComponent(Animation).play("startFight")
oops.message.dispatchEvent(GameEvent.FightReady) oops.message.dispatchEvent(GameEvent.FightReady)
this.node.active=true this.node.active=true
this.data_init() this.data_init()
@@ -240,15 +246,18 @@ export class MissionComp extends CCComp {
loading.active=true loading.active=true
this.scheduleOnce(()=>{ this.scheduleOnce(()=>{
loading.active=false loading.active=false
this.node.getChildByName("ending").active=false
},1) },1)
this.to_ready() this.to_ready()
} }
to_ready(){ to_ready(){
console.log("[MissionComp] ** 2 ** to_ready")
oops.message.dispatchEvent(GameEvent.HeroSelect) oops.message.dispatchEvent(GameEvent.HeroSelect)
} }
ready_to_fight(){ ready_to_fight(){
console.log("[MissionComp] ** 3 ** ready_to_fight")
this.time_num=5 this.time_num=5
this.show_time(this.to_fight.bind(this)) this.show_time(this.to_fight.bind(this))
} }
@@ -269,7 +278,7 @@ export class MissionComp extends CCComp {
} }
to_fight(){ to_fight(){
console.log("[MissionComp] to_fight") console.log("[MissionComp] ** 4 ** to_fight")
smc.vmdata.mission_data.in_fight=true smc.vmdata.mission_data.in_fight=true
oops.message.dispatchEvent(GameEvent.FightStart) //MissionMonComp 监听刷怪 oops.message.dispatchEvent(GameEvent.FightStart) //MissionMonComp 监听刷怪
this.do_next_wave() this.do_next_wave()
@@ -283,6 +292,8 @@ export class MissionComp extends CCComp {
fight_end(){ fight_end(){
console.log("任务结束") console.log("任务结束")
this.node.getChildByName("ending").active=true
this.node.getChildByName("ending").getComponent(Animation).play("endFight")
// 延迟0.5秒后执行任务结束逻辑 // 延迟0.5秒后执行任务结束逻辑
this.scheduleOnce(() => { this.scheduleOnce(() => {
smc.mission.play=false smc.mission.play=false
@@ -292,6 +303,7 @@ export class MissionComp extends CCComp {
} }
mission_end(){ mission_end(){
this.node.getChildByName("ending").active=false
this.node.active=false this.node.active=false
} }
@@ -304,6 +316,11 @@ export class MissionComp extends CCComp {
this.update_count=0 this.update_count=0
this.GlodAddTimer=new Timer(smc.vmdata.mission_data.refrsh_time) this.GlodAddTimer=new Timer(smc.vmdata.mission_data.refrsh_time)
smc.enhancements=defaultEnhancements() smc.enhancements=defaultEnhancements()
this.heros={
0:{uuid:0,count:0},
1:{uuid:0,count:0},
2:{uuid:0,count:0},
}
this.hide_time() this.hide_time()
this.hide_wave_time() this.hide_wave_time()
this.tals={ this.tals={
@@ -374,6 +391,9 @@ export class MissionComp extends CCComp {
} }
private cleanComponents() { private cleanComponents() {
smc.vmdata.hero1=JSON.parse(JSON.stringify(HeroUI))
smc.vmdata.hero2=JSON.parse(JSON.stringify(HeroUI))
smc.vmdata.hero3=JSON.parse(JSON.stringify(HeroUI))
ecs.query(ecs.allOf(HeroViewComp)).forEach(entity => {entity.remove(HeroViewComp);entity.destroy()}); ecs.query(ecs.allOf(HeroViewComp)).forEach(entity => {entity.remove(HeroViewComp);entity.destroy()});
} }

View File

@@ -34,6 +34,10 @@ export class VictoryComp extends CCComp {
this.hide() this.hide()
oops.message.dispatchEvent(GameEvent.MissionEnd) oops.message.dispatchEvent(GameEvent.MissionEnd)
} }
restart(){
this.hide()
oops.message.dispatchEvent(GameEvent.MissionStart)
}
open(){ open(){
this.show() this.show()
} }