1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- import { _decorator, Component, Node, 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 { DataModelEventType } from '../../../engines/models/DataModelEventType';
- import { NoticeManager } from '../../../engines/notices/NoticeManager';
- import { PlatformManager } from '../../../Platform/PlatformManager';
- import AutoSyntheticBuffer from '../../buffers/AutoSyntheticBuffer';
- import GameConfigManager from '../../models/GameConfigManager';
- import { GameModel } from '../../models/GameModel';
- import { GamePropertys } from '../../models/GamePropertys';
- import { UIConst } from '../UIConst';
- const { ccclass, property } = _decorator;
- @ccclass('AutoSynthesisMediator')
- export class AutoSynthesisMediator extends GUIMediator {
- @property({
- type:LabelComponent
- })
- diamondLabel:LabelComponent=null;
- private consume:number=20;
- private time:number=300*1000;
- start():void{
- this.consume=GameConfigManager.getGlobalValue("AutoSyntheticDiamondConsume");
- this.time=GameConfigManager.getGlobalValue("autoSyntheticTime")*1000;
- }
- OnShow(data?:any):void{
- super.OnShow(data);
- this.RefreshView();
- }
- OnHide():void{
- }
- private RefreshView():void{
- this.diamondLabel.string=this.consume.toString();
- }
- /**
- * 钻石按钮点击
- */
- DiamondButtonClickHandler():void{
- if(GameModel.single.diamond>this.consume){
- if(this.AddBuffer()){
- //扣钱
- GameModel.single.diamond-=this.consume;
- this.CloseButtonClickHandler();
- }
- }else{
- NoticeManager.ShowPrompt("钻石不足");
- }
- }
- /**
- * 视频按钮点击
- */
- VideoButtonClickHandler():void{
- PlatformManager.showRewardedVideo(()=>{
- this.AddBuffer();
- this.CloseButtonClickHandler();
- },()=>{
- NoticeManager.ShowPrompt("看视频失败");
- });
- }
- /**
- * 关闭按钮点击
- */
- CloseButtonClickHandler():void{
- GUIManager.single.Show(UIConst.PREPARE_UI);
- this.HideSelf();
- }
- private AddBuffer():boolean{
- let buffers:IBuffer[]=BufferManager.GetBufferGroup("AutoSynthesis");
- if(buffers!=null&&buffers.length>0){
- NoticeManager.ShowPrompt("自动合成已开启");
- return false;
- }
- let buffer:AutoSyntheticBuffer=new AutoSyntheticBuffer("AutoSynthesis",this.time);
- BufferManager.RunBuffer(buffer);
- return true;
- }
- }
|