• cookie_sabotage@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    3
    ·
    6 months ago
    public class GameManager : MonoBehaviour
    {
        public bool EnableHighContrast;
        public bool PlayerWon;
        public float PlayerUnitsMoved;
        public int PlayerDeathCount;
        public float PlayerHealth;
    
        public void PlayerTakeDamage(float damage)
        {
            PlayerHealth -= damage;
            if (PlayerHealth < 0)
            {
                PlayerDieAndRespawn();
            }
        }
    
        public void PlayerDieAndRespawn()
        {
            return;
        }
    }
    

    I couldn’t contain myself.

    • Wise@feddit.uk
      link
      fedilink
      English
      arrow-up
      0
      ·
      6 months ago

      Should it be

      PlayerHealth <= 0
      

      ?

      Otherwise the player could have 0 health and not die? I’m sleep deprived so forgive me if I’m wrong

      • vithigar@lemmy.ca
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        6 months ago

        You are correct about it allowing you to have zero health and not die, but whether or not that’s the correct behavior will depend on the game. Off the top of my head I know that Street Fighter, some versions at least, let you cling to life at zero.