-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
MenuUIController.cs
65 lines (57 loc) · 1.49 KB
/
MenuUIController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using Assets.Scripts.Core;
using Assets.Scripts.Core.Audio;
using System.Collections;
using UnityEngine;
public class MenuUIController : MonoBehaviour
{
public delegate void MenuCloseDelegate();
public UIPanel Panel;
private float time = 0.5f;
private bool isClosing;
public float PanelAlpha() => Panel.alpha;
private IEnumerator LeaveMenuAnimation(MenuCloseDelegate onClose, bool showMessage)
{
isClosing = true;
if (time > 0f)
{
yield return (object)new WaitForSeconds(time);
}
AudioController.Instance.PlaySystemSound("sysse05.ogg");
yield return (object)null;
yield return (object)null;
LeanTween.value(this.Panel.gameObject, delegate(float f)
{
this.Panel.alpha = f;
}, 1f, 0f, 0.3f);
yield return (object)new WaitForSeconds(0.3f);
if (showMessage)
{
GameSystem.Instance.MainUIController.FadeIn(0.3f);
GameSystem.Instance.SceneController.RevealFace(0.3f);
GameSystem.Instance.ExecuteActions();
yield return (object)new WaitForSeconds(0.3f);
}
onClose?.Invoke();
Object.Destroy(base.gameObject);
}
public void LeaveMenu(MenuCloseDelegate onClose, bool showMessage)
{
if (!isClosing && !(time > 0f))
{
StartCoroutine(LeaveMenuAnimation(onClose, showMessage));
}
}
private void Start()
{
Panel.alpha = 0f;
LeanTween.value(Panel.gameObject, delegate(float f)
{
Panel.alpha = f;
}, 0f, 1f, 0.3f).setDelay(0.3f);
AudioController.Instance.PlaySystemSound("sysse05.ogg");
}
private void Update()
{
time -= Time.deltaTime;
}
}