添加 缓冲倒计时

This commit is contained in:
2025-07-29 00:04:57 +08:00
parent 98039f36ca
commit 9f820436fc
5 changed files with 2040 additions and 634 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -48,7 +48,7 @@ export enum GameEvent {
FuncSelect = "FuncSelect", FuncSelect = "FuncSelect",
TalentSelect = "TalentSelect", TalentSelect = "TalentSelect",
RefreshCard = "RefreshCard", RefreshCard = "RefreshCard",
WaveUpdate = "WaveUpdate", NewWave = "NewWave",
ChangeATK = "ChangeATK", ChangeATK = "ChangeATK",
ChangeATK_EQUIP_SPECIAL_ATTR = "ChangeATK_EQUIP_SPECIAL_ATTR", ChangeATK_EQUIP_SPECIAL_ATTR = "ChangeATK_EQUIP_SPECIAL_ATTR",
UpdateVMData = "UpdateVMData", UpdateVMData = "UpdateVMData",

View File

@@ -68,6 +68,8 @@ export enum FightSet {
ATK_TO_POWER=1,//攻击涨能量 ATK_TO_POWER=1,//攻击涨能量
CRIT_TO_POWER=1,//暴击涨能量 CRIT_TO_POWER=1,//暴击涨能量
DODGE_TO_POWER=1,//闪避涨能量 DODGE_TO_POWER=1,//闪避涨能量
ONE_WAVE_TIME=30,//单波时间
DOWN_TIME=5,//倒计时时间
// ATK_TO_ATK_RATIO=0.1, // ATK_TO_ATK_RATIO=0.1,
// ATK_TO_HP_RATIO=0.2, // ATK_TO_HP_RATIO=0.2,
// ATK_TO_SHIELD_RATIO=2, // ATK_TO_SHIELD_RATIO=2,
@@ -95,6 +97,8 @@ export const MissionData = {
buff_refrsh_time:0,//额外刷新时间 buff_refrsh_time:0,//额外刷新时间
buff_refresh_gold:0,//额外发现所需的金币 buff_refresh_gold:0,//额外发现所需的金币
current_wave:0, current_wave:0,
mon_num:0,//怪物数量
wave_time_num:0,//波次时间
in_fight:false, in_fight:false,
fight_time:0,//战斗时间 fight_time:0,//战斗时间
equip_stone:0,//装备石 equip_stone:0,//装备石

View File

@@ -9,6 +9,7 @@ import { GameEvent } from "../common/config/GameEvent";
import { HeroViewComp } from "../hero/HeroViewComp"; import { HeroViewComp } from "../hero/HeroViewComp";
import { Hero } from "../hero/Hero"; import { Hero } from "../hero/Hero";
import { defaultEnhancements, EnhancementOptions } from "../common/config/LevelUp"; import { defaultEnhancements, EnhancementOptions } from "../common/config/LevelUp";
import { MonModelComp } from "../hero/MonModelComp";
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@@ -22,7 +23,6 @@ export class MissionComp extends CCComp {
reward:number = 0; reward:number = 0;
reward_num:number = 0; reward_num:number = 0;
GlodAddTimer:Timer = new Timer(1); GlodAddTimer:Timer = new Timer(1);
waveTimer:Timer = new Timer(10);
normal_max_wave:number = 10; normal_max_wave:number = 10;
is_fight:boolean = false; is_fight:boolean = false;
enhancements:any=[0,0,0,0,0] enhancements:any=[0,0,0,0,0]
@@ -30,13 +30,19 @@ export class MissionComp extends CCComp {
is_show_time:boolean = false; is_show_time:boolean = false;
time_num:number = 0; time_num:number = 0;
time_cd:Timer=new Timer(1); time_cd:Timer=new Timer(1);
next_func?:Function; next_func?:Function;
wave_time_num:number = 0;
wave_time_cd:Timer=new Timer(1);
is_in_wave:boolean = false;
onLoad(){ onLoad(){
this.on(GameEvent.MissionStart,this.mission_start,this) this.on(GameEvent.MissionStart,this.mission_start,this)
this.on(GameEvent.MasterCalled,this.ready_to_fight,this)
// this.on(GameEvent.CardsClose,this.after_used_skill_card,this)
this.on(GameEvent.MonDead,this.do_mon_dead,this)
this.on(GameEvent.FightEnd,this.fight_end,this) this.on(GameEvent.FightEnd,this.fight_end,this)
this.on(GameEvent.MissionEnd,this.mission_end,this) this.on(GameEvent.MissionEnd,this.mission_end,this)
// this.on(GameEvent.CardsClose,this.after_used_skill_card,this)
this.on(GameEvent.WaveUpdate,this.on_mon_wave_update,this)
// this.on(GameEvent.CanUpdateLv,this.show_uplv_button,this) // this.on(GameEvent.CanUpdateLv,this.show_uplv_button,this)
// this.on(GameEvent.UseEnhancement,this.hide_uplv_button,this) // this.on(GameEvent.UseEnhancement,this.hide_uplv_button,this)
@@ -57,13 +63,55 @@ export class MissionComp extends CCComp {
this.run_time() this.run_time()
} }
} }
if(this.is_in_wave){
if(this.wave_time_cd.update(dt)){
smc.vmdata.mission_data.wave_time_num--
if(smc.vmdata.mission_data.wave_time_num<=0){
this.hide_wave_time()
this.show_time(this.do_next_wave.bind(this))
}
}
}
}
//奖励发放
do_reward(){
// 奖励发放
}
do_mon_dead(){
smc.vmdata.mission_data.mon_num--
if(smc.vmdata.mission_data.mon_num<=0) {
this.show_time(this.do_next_wave.bind(this))
}
}
do_next_wave(){ //怪物死亡后,重置时间
smc.vmdata.mission_data.current_wave++
oops.message.dispatchEvent(GameEvent.NewWave)
this.show_wave_time()
}
show_wave_time(){
smc.vmdata.mission_data.wave_time_num=FightSet.ONE_WAVE_TIME
this.is_in_wave=true
}
hide_wave_time(){
this.is_in_wave=false
} }
show_time(onHide?:Function){ show_time(onHide?:Function){
this.time_num=FightSet.DOWN_TIME
this.node.getChildByName("time").active=true this.node.getChildByName("time").active=true
this.is_show_time=true this.is_show_time=true
this.next_func=onHide this.next_func=onHide
} }
hide_time(){ hide_time(){
if(this.next_func){ if(this.next_func){
this.next_func() this.next_func()
@@ -72,11 +120,12 @@ export class MissionComp extends CCComp {
this.is_show_time=false this.is_show_time=false
this.next_func=undefined this.next_func=undefined
} }
run_time(){ run_time(){
this.node.getChildByName("time").setScale(0,0,0)
tween(this.node.getChildByName("time")) tween(this.node.getChildByName("time"))
.to(0.2, {scale:v3(1.5,1.5,1.5)}, {easing:"backOut"}) .to(0.2, {scale:v3(1,1,1)}, {easing:"backOut"})
.to(0.2, {scale:v3(1,1,1)}, {easing:"backIn"}) .to(0.2, {scale:v3(0,0,0)}, {easing:"backIn"})
.to(0.2, {scale:v3(1.5,1.5,1.5)}, {easing:"backOut"})
.start() .start()
this.time_num-- this.time_num--
this.node.getChildByName("time").getChildByName("time").getComponent(Label).string=this.time_num.toString() this.node.getChildByName("time").getChildByName("time").getComponent(Label).string=this.time_num.toString()
@@ -85,11 +134,6 @@ export class MissionComp extends CCComp {
} }
} }
private on_mon_wave_update(){
smc.vmdata.mission_data.current_wave++
let wave=smc.vmdata.mission_data.current_wave
}
async mission_start(){ async mission_start(){
oops.message.dispatchEvent(GameEvent.FightReady) oops.message.dispatchEvent(GameEvent.FightReady)
@@ -102,13 +146,16 @@ export class MissionComp extends CCComp {
loading.active=false loading.active=false
},0.5) },0.5)
this.to_ready() this.to_ready()
this.time_num=5
this.show_time(this.to_fight.bind(this))
} }
to_ready(){ to_ready(){
oops.message.dispatchEvent(GameEvent.HeroSelect,{is_master:true}) oops.message.dispatchEvent(GameEvent.HeroSelect,{is_master:true})
} }
ready_to_fight(){
this.time_num=5
this.show_time(this.to_fight.bind(this))
}
// show_uplv_button(){ // show_uplv_button(){
// this.update_count++ // this.update_count++
// this.node.getChildByName("uplv").active=true // this.node.getChildByName("uplv").active=true
@@ -124,11 +171,12 @@ export class MissionComp extends CCComp {
to_call_friend(){ to_call_friend(){
oops.message.dispatchEvent(GameEvent.HeroSelect,{is_master:false}) oops.message.dispatchEvent(GameEvent.HeroSelect,{is_master:false})
} }
to_fight(){ to_fight(){
console.log("[MissionComp] to_fight") console.log("[MissionComp] 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()
} }
@@ -160,6 +208,9 @@ 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.hide_time()
this.hide_wave_time()
smc.vmdata.mission_data.wave_time_num=FightSet.ONE_WAVE_TIME
console.log("局内数据初始化",smc.enhancements,defaultEnhancements()) console.log("局内数据初始化",smc.enhancements,defaultEnhancements())
} }

View File

@@ -18,9 +18,7 @@ const { ccclass, property } = _decorator;
/** 视图层对象 */ /** 视图层对象 */
@ccclass('MissionMonCompComp') @ccclass('MissionMonCompComp')
@ecs.register('MissionMonComp', false) @ecs.register('MissionMonComp', false)
export class MissionMonCompComp extends CCComp { export class MissionMonCompComp extends CCComp { // 添加刷怪队列 - 扩展支持词条
timer:Timer=new Timer(1)
// 添加刷怪队列 - 扩展支持词条
private monsterQueue: Array<{ private monsterQueue: Array<{
uuid: number, uuid: number,
position: number, position: number,
@@ -34,43 +32,20 @@ export class MissionMonCompComp extends CCComp {
private isSpawning: boolean = false;// 是否正在生成怪物 private isSpawning: boolean = false;// 是否正在生成怪物
private spawnInterval: number = 0.1; // 每个怪物生成间隔时间 private spawnInterval: number = 0.1; // 每个怪物生成间隔时间
private spawnTimer: number = 0; // 生成计时器 private spawnTimer: number = 0; // 生成计时器
private is_fight:boolean = false;
onLoad(){ onLoad(){
this.on(GameEvent.FightStart,this.to_fight,this) this.on(GameEvent.NewWave,this.do_mon_wave,this)
this.on(GameEvent.MonDead,this.check_mon,this)
} }
/** 视图层逻辑代码分离演示 */ /** 视图层逻辑代码分离演示 */
start() { start() {
// var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象 // var entity = this.ent as ecs.Entity; // ecs.Entity 可转为当前模块的具体实体对象
// this.on(ModuleEvent.Cmd, this.onHandler, this); // this.on(ModuleEvent.Cmd, this.onHandler, this);
// this.test_call()
} }
check_mon(){
let mon=ecs.query(ecs.allOf(MonModelComp))
console.log("[MissionMonComp]:check_mon",mon)
if(mon.length==1) {
// do 倒计时
this.do_mon_wave()
}
}
//奖励发放
do_reward(){
let wave=smc.vmdata.mission_data.current_wave
// 奖励发放
}
protected update(dt: number): void { protected update(dt: number): void {
if(!smc.mission.play||smc.mission.pause) return if(!smc.mission.play||smc.mission.pause) return
if(this.is_fight) {
// if(this.timer.update(dt)){
// this.do_mon_wave()
// }
}
// 处理刷怪队列 // 处理刷怪队列
if (this.monsterQueue.length > 0 && !this.isSpawning) { if (this.monsterQueue.length > 0 && !this.isSpawning) {
this.spawnTimer += dt; this.spawnTimer += dt;
@@ -81,18 +56,8 @@ export class MissionMonCompComp extends CCComp {
} }
} }
to_fight(){
console.log("[MissionMonComp]:to_fight")
this.is_fight=true
this.do_mon_wave()
this.timer=new Timer(FightSet.MON_WAVE_TIME)
}
test_call(){
this.addToSpawnQueue(5202, 0, true, 1);
}
do_mon_wave(){ do_mon_wave(){
oops.message.dispatchEvent(GameEvent.WaveUpdate)
console.log("[MissionMonComp]:怪物登场,当前波次 :",smc.vmdata.mission_data.current_wave) console.log("[MissionMonComp]:怪物登场,当前波次 :",smc.vmdata.mission_data.current_wave)
const currentWave = smc.vmdata.mission_data.current_wave; const currentWave = smc.vmdata.mission_data.current_wave;
// 使用肉鸽模式配置 // 使用肉鸽模式配置
@@ -107,7 +72,7 @@ export class MissionMonCompComp extends CCComp {
const { monsters, waveType } = rogueWaveConfig; const { monsters, waveType } = rogueWaveConfig;
const currentWave = smc.vmdata.mission_data.current_wave; const currentWave = smc.vmdata.mission_data.current_wave;
const monsterLevel = RogueConfig.getMonsterLevel(currentWave); const monsterLevel = RogueConfig.getMonsterLevel(currentWave);
smc.vmdata.mission_data.mon_num=monsters.reduce((total: number, group: any) => total + group.count, 0);
// 固定9波模式所有波次都是战斗波次 // 固定9波模式所有波次都是战斗波次
console.log(`[MissionMonComp]:第${currentWave}波 - ${waveType}战斗波次`); console.log(`[MissionMonComp]:第${currentWave}波 - ${waveType}战斗波次`);