summaryrefslogtreecommitdiff
path: root/ArchiveScript.cs
blob: 1f23c2426aa28a0284d66e481fde79d01a9fef41 (plain)
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
using UnityEngine;
using UnityEngine.UI;

public class ArchiveScript : MonoBehaviour
{
	private static ArchiveScript intance;

	public Image bar;

	public CanvasGroup escapeCG;

	public CanvasGroup wholeCG;

	private bool hide;

	private float escapeCounter;

	private void Start()
	{
		if (intance == null)
		{
			intance = this;
			Object.DontDestroyOnLoad(base.gameObject);
		}
		else
		{
			Object.Destroy(intance.gameObject);
		}
	}

	private void Update()
	{
		if (Input.GetKeyDown(KeyCode.H))
		{
			hide = !hide;
			if (hide)
			{
				wholeCG.alpha = 0f;
			}
			else
			{
				wholeCG.alpha = 1f;
			}
		}
		if (Input.GetKey(KeyCode.Escape))
		{
			escapeCounter += Time.deltaTime;
			if (escapeCounter > 1f)
			{
				Application.Quit();
			}
		}
		else
		{
			escapeCounter -= Time.deltaTime;
		}
		escapeCounter = Mathf.Clamp(escapeCounter, 0f, 2f);
		escapeCG.alpha = escapeCounter * 2f;
		bar.fillAmount = escapeCounter;
	}
}