//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Tuesday, September 11, 2018 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace vnxbqy.UI { public class ExitGameWin : Window { [SerializeField] Button m_Exit; [SerializeField] Button m_Cancel; [SerializeField] UIAlphaTween m_AlphaTween; [SerializeField] PositionTween m_PositionTween; float doubleKickTime = 0f; #region Built-in protected override void BindController() { } protected override void AddListeners() { m_Exit.AddListener(ExitGame); m_Cancel.AddListener(Cancel); } protected override void OnPreOpen() { doubleKickTime = Time.time + 2f; m_PositionTween.SetStartState(); } protected override void OnAfterOpen() { } protected override void OnPreClose() { } protected override void OnAfterClose() { } protected override void OnActived() { base.OnActived(); m_AlphaTween.Play(); m_PositionTween.Play(); } protected override void LateUpdate() { base.LateUpdate(); if (Input.GetKeyDown(KeyCode.Escape)) { if (Time.time < doubleKickTime) { ExitGame(); } else { Cancel(); } } } #endregion private void ExitGame() { #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #elif UNITY_ANDROID Application.Quit(); #endif } private void Cancel() { WindowCenter.Instance.Close(); } } }