コード例 #1
0
 public void AddPowerUp(HeroPowerUp powerUp)
 {
     powerUp.Activate(hero);
     numActivePowerUps++;
     // Send event
     if (OnPowerUpAdded != null)
     {
         OnPowerUpAdded();
     }
 }
コード例 #2
0
    public void AddPowerUp(string name)
    {
        HeroPowerUp selectedPowerUp = GetPowerUp(name).GetComponent <HeroPowerUp> ();

        //print("Got power up:" + selectedPowerUp.gameObject);
        // test if this hero already has the selected power up
        if (selectedPowerUp.isActive)
        {
            //print("Stacking...");
            selectedPowerUp.Stack();
        }
        else
        {
            //print("Power up not active. Activating...");
            selectedPowerUp.gameObject.SetActive(true);
            selectedPowerUp.Activate(hero);
            numActivePowerUps++;
        }
        // send event
        if (OnPowerUpAdded != null)
        {
            OnPowerUpAdded();
        }
    }