|
@@ -1,8 +1,10 @@
|
|
|
-import { _decorator, Component, Node } from 'cc';
|
|
|
+import { _decorator, Component, Node, ProgressBarComponent, LabelComponent } from 'cc';
|
|
|
import BufferManager from '../../../engines/buffers/BufferManager';
|
|
|
+import IBuffer from '../../../engines/buffers/IBuffer';
|
|
|
import { GUIManager } from '../../../engines/gui/GUIManager';
|
|
|
import { GUIMediator } from '../../../engines/gui/GUIMediator';
|
|
|
import { NoticeManager } from '../../../engines/notices/NoticeManager';
|
|
|
+import StringUtils from '../../../engines/utils/StringUtils';
|
|
|
import { PlatformManager } from '../../../Platform/PlatformManager';
|
|
|
import AccelerateBuffer from '../../buffers/AccelerateBuffer';
|
|
|
import { GameModel } from '../../models/GameModel';
|
|
@@ -12,6 +14,21 @@ const { ccclass, property } = _decorator;
|
|
|
@ccclass('AccelerateMediator')
|
|
|
export class AccelerateMediator extends GUIMediator {
|
|
|
|
|
|
+ @property({
|
|
|
+ type:ProgressBarComponent
|
|
|
+ })
|
|
|
+ progressBar:ProgressBarComponent=null;
|
|
|
+
|
|
|
+ @property({
|
|
|
+ type:LabelComponent
|
|
|
+ })
|
|
|
+ timeLabel:LabelComponent=null;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 最大时间
|
|
|
+ */
|
|
|
+ private max:number=150*1000*10;
|
|
|
+
|
|
|
OnShow(data?:any):void{
|
|
|
super.OnShow(data);
|
|
|
}
|
|
@@ -23,9 +40,14 @@ export class AccelerateMediator extends GUIMediator {
|
|
|
|
|
|
DiamondButtonClickHandler():void{
|
|
|
if(GameModel.single.diamond>20){
|
|
|
+ if(this.CurrentBufferTime>=this.max){
|
|
|
+ NoticeManager.ShowPrompt("加速时间已满!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
if(this.AddBuffer()){
|
|
|
//扣钱
|
|
|
GameModel.single.diamond-=20;
|
|
|
+ this.CloseButtonClickHandler();
|
|
|
}
|
|
|
}else{
|
|
|
NoticeManager.ShowPrompt("钻石不足");
|
|
@@ -36,6 +58,10 @@ export class AccelerateMediator extends GUIMediator {
|
|
|
* 视频按钮点击
|
|
|
*/
|
|
|
VideoButtonClickHandler():void{
|
|
|
+ if(this.CurrentBufferTime>=this.max){
|
|
|
+ NoticeManager.ShowPrompt("加速时间已满!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
PlatformManager.showRewardedVideo(()=>{
|
|
|
this.AddBuffer();
|
|
|
},()=>{
|
|
@@ -56,4 +82,19 @@ export class AccelerateMediator extends GUIMediator {
|
|
|
BufferManager.RunBuffer(buffer);
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private get CurrentBufferTime():number{
|
|
|
+ let buffers:IBuffer[]=BufferManager.GetBufferGroup("Accelerate");
|
|
|
+ if(buffers==null||buffers.length==0){
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ return buffers[0].GetTime();
|
|
|
+ }
|
|
|
+
|
|
|
+ update(dt:number):void{
|
|
|
+ this.progressBar.progress=this.CurrentBufferTime/this.max;
|
|
|
+ this.timeLabel.string=StringUtils.TimeFormatting(this.CurrentBufferTime,":",":",":","");
|
|
|
+ super.update(dt);
|
|
|
+ }
|
|
|
}
|