summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/KillOverlay.cs
blob: 9c0c226944856bee3200caf7957c96abae4fa36f (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class KillOverlay : MonoBehaviour
{
	public bool IsOpen
	{
		get
		{
			return this.showAll != null || this.queue.Count > 0;
		}
	}

	public SpriteRenderer background;

	public GameObject flameParent;

	public OverlayKillAnimation[] KillAnims;

	public float FadeTime = 0.6f;

	public OverlayKillAnimation EmergencyOverlay;

	public OverlayKillAnimation ReportOverlay;

	private Queue<Func<IEnumerator>> queue = new Queue<Func<IEnumerator>>();

	private Coroutine showAll;

	private Coroutine showOne;

	public IEnumerator WaitForFinish()
	{
		while (this.showAll != null || this.queue.Count > 0)
		{
			yield return null;
		}
		yield break;
	}

	public void ShowOne(PlayerControl killer, GameData.PlayerInfo victim)
	{
		this.queue.Enqueue(() => this.CoShowOne(this.KillAnims.Random<OverlayKillAnimation>(), killer, victim));
		if (this.showAll == null)
		{
			this.showAll = base.StartCoroutine(this.ShowAll());
		}
	}

	public void ShowOne(OverlayKillAnimation killAnimPrefab, PlayerControl killer, GameData.PlayerInfo victim)
	{
		this.queue.Enqueue(() => this.CoShowOne(killAnimPrefab, killer, victim));
		if (this.showAll == null)
		{
			this.showAll = base.StartCoroutine(this.ShowAll());
		}
	}

	private IEnumerator ShowAll()
	{
		while (this.queue.Count > 0 || this.showOne != null)
		{
			if (this.showOne == null)
			{
				this.showOne = base.StartCoroutine(this.queue.Dequeue()());
			}
			yield return null;
		}
		this.showAll = null;
		yield break;
	}

	private IEnumerator CoShowOne(OverlayKillAnimation killAnimPrefab, PlayerControl killer, GameData.PlayerInfo victim)
	{
		OverlayKillAnimation overlayKillAnimation = UnityEngine.Object.Instantiate<OverlayKillAnimation>(killAnimPrefab, base.transform);
		overlayKillAnimation.Begin(killer, victim);
		overlayKillAnimation.gameObject.SetActive(false);
		yield return this.CoShowOne(overlayKillAnimation);
		yield break;
	}

	private IEnumerator CoShowOne(OverlayKillAnimation anim)
	{
		if (Constants.ShouldPlaySfx())
		{
			SoundManager.Instance.PlaySound(anim.Stinger, false, 1f).volume = anim.StingerVolume;
		}
		WaitForSeconds wait = new WaitForSeconds(0.083333336f);
		this.background.enabled = true;
		yield return wait;
		this.background.enabled = false;
		this.flameParent.SetActive(true);
		this.flameParent.transform.localScale = new Vector3(1f, 0.3f, 1f);
		this.flameParent.transform.localEulerAngles = new Vector3(0f, 0f, 25f);
		yield return wait;
		this.flameParent.transform.localScale = new Vector3(1f, 0.5f, 1f);
		this.flameParent.transform.localEulerAngles = new Vector3(0f, 0f, -15f);
		yield return wait;
		this.flameParent.transform.localScale = new Vector3(1f, 1f, 1f);
		this.flameParent.transform.localEulerAngles = new Vector3(0f, 0f, 0f);
		anim.gameObject.SetActive(true);
		yield return anim.WaitForFinish();
		UnityEngine.Object.Destroy(anim.gameObject);
		yield return new WaitForLerp(0.16666667f, delegate(float t)
		{
			this.flameParent.transform.localScale = new Vector3(1f, 1f - t, 1f);
		});
		this.flameParent.SetActive(false);
		this.showOne = null;
		yield break;
	}
}