Exemplo n.º 1
0
    public void SetInactivePUObject(PowerUpBaseClass powerUp, GameObject obj)
    {
        System.Type powerUpType = powerUp.GetType();

        inactivePU.Add(powerUp);
        activePU.Remove(powerUp);
        obj.SetActive(false);

        //May want to keep these in order to change what happens to each type when it is deactivated
        if (powerUpType.Equals(typeof(BrightenPowerUp)))
        {
            // obj.SetActive (false);
        }
        else if (powerUpType.Equals(typeof(DestroyAllPowerUp)))
        {
            // obj.SetActive (false);
        }
        else if (powerUpType.Equals(typeof(HealthBackPowerUp)))
        {
            // obj.SetActive (false);
        }
        else if (powerUpType.Equals(typeof(ShieldPowerUp)))
        {
            // obj.SetActive(false);
        }
        else
        {
            Debug.LogWarning("This powerup type hasn't been added to the handler! " + powerUpType);
        }
    }
Exemplo n.º 2
0
    void SpawnPowerUp()
    {
        if (currentPUBag.Count == 0)
        {
            ShuffleAndReplenishBag(powerUpBag, currentPUBag);
        }

        PowerUpBaseClass newPU = currentPUBag[0];

        currentPUBag.RemoveAt(0);

        //If there is already an inactive enemy of the same type, active it and jump out
        for (int i = 0; i < inactivePU.Count; i++)
        {
            if (inactivePU [i].GetType() == newPU.GetType())
            {
                newPU = inactivePU [i];
                activePU.Add(newPU);
                inactivePU.RemoveAt(i);
                newPU.Reset();
                return;
            }
        }

        //If we make it through the for loop, that means we need to make a new enemy of that type
        GameObject newPUObj = (GameObject)Instantiate(newPU.gameObject);

        //This is a bit weird, but we want to change what this is pointing to from the prefab to the new instance
        newPU = newPUObj.GetComponent <PowerUpBaseClass>();

        allPU.Add(newPU);
        activePU.Add(newPU);
//		newEnemy.Reset (); //probably don't want this, should just use Awake
    }
Exemplo n.º 3
0
    public void GotPowerup(PowerUpBaseClass powerUp)
    {
        System.Type powerUpType = powerUp.GetType();

        if (powerUpType.Equals(typeof(BrightenPowerUp)))
        {
            InitBrighten();
        }
        else if (powerUpType.Equals(typeof(DestroyAllPowerUp)))
        {
            DestroyAllEnemies();
        }
        else if (powerUpType.Equals(typeof(HealthBackPowerUp)))
        {
            GetHealthBack();
        }
        else if (powerUpType.Equals(typeof(ShieldPowerUp)))
        {
            ActivateShield();
        }
        else
        {
            Debug.LogWarning("This powerup type hasn't been added to the handler! " + powerUpType);
        }
    }