diff options
Diffstat (limited to 'Client/Assembly-CSharp/KillOverlay.cs')
-rw-r--r-- | Client/Assembly-CSharp/KillOverlay.cs | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/KillOverlay.cs b/Client/Assembly-CSharp/KillOverlay.cs new file mode 100644 index 0000000..9c0c226 --- /dev/null +++ b/Client/Assembly-CSharp/KillOverlay.cs @@ -0,0 +1,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; + } +} |