Example #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (cooldownTimer <= 0)
        {
            print("COLLIDING");
            switch (collision.tag)
            {
            case "Hostile":
                var player = transform.parent.GetComponent <BattlePlayer>();

                // Damaging player [consider battle dmg depending on entity or if player wearing armor / defense]
                print("HOSTILE!!!");
                player.SetHP(player.GetHP() - 1);
                HP1UP.MakeAt("-1", player.transform.position, Color.red);
                SFXManager.ResetSFX("PlayerHit");

                // Updating the HP UI box
                player.UpdateHPUI();

                // Resetting cooldown
                cooldownTimer = cooldown;
                break;
            }
        }
    }
Example #2
0
 public static void Heal(int hpToHeal)
 {
     HP1UP.MakeAt(hpToHeal + "+", BattlePlayer.player.transform.position, Color.green);
     hp += hpToHeal;
     if (hp > maxHp)
     {
         hp = maxHp;             // So that hp doesn't go over the limit.
     }
     BattlePlayer.player.UpdateHPUI();
 }
Example #3
0
    public void DamageFeedback(int hpDec)
    {
        HP1UP.MakeAt(hpDec + "-", transform.position, Color.red);
        int newHp = (int)hp - hpDec;

        if (newHp < 1)
        {
            newHp = 1;
        }
        hpbox.SetHP(newHp, startHP);
    }