|
@@ -1,5 +1,5 @@
|
|
|
import { _decorator, Component, Label, Node, ProgressBar } from 'cc';
|
|
|
-import { att_count_down } from '../../../data/data';
|
|
|
+import { att_count_down, widget_item_data } from '../../../data/data';
|
|
|
import { gameManager } from '../gameManager';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
@@ -11,13 +11,19 @@ export class count_down extends Component {
|
|
|
@property(Node) img_text:Node = null;
|
|
|
@property(Node) lab_time:Node = null;
|
|
|
private time_count:number = 0;
|
|
|
+ private add_time:number = 0;
|
|
|
private m_over_call = null;
|
|
|
- public init(data:att_count_down,on_over_call){
|
|
|
+ private m_widget_data:widget_item_data = null;
|
|
|
+ public init(data:att_count_down,on_over_call,widget_data:widget_item_data){
|
|
|
|
|
|
this.m_data = data;
|
|
|
|
|
|
+ this.m_widget_data = widget_data;
|
|
|
+
|
|
|
this.m_over_call = on_over_call;
|
|
|
|
|
|
+ this.add_time = 0;
|
|
|
+
|
|
|
gameManager.initUiBaseAtt(this.ProgressBar_Bar,this.m_data.ProgressBar_Bar)
|
|
|
|
|
|
gameManager.initUiBaseAtt(this.ProgressBar_Bg,this.m_data.ProgressBar_Bg)
|
|
@@ -44,19 +50,26 @@ export class count_down extends Component {
|
|
|
return this.m_data
|
|
|
}
|
|
|
|
|
|
+ public addTime(widget_id:number,time:number){
|
|
|
+ if(this.m_widget_data.att.id==widget_id){
|
|
|
+ this.add_time+=time;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public startCountDown(){
|
|
|
this.schedule(()=>{
|
|
|
this.time_count+=1;
|
|
|
- if(this.time_count>this.m_data.time_count){
|
|
|
+ let all_time = this.m_data.time_count+this.add_time
|
|
|
+ if(this.time_count>all_time){
|
|
|
this.unscheduleAllCallbacks()
|
|
|
if(this.m_over_call!=null){
|
|
|
this.m_over_call(true)
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
- this.ProgressBar_Bg.getComponent(ProgressBar).progress = 1-this.time_count/this.m_data.time_count
|
|
|
+ this.ProgressBar_Bg.getComponent(ProgressBar).progress = 1-this.time_count/all_time
|
|
|
if(this.m_data.is_show_time){
|
|
|
- this.lab_time.getComponent(Label).string = `${this.m_data.time_count-this.time_count}秒`
|
|
|
+ this.lab_time.getComponent(Label).string = `${all_time-this.time_count}秒`
|
|
|
}
|
|
|
|
|
|
},1)
|