summaryrefslogtreecommitdiff
path: root/GameCode/SetSpawnedParticleColor.cs
blob: fc9052b1f336157ee40e551006b5357b0916ee21 (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
using System;
using UnityEngine;

public class SetSpawnedParticleColor : MonoBehaviour
{
	private Color myColor;

	private void Start()
	{
		SpawnObjects component = GetComponent<SpawnObjects>();
		component.SpawnedAction = (Action<GameObject>)Delegate.Combine(component.SpawnedAction, new Action<GameObject>(Go));
		myColor = PlayerSkinBank.GetPlayerSkinColors(GetComponentInParent<SpawnedAttack>().spawner.playerID).particleEffect;
	}

	private void Go(GameObject spawned)
	{
		ParticleSystem[] componentsInChildren = spawned.GetComponentsInChildren<ParticleSystem>();
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			componentsInChildren[i].startColor = myColor;
		}
		LineEffect[] componentsInChildren2 = spawned.GetComponentsInChildren<LineEffect>();
		for (int j = 0; j < componentsInChildren2.Length; j++)
		{
			componentsInChildren2[j].useColorOverTime = false;
			componentsInChildren2[j].GetComponent<LineRenderer>().startColor = myColor;
			componentsInChildren2[j].GetComponent<LineRenderer>().endColor = myColor;
		}
	}
}