Beispiel #1
0
    /// <summary>
    /// Activates a random good powerup.
    /// </summary>
    public void DoGoodPowerUp()
    {
        // if not all powerups are active
        if (numActiveGoodPowerUps < goodPowerUps.Length)
        {
            // randomly choose a powerup
            int num = Random.Range(0, goodPowerUps.Length);

            // if it is possible to activate powerup
            if (goodPowerUps[num].GetIsPossible())
            {
                // if it not alrady activated
                if (!goodPowerUps[num].GetIsActive())
                {
                    goodPowerUps[num].Enable();

                    numActiveGoodPowerUps++;
                }
                else
                {
                    if (IsPowerUpPossible(PowerUpType.Good, manager.GetCurrentSpawned(PowerUpType.Good))) // although powerup should only spawn if at least one powerup is possible this is a double check to prevent stack overflows
                    {
                        DoGoodPowerUp();
                    }
                    Debug.LogError("DEFENCES BREACHED! MASSIVE ERROR CALL THE POLICE");
                }
            }
            else
            {
                DoGoodPowerUp();
            }
        }
    }