using UnityEngine; using System.Collections;
public class ParticleScript : MonoBehaviour { public static Color [] holder ;
public static bool PlayerMoved = false
;
void Update()
{
if (Mathf.Abs(PlayerMoveScript.MoveForward) > 0)
{
PlayerMoved = true;
}
else PlayerMoved = false;
}
public static IEnumerator FadeParticles()
{
Debug.Log("Done Waiting");
if (PlayerBias.theRedParticles != null)
{
holder = new Color[5]; // we have five color groups to alter
// Reset our Emitter coordinate and assign it to follow the player
theRedParticles.GetComponent<ParticleEmitter>( ).transform.position = new Vector3(0, 0, 0);
theRedParticles.GetComponent<ParticleEmitter>( ).transform.position = PlayerMoveScript.myPosition;
holder = theRedParticles.GetComponent<ParticleAnimator>( ).colorAnimation;
if (Mathf.Abs(PlayerMoveScript.MoveForward) > 0)
{
for (int x=0; x<5; x++)
holder[x].a -= 0.02f;
}
PlayerMoveScript.lastPosition = PlayerMoveScript.myPosition; // Update our Position
theRedParticles.GetComponent<ParticleAnimator>( ).colorAnimation = holder;
if (holder[0].a < 0)
{
Debug.Log("Clearing Particles..");
theRedParticles.GetComponent<ParticleEmitter>( ).ClearParticles();
}
}
if (theRedParticles != null) // Meaning that we instantiated it with PlayerBias
{
holder = new Color[5]; // we have five color groups to alter
// Reset our Emitter coordinate and assign it to follow the player
theRedParticles.GetComponent<ParticleEmitter>( ).transform.position = new Vector3(0, 0, 0);
theRedParticles.GetComponent<ParticleEmitter>( ).transform.position = PlayerMoveScript.myPosition;
if (Mathf.Abs(PlayerMoveScript.MoveForward) > 0)
{
for (int x=0; x<5; x++)
holder[x].a -= 0.02f;
}
PlayerMoveScript.lastPosition = PlayerMoveScript.myPosition; // Update our Position
}
yield return new WaitForSeconds(3.5f);
}
}