summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/OverlayKillAnimation.cs
blob: d6f711e83691170c5171a75435d06a9eef7c1b37 (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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
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<HatManager>.Instance.GetSkinById(kInfo.SkinId);
				this.killerParts.SkinSlot.GetComponent<SpriteAnim>().Play(skinById.KillTongueImpostor, 1f);
				break;
			}
			case KillAnimType.Shoot:
			{
				SkinData skinById2 = DestroyableSingleton<HatManager>.Instance.GetSkinById(kInfo.SkinId);
				this.killerParts.SkinSlot.GetComponent<SpriteAnim>().Play(skinById2.KillShootImpostor, 1f);
				break;
			}
			}
			if (this.killerParts.PetSlot)
			{
				PetBehaviour petById = DestroyableSingleton<HatManager>.Instance.GetPetById(kInfo.PetId);
				if (petById && petById.scaredClip)
				{
					this.killerParts.PetSlot.GetComponent<SpriteAnim>().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<HatManager>.Instance.GetSkinById(vInfo.SkinId);
			switch (this.KillType)
			{
			case KillAnimType.Stab:
				this.victimParts.SkinSlot.GetComponent<SpriteAnim>().Play(skinById3.KillStabVictim, 1f);
				break;
			case KillAnimType.Tongue:
				this.victimParts.SkinSlot.GetComponent<SpriteAnim>().Play(skinById3.KillTongueVictim, 1f);
				break;
			case KillAnimType.Shoot:
				this.victimParts.SkinSlot.GetComponent<SpriteAnim>().Play(skinById3.KillShootVictim, 1f);
				break;
			case KillAnimType.Neck:
				this.victimParts.SkinSlot.GetComponent<SpriteAnim>().Play(skinById3.KillNeckVictim, 1f);
				break;
			}
			if (this.victimParts.PetSlot)
			{
				PetBehaviour petById2 = DestroyableSingleton<HatManager>.Instance.GetPetById(vInfo.PetId);
				if (petById2 && petById2.scaredClip)
				{
					this.victimParts.PetSlot.GetComponent<SpriteAnim>().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<HatManager>.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<SpriteAnim>();
		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;
	}
}