|
@@ -1,4 +1,4 @@
|
|
-import { _decorator, Color, Component, Label, Node, ProgressBar, Tween, tween } from 'cc';
|
|
|
|
|
|
+import { _decorator, Color, Component, Label, Node, ProgressBar, Size, Tween, tween, UITransform } from 'cc';
|
|
import { ui_base } from './ui_base';
|
|
import { ui_base } from './ui_base';
|
|
import { boss_info_data } from '../../../data/data';
|
|
import { boss_info_data } from '../../../data/data';
|
|
import { tools } from '../../tools';
|
|
import { tools } from '../../tools';
|
|
@@ -25,6 +25,7 @@ export class ui_boss_info extends ui_base {
|
|
gameManager.initUiBaseAtt(this.bg_bar,this.mBossData.bg_bar)
|
|
gameManager.initUiBaseAtt(this.bg_bar,this.mBossData.bg_bar)
|
|
gameManager.initUiBaseAtt(this.bar,this.mBossData.bar)
|
|
gameManager.initUiBaseAtt(this.bar,this.mBossData.bar)
|
|
gameManager.initUiBaseAtt(this.head,this.mBossData.head)
|
|
gameManager.initUiBaseAtt(this.head,this.mBossData.head)
|
|
|
|
+ this.bg_bar.getComponent(ProgressBar).totalLength = this.bg_bar.getComponent(UITransform).width
|
|
this.bossHp = this.mBossData.hp;
|
|
this.bossHp = this.mBossData.hp;
|
|
this.bg_bar.getComponent(ProgressBar).progress = 1;
|
|
this.bg_bar.getComponent(ProgressBar).progress = 1;
|
|
ClientEvent.on(config.EventRun.ON_BOSS_HURT,this.hurt.bind(this),this)
|
|
ClientEvent.on(config.EventRun.ON_BOSS_HURT,this.hurt.bind(this),this)
|
|
@@ -32,6 +33,7 @@ export class ui_boss_info extends ui_base {
|
|
|
|
|
|
protected onDisable(): void {
|
|
protected onDisable(): void {
|
|
ClientEvent.off(config.EventRun.ON_BOSS_HURT,this.hurt.bind(this),this)
|
|
ClientEvent.off(config.EventRun.ON_BOSS_HURT,this.hurt.bind(this),this)
|
|
|
|
+ this.unscheduleAllCallbacks()
|
|
}
|
|
}
|
|
|
|
|
|
hurt(hurt_num:number){
|
|
hurt(hurt_num:number){
|
|
@@ -40,20 +42,30 @@ export class ui_boss_info extends ui_base {
|
|
this.onFialEvent()
|
|
this.onFialEvent()
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- this.bossHp -= hurt_num;
|
|
|
|
- Tween.stopAllByTarget(this.hp_ani)
|
|
|
|
- this.hp_ani.getComponent(Label).string = `${hurt_num>0?"-":"+"}${Math.abs(hurt_num)}`
|
|
|
|
- this.hp_ani.active = true;
|
|
|
|
- this.hp_ani.getComponent(Label).color = hurt_num>0?Color.RED:Color.GREEN;
|
|
|
|
- tween(this.hp_ani).delay(2).call(()=>{
|
|
|
|
- this.hp_ani.active = false;
|
|
|
|
- }).start()
|
|
|
|
- this.bg_bar.getComponent(ProgressBar).progress = this.bossHp/this.mBossData.hp;
|
|
|
|
- if(this.bossHp<=0){
|
|
|
|
- tools.showToast("成功打死boss")
|
|
|
|
- this.onFinishEvent()
|
|
|
|
- ClientEvent.off(config.EventRun.ON_BOSS_HURT,this.hurt.bind(this),this)
|
|
|
|
|
|
+ let hp_delay_time = 0
|
|
|
|
+ if(this.mBossData.hp_delay_time!=undefined) {
|
|
|
|
+ hp_delay_time = this.mBossData.hp_delay_time
|
|
}
|
|
}
|
|
|
|
+ this.scheduleOnce(()=>{
|
|
|
|
+ this.bossHp -= hurt_num;
|
|
|
|
+ Tween.stopAllByTarget(this.hp_ani)
|
|
|
|
+ this.hp_ani.getComponent(Label).string = `${hurt_num>0?"-":"+"}${Math.abs(hurt_num)}`
|
|
|
|
+ this.hp_ani.active = true;
|
|
|
|
+ this.hp_ani.getComponent(Label).color = hurt_num>0?Color.RED:Color.GREEN;
|
|
|
|
+ tween(this.hp_ani).delay(2).call(()=>{
|
|
|
|
+ this.hp_ani.active = false;
|
|
|
|
+ }).start()
|
|
|
|
+ if(this.bossHp>=this.mBossData.hp) {
|
|
|
|
+ this.bossHp = this.mBossData.hp
|
|
|
|
+ }
|
|
|
|
+ let progress = this.bossHp/this.mBossData.hp
|
|
|
|
+ this.bg_bar.getComponent(ProgressBar).progress = progress;
|
|
|
|
+ if(this.bossHp<=0){
|
|
|
|
+ tools.showToast("成功打死boss")
|
|
|
|
+ this.onFinishEvent()
|
|
|
|
+ ClientEvent.off(config.EventRun.ON_BOSS_HURT,this.hurt.bind(this),this)
|
|
|
|
+ }
|
|
|
|
+ },hp_delay_time)
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|