diff options
Diffstat (limited to 'GameCode/SetSpawnedParticleColor.cs')
-rw-r--r-- | GameCode/SetSpawnedParticleColor.cs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/GameCode/SetSpawnedParticleColor.cs b/GameCode/SetSpawnedParticleColor.cs new file mode 100644 index 0000000..fc9052b --- /dev/null +++ b/GameCode/SetSpawnedParticleColor.cs @@ -0,0 +1,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; + } + } +} |