import BasicView from "../../../Engine/Basic/BasicView"; import { _ECommonState, _EJsonRes, _IViewConfig } from "../../../Engine/Data/CommonDataType"; import EventManager from "../../../Engine/Event/EventManager"; import TimeManager from "../../../Engine/Time/TimeManager"; import Tool from "../../../Engine/Tool/Tool"; import GameManager from "../../Game/GameManager"; import { ConstObject } from "../../Data/GameDataType"; import GameEventName from "../../Event/GameEventName"; import SDKManager from "../../SDK/SDKManager"; import GameView from "../GameView/GameView"; import HintView from "../HintView/HintView"; import JsonResources from "../../../Engine/Resources/JsonResources"; import GameAudioResData from "../../Game/Data/GameMusicResData"; import { _IPlaySound } from "../../../Engine/Audio/Data/AudioConfig"; /** * 暂停页 */ export default class PauseView extends BasicView { public static resPath: string = "PauseView"; protected _initView(): void { ConstObject.GameState = _ECommonState.Pause; TimeManager.pause(); let resetButton: fgui.GComponent = this.fgui.getChild("resetButton").asCom; Tool.Tool2D.Button.addEvent(resetButton, { "touchend": () => { this.onReset(); } }, this.fgui.id, 0.9, 0.9, 0, false); let continueButton: fgui.GComponent = this.fgui.getChild("continueButton").asCom; Tool.Tool2D.Button.addEvent(continueButton, { "touchend": () => { this.onContinue(); } }, this.fgui.id, 0.9, 0.9, 0, false); let quitButton: fgui.GComponent = this.fgui.getChild("quitButton").asCom; Tool.Tool2D.Button.addEvent(quitButton, { "touchend": () => { this.onQuit(); } }, this.fgui.id, 0.9, 0.9, 0, false); SDKManager.addButton([ { button: continueButton, color: [ cc.Color.BLACK, cc.Color.BLACK, ], callback: () => { if (ConstObject.FirstEnter == false) { this.onContinue(); } } }, { button: resetButton, color: [ cc.Color.BLACK, cc.Color.BLACK, ], callback: () => { if (ConstObject.FirstEnter == false) { this.onReset(); } } }, { button: quitButton, color: [ cc.Color.BLACK, cc.Color.BLACK, ], callback: () => { if (ConstObject.FirstEnter == false) { this.onQuit(); } } } ]); EventManager.sendEvent(GameEventName.Audio.Audio_PauseSound, null); if (ConstObject.FirstEnter == true) { this.fgui.node.zIndex = -1000; // this.onContinue(); EventManager.onEvent(GameEventName.SDK.SDK_Confirm, this, this.onContinue, 1); } EventManager.sendEvent(GameEventName.View.View_ShowView, HintView); } protected _refreshView(): void { let viewConfig: _IViewConfig = JsonResources.getResources(_EJsonRes.View); this.fgui.node.zIndex = viewConfig.ZIndex[PauseView.resPath] as any; } protected _clearView(): void { TimeManager.resume(); SDKManager.removeButton(); EventManager.sendEvent(GameEventName.Audio.Audio_ResumeSound, null); EventManager.sendEvent(GameEventName.View.View_DestroyView, HintView); if (ConstObject.FirstEnter == false) { ConstObject.GameState = _ECommonState.Runing; } } protected resize () { this.fgui.width = fgui.GRoot.inst.width; } private onReset (): void { ConstObject.GameState = _ECommonState.None; let playSound: _IPlaySound = { url: GameAudioResData.ClickButton, callback: null, } EventManager.sendEvent(GameEventName.Audio.Audio_PlaySound, playSound); EventManager.sendEvent(GameEventName.View.View_DestroyView, PauseView); EventManager.sendEvent(GameEventName.View.View_ShowView, GameView); GameManager.setGameView(GameEventName.View.View_ShowView); } private onContinue (): void { if (ConstObject.FirstEnter == false) { let playSound: _IPlaySound = { url: GameAudioResData.ClickButton, callback: null, } EventManager.sendEvent(GameEventName.Audio.Audio_PlaySound, playSound); } EventManager.sendEvent(GameEventName.View.View_DestroyView, PauseView); } private onQuit (): void { let playSound: _IPlaySound = { url: GameAudioResData.ClickButton, callback: null, } EventManager.sendEvent(GameEventName.Audio.Audio_PlaySound, playSound); EventManager.sendEvent(GameEventName.Game_QuitGame); } }