using System; using System.Collections; using PowerTools; using UnityEngine; public class OverlayKillAnimation : MonoBehaviour { public KillAnimType KillType; public PoolablePlayer killerParts; public PoolablePlayer victimParts; private uint victimHat; public AudioClip Stinger; public AudioClip Sfx; public float StingerVolume = 0.6f; public void Begin(PlayerControl killer, GameData.PlayerInfo vInfo) { if (this.killerParts) { GameData.PlayerInfo kInfo = killer.Data; PlayerControl.SetPlayerMaterialColors((int)kInfo.ColorId, this.killerParts.Body); this.killerParts.Hands.ForEach(delegate(SpriteRenderer b) { PlayerControl.SetPlayerMaterialColors((int)kInfo.ColorId, b); }); PlayerControl.SetHatImage(kInfo.HatId, this.killerParts.HatSlot); switch (this.KillType) { case KillAnimType.Stab: case KillAnimType.Neck: PlayerControl.SetSkinImage(kInfo.SkinId, this.killerParts.SkinSlot); break; case KillAnimType.Tongue: { SkinData skinById = DestroyableSingleton.Instance.GetSkinById(kInfo.SkinId); this.killerParts.SkinSlot.GetComponent().Play(skinById.KillTongueImpostor, 1f); break; } case KillAnimType.Shoot: { SkinData skinById2 = DestroyableSingleton.Instance.GetSkinById(kInfo.SkinId); this.killerParts.SkinSlot.GetComponent().Play(skinById2.KillShootImpostor, 1f); break; } } if (this.killerParts.PetSlot) { PetBehaviour petById = DestroyableSingleton.Instance.GetPetById(kInfo.PetId); if (petById && petById.scaredClip) { this.killerParts.PetSlot.GetComponent().Play(petById.idleClip, 1f); this.killerParts.PetSlot.sharedMaterial = petById.rend.sharedMaterial; PlayerControl.SetPlayerMaterialColors((int)kInfo.ColorId, this.killerParts.PetSlot); } else { this.killerParts.PetSlot.enabled = false; } } } if (vInfo != null && this.victimParts) { this.victimHat = vInfo.HatId; PlayerControl.SetPlayerMaterialColors((int)vInfo.ColorId, this.victimParts.Body); PlayerControl.SetHatImage(vInfo.HatId, this.victimParts.HatSlot); SkinData skinById3 = DestroyableSingleton.Instance.GetSkinById(vInfo.SkinId); switch (this.KillType) { case KillAnimType.Stab: this.victimParts.SkinSlot.GetComponent().Play(skinById3.KillStabVictim, 1f); break; case KillAnimType.Tongue: this.victimParts.SkinSlot.GetComponent().Play(skinById3.KillTongueVictim, 1f); break; case KillAnimType.Shoot: this.victimParts.SkinSlot.GetComponent().Play(skinById3.KillShootVictim, 1f); break; case KillAnimType.Neck: this.victimParts.SkinSlot.GetComponent().Play(skinById3.KillNeckVictim, 1f); break; } if (this.victimParts.PetSlot) { PetBehaviour petById2 = DestroyableSingleton.Instance.GetPetById(vInfo.PetId); if (petById2 && petById2.scaredClip) { this.victimParts.PetSlot.GetComponent().Play(petById2.scaredClip, 1f); this.victimParts.PetSlot.sharedMaterial = petById2.rend.sharedMaterial; PlayerControl.SetPlayerMaterialColors((int)vInfo.ColorId, this.victimParts.PetSlot); return; } this.victimParts.PetSlot.enabled = false; } } } public void SetHatFloor() { HatBehaviour hatById = DestroyableSingleton.Instance.GetHatById(this.victimHat); if (!hatById) { return; } this.victimParts.HatSlot.sprite = hatById.FloorImage; } public void PlayKillSound() { if (Constants.ShouldPlaySfx()) { SoundManager.Instance.PlaySound(this.Sfx, false, 1f).volume = 0.8f; } } public IEnumerator WaitForFinish() { SpriteAnim[] anims = base.GetComponentsInChildren(); if (anims.Length == 0) { yield return new WaitForSeconds(1f); } else { for (;;) { bool flag = false; for (int i = 0; i < anims.Length; i++) { if (anims[i].IsPlaying(null)) { flag = true; break; } } if (!flag) { break; } yield return null; } } yield break; } }