123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- using System;
- using System.Collections;
- using Colorful;
- using Core;
- using DG.Tweening;
- using DG.Tweening.Core;
- using DG.Tweening.Plugins.Options;
- using UnityEngine;
- public class UIPauseController : MonoBehaviour
- {
- private bool HasEnteredLevelSelectSystem
- {
- get
- {
- return SaveStorage.Get("HasEnteredLevelSelectSystem", false);
- }
- set
- {
- SaveStorage.Set("HasEnteredLevelSelectSystem", value);
- }
- }
- private void Start()
- {
- EventDelegate.Add(this._resume.onClick, new EventDelegate.Callback(this.OnResumeClick));
- EventDelegate.Add(this._exit.onClick, new EventDelegate.Callback(this.OnExitClick));
- EventDelegate.Add(this._levelSelect.onClick, new EventDelegate.Callback(this.OnLevelSelect));
- }
- private void Update()
- {
- if (this._panel.gameObject.activeInHierarchy && Core.Input.UI.Cancel.OnClick)
- {
- this.OnResumeClick();
- }
- }
- public bool Enabled
- {
- get
- {
- return Core.Input.UI.Pause.IsOpen;
- }
- set
- {
- Core.Input.UI.Pause.IsOpen = value;
- SingletonMono<MobileInputPlayer>.Instance.OptionsVisible = value;
- }
- }
- private void Open()
- {
- this._levelSelect.transform.parent.gameObject.SetActive(this.HasEnteredLevelSelectSystem);
- R.Audio.PauseBGM();
- R.Mode.EnterMode(Mode.AllMode.UI);
- R.Ui.HideUI(true);
- UIKeyInput.SaveAndSetHoveredObject(this._resume.gameObject);
- this._panel.gameObject.SetActive(true);
- AnalogTV analogTV = R.Ui.CameraGO.AddComponent<AnalogTV>();
- analogTV.Shader = Shader.Find("Hidden/Colorful/Analog TV");
- analogTV.NoiseIntensity = 1f;
- analogTV.ScanlinesIntensity = 0f;
- analogTV.ScanlinesCount = 696;
- analogTV.Distortion = 0.18f;
- analogTV.CubicDistortion = 0f;
- analogTV.Scale = 1.02f;
- }
- public YieldInstruction PauseThenOpenWithAnim()
- {
- this.Open();
- this.Enabled = false;
- R.PauseGame();
- AnalogTV analogTV = R.Ui.CameraGO.GetComponent<AnalogTV>();
- analogTV.Scale = 0f;
- return DOTween.To(() => analogTV.Scale, delegate(float scale)
- {
- analogTV.Scale = scale;
- }, 1.02f, 0.5f).OnComplete(delegate
- {
- this.Enabled = true;
- }).SetUpdate(true).WaitForCompletion();
- }
- private void Close()
- {
- UnityEngine.Object.Destroy(R.Ui.CameraGO.GetComponent<AnalogTV>());
- this._panel.gameObject.SetActive(false);
- UIKeyInput.LoadHoveredObject();
- R.Mode.ExitMode(Mode.AllMode.UI);
- R.Ui.ShowUI(true);
- R.Audio.UnPauseBGM();
- }
- public YieldInstruction CloseWithAnimThenResume()
- {
- this.Enabled = false;
- AnalogTV analogTV = R.Ui.CameraGO.GetComponent<AnalogTV>();
- return DOTween.To(() => analogTV.Scale, delegate(float scale)
- {
- analogTV.Scale = scale;
- }, 0f, 0.5f).SetUpdate(true).OnComplete(delegate
- {
- this.Close();
- R.ResumeGame();
- this.Enabled = true;
- }).WaitForCompletion();
- }
- private void OnResumeClick()
- {
- if (!this.Enabled)
- {
- return;
- }
- UIKeyInput.OnPauseClick();
- }
- private void OnExitClick()
- {
- if (!this.Enabled)
- {
- return;
- }
- UIKeyInput.OnPauseClick();
- R.Ui.Reset();
- R.Player.Action.ChangeState(PlayerAction.StateEnum.Idle, 1f);
- R.Audio.StopVoiceOver();
- LevelManager.LoadLevelByGateId("ui_start", SceneGate.OpenType.None);
- }
- private void OnLevelSelect()
- {
- if (!this.Enabled)
- {
- return;
- }
- base.StartCoroutine(this.LevelSelectCoroutine());
- }
- private IEnumerator LevelSelectCoroutine()
- {
- R.Audio.StopVoiceOver();
- yield return UIKeyInput.OnPauseClick();
- R.Ui.LevelSelect.OpenWithAnim(true, true);
- yield break;
- }
- [SerializeField]
- private UIButton _resume;
- [SerializeField]
- private UIButton _exit;
- [SerializeField]
- private UIButton _levelSelect;
- [SerializeField]
- private UIPanel _panel;
- }
|