/// <summary> /// A coroutine to track the duration of the powerup and stop it when its dureation is up /// </summary> /// <returns>yields a short wait (one second) if the powerup is still active, null otherwise</returns> IEnumerator PowerUpTimer(AgentData agentData) { yield return(new WaitForSeconds(PowerUpDuration)); // the powerup effect has finished so reset agentData.PowerUp(0); // Removed from game after use Destroy(gameObject); yield return(null); }
/// <summary> /// Apply the effect of the powerup while it is active /// </summary> /// <param name="agentData"></param> public void Use(AgentData agentData) { agentData.PowerUp(PowerUpAmount); Destroy(gameObject); //StartCoroutine(PowerUpTimer(agentData)); }
/// <summary> /// Apply the effect of the powerup while it is active /// </summary> /// <param name="agentData"></param> public void Use(AgentData agentData) { agentData.PowerUp(PowerUpAmount); StartCoroutine(PowerUpTimer(agentData)); }