summaryrefslogtreecommitdiff
path: root/GameCode/SpawnStaticRemnant.cs
blob: 9e0a67e697927b81902920a9c00324e468cfad7a (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
using UnityEngine;

public class SpawnStaticRemnant : MonoBehaviour
{
	public GameObject remnantSource;

	private AttackLevel level;

	private Color remnantColor;

	private void Start()
	{
		remnantColor = PlayerSkinBank.GetPlayerSkinColors(base.transform.GetComponentInParent<Player>().playerID).winText;
		level = GetComponent<AttackLevel>();
	}

	public void Go()
	{
		GameObject gameObject = Object.Instantiate(remnantSource, base.transform.position, base.transform.rotation);
		SpriteRenderer[] componentsInChildren = base.transform.root.GetComponentsInChildren<SpriteRenderer>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			if (componentsInChildren[i].transform.lossyScale.x != 0f && componentsInChildren[i].transform.lossyScale.y != 0f && componentsInChildren[i].transform.lossyScale.z != 0f && (!(componentsInChildren[i].transform.parent.name != "Art") || !(componentsInChildren[i].transform.parent.parent.name != "Face")))
			{
				Vector3 lossyScale = componentsInChildren[i].transform.lossyScale;
				GameObject gameObject2 = Object.Instantiate(componentsInChildren[i].gameObject, componentsInChildren[i].transform.position, componentsInChildren[i].transform.rotation, gameObject.transform.GetChild(0));
				gameObject2.transform.localScale = lossyScale;
				Strip(gameObject2);
				SpriteRenderer component = gameObject2.GetComponent<SpriteRenderer>();
				component.enabled = true;
				component.color = remnantColor;
				SpriteMask component2 = gameObject2.GetComponent<SpriteMask>();
				if ((bool)component2)
				{
					Object.Destroy(component2);
				}
			}
		}
		gameObject.GetComponentInChildren<ParticleSystem>().startColor = PlayerSkinBank.GetPlayerSkinColors(base.transform.GetComponentInParent<Player>().playerID).particleEffect;
		gameObject.AddComponent<SpawnedAttack>().spawner = base.transform.root.GetComponent<Player>();
		gameObject.transform.localScale *= 1f + (float)(level.attackLevel - 1) * 0.3f;
	}

	private void Strip(GameObject go)
	{
		MonoBehaviour[] componentsInChildren = go.GetComponentsInChildren<MonoBehaviour>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			Object.Destroy(componentsInChildren[i]);
		}
	}
}