Exemplo n.º 1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player")
     {
         th = other.gameObject.GetComponent <TankHealth>();
         th.AddHP(50);
         th.SetHealthUI();
         Destroy(gameObject);
         GameObject effect = (GameObject)Instantiate(effectPrefab, transform.position, Quaternion.identity);
         Destroy(effect, 0.7f);
     }
 }
Exemplo n.º 2
0
    void OnTriggerStay(Collider other)
    {
        if (other.CompareTag("Player") || other.CompareTag("AI"))
        {
            TankHealth script = other.GetComponent <TankHealth>();
            //Debug.Log(script.m_CurrentHealth);
            if (script.m_CurrentHealth < 100)
            {
                script.m_CurrentHealth += Mathf.Max(.15f, Mathf.Pow((100 - script.m_CurrentHealth) / 100, 2));
            }
            else
            {
                script.m_CurrentHealth = 100;
            }

            script.SetHealthUI();
        }
    }
Exemplo n.º 3
0
    /// <summary>
    /// Acts as a med pack for the player, recovers lost health and caps at their max health
    /// </summary>
    private void BonusHealth()
    {
        TankHealth th = _rb.GetComponent <TankHealth>();

        if (th.GetHealth() == th.m_StartingHealth)
        {
            return;
        }

        th.AddHealth(_healthAdd);
        if (th.GetHealth() > th.m_StartingHealth)
        {
            th.SetHealth(th.m_StartingHealth);
        }
        th.SetHealthUI();

        Destroy(gameObject);
    }