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> queue = new Queue>(); 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(), 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(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; } }