Exemplo n.º 1
0
 /// <summary>
 /// Takes the damage.
 /// </summary>
 /// <param name="amount">Amount.</param>
 public void TakeDamage(byte amount)
 {
     if (amount >= this.Health)
     {
         GameObjectGrid.KillObject(this.gameObject);
     }
     else
     {
         this.Health = (byte)(this.Health - amount);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Takes the damage.
        /// </summary>
        /// <param name="amount">Amount.</param>
        public void TakeDamage(int amount)
        {
            if (amount <= 0)
            {
                return;
            }

            try
            {
                this.Health.Value = checked (this.Health.Value - amount);
            }
            catch (OverflowException)
            {
                this.Health.Value = int.MinValue;
            }

            if (this.Health.Value <= 0)
            {
                GameObjectGrid.KillObject(this.gameObject);
            }
        }