添加 缓冲倒计时
This commit is contained in:
@@ -9,6 +9,7 @@ import { GameEvent } from "../common/config/GameEvent";
|
||||
import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
import { Hero } from "../hero/Hero";
|
||||
import { defaultEnhancements, EnhancementOptions } from "../common/config/LevelUp";
|
||||
import { MonModelComp } from "../hero/MonModelComp";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
|
||||
@@ -22,7 +23,6 @@ export class MissionComp extends CCComp {
|
||||
reward:number = 0;
|
||||
reward_num:number = 0;
|
||||
GlodAddTimer:Timer = new Timer(1);
|
||||
waveTimer:Timer = new Timer(10);
|
||||
normal_max_wave:number = 10;
|
||||
is_fight:boolean = false;
|
||||
enhancements:any=[0,0,0,0,0]
|
||||
@@ -30,13 +30,19 @@ export class MissionComp extends CCComp {
|
||||
is_show_time:boolean = false;
|
||||
time_num:number = 0;
|
||||
time_cd:Timer=new Timer(1);
|
||||
|
||||
next_func?:Function;
|
||||
wave_time_num:number = 0;
|
||||
wave_time_cd:Timer=new Timer(1);
|
||||
is_in_wave:boolean = false;
|
||||
onLoad(){
|
||||
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.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.UseEnhancement,this.hide_uplv_button,this)
|
||||
|
||||
@@ -57,13 +63,55 @@ export class MissionComp extends CCComp {
|
||||
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){
|
||||
this.time_num=FightSet.DOWN_TIME
|
||||
this.node.getChildByName("time").active=true
|
||||
this.is_show_time=true
|
||||
this.next_func=onHide
|
||||
}
|
||||
|
||||
hide_time(){
|
||||
if(this.next_func){
|
||||
this.next_func()
|
||||
@@ -72,11 +120,12 @@ export class MissionComp extends CCComp {
|
||||
this.is_show_time=false
|
||||
this.next_func=undefined
|
||||
}
|
||||
|
||||
run_time(){
|
||||
this.node.getChildByName("time").setScale(0,0,0)
|
||||
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:"backIn"})
|
||||
.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(0,0,0)}, {easing:"backIn"})
|
||||
.start()
|
||||
this.time_num--
|
||||
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(){
|
||||
oops.message.dispatchEvent(GameEvent.FightReady)
|
||||
@@ -102,13 +146,16 @@ export class MissionComp extends CCComp {
|
||||
loading.active=false
|
||||
},0.5)
|
||||
this.to_ready()
|
||||
this.time_num=5
|
||||
this.show_time(this.to_fight.bind(this))
|
||||
|
||||
|
||||
}
|
||||
to_ready(){
|
||||
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(){
|
||||
// this.update_count++
|
||||
// this.node.getChildByName("uplv").active=true
|
||||
@@ -124,11 +171,12 @@ export class MissionComp extends CCComp {
|
||||
to_call_friend(){
|
||||
oops.message.dispatchEvent(GameEvent.HeroSelect,{is_master:false})
|
||||
}
|
||||
|
||||
|
||||
to_fight(){
|
||||
console.log("[MissionComp] to_fight")
|
||||
smc.vmdata.mission_data.in_fight=true
|
||||
oops.message.dispatchEvent(GameEvent.FightStart) //MissionMonComp 监听刷怪
|
||||
this.do_next_wave()
|
||||
}
|
||||
|
||||
|
||||
@@ -160,6 +208,9 @@ export class MissionComp extends CCComp {
|
||||
this.update_count=0
|
||||
this.GlodAddTimer=new Timer(smc.vmdata.mission_data.refrsh_time)
|
||||
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())
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user