Exemplo n.º 1
0
 public void IncreaseStat(BasicAgent agent)
 {
     Debug.Log("Increasing stats!");
     if (uses > 0)
     {
         if (isEnergyPotion)
         {
             agent.GetComponentInChildren <EnergyController> ().ChangeEnergy(increaseAmount);
         }
         else
         {
             agent.Heal(increaseAmount);
         }
         uses--;
         if (uses > 0)
         {
             evt_usePotion.Invoke(isEnergyPotion);
         }
         else
         {
             evt_outOfPotions.Invoke(isEnergyPotion);
         }
         if (healthBar != null)
         {
             healthBar.currentHealth = (float)uses;
         }
         ;
     }
     ;
 }
Exemplo n.º 2
0
    public void TriggerActivate(GameObject trg)
    {
        BasicAgent agent = trg.GetComponent <BasicAgent> ();

        Debug.Log("Agent >" + agent);
        if (agent != null)
        {
            // We only do it if they aren't at full health/energy
            if (isEnergyPotion)
            {
                EnergyController ctrl = agent.GetComponentInChildren <EnergyController> ();
                Debug.Log("Energycontroller >" + ctrl);
                if (ctrl != null)
                {
                    if (ctrl.currentEnergy < ctrl.minMaxEnergy.y)
                    {
                        IncreaseStat(agent);
                    }
                }
            }
            else
            {
                if (agent.currentHealth < agent.healthMinMax.y)
                {
                    IncreaseStat(agent);
                }
            }
        }
    }