summaryrefslogtreecommitdiff
path: root/GameCode/DynamicParticles.cs
blob: 26a0cad96554334dc4f496d1cabcfd48c78008c3 (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
using UnityEngine;

public class DynamicParticles : MonoBehaviour
{
	public static DynamicParticles instance;

	public DynamicParticleSet[] bulletHit;

	private int spawnsThisFrame;

	private void Start()
	{
		instance = this;
	}

	private void Update()
	{
		spawnsThisFrame = 0;
	}

	public void PlayBulletHit(float damage, Transform spawnerTransform, HitInfo hit, Color projectielColor)
	{
		if ((float)spawnsThisFrame > 5f)
		{
			return;
		}
		spawnsThisFrame++;
		int num = 0;
		for (int i = 1; i < bulletHit.Length && !(bulletHit[i].dmg > damage); i++)
		{
			num = i;
		}
		GameObject[] array = ObjectsToSpawn.SpawnObject(base.transform, hit, bulletHit[num].objectsToSpawn, null, null);
		if (!(projectielColor != Color.black))
		{
			return;
		}
		for (int j = 0; j < array.Length; j++)
		{
			for (int k = 0; k < array[j].transform.childCount; k++)
			{
				ChangeColor componentInChildren = array[j].transform.GetChild(k).GetComponentInChildren<ChangeColor>();
				if ((bool)componentInChildren)
				{
					componentInChildren.GetComponent<ParticleSystemRenderer>().material.color = projectielColor;
				}
			}
		}
	}
}