Ejemplo n.º 1
0
    public void RecieveDamage(Player source)
    {
        // Hitting enemy team (damage)
        if (source.team == Team.Blue && team == Team.Red ||
            source.team == Team.Red && team == Team.Blue)
        {
            float damage = source.shoot.damage;

            if (currLife - damage <= 0)
            {
                if (source.team == Team.Red)
                {
                    score.AddRedScore();
                }
                if (source.team == Team.Blue)
                {
                    score.AddBlueScore();
                }

                ResetPlayer();
            }
            else
            {
                currLife -= damage;
            }
        }

        // Hitting teammate(heal)
        else
        {
            float damage = source.heal.damage;

            if (currLife + damage <= player.maxLife)
            {
                currLife += damage;
            }
            else
            {
                currLife = player.maxLife;
            }
        }

        info.UpdateLifeUI(currLife, player.maxLife);
    }