コード例 #1
0
        public void TakeDamage(int damage)
        {
            if (_accessory != null)
            {
                _accessory.Health -= damage;
                var temp = _accessory.Health;                         //temp health for leftover damage

                if (_accessory.Health <= 0 && _accessory.Type == "R") //dead zombie
                {
                    Die();
                }
                else if (_accessory.Health <= 50 && _accessory.Type != "R") //become regular zombie if health is below 50 (regular zombie max health)
                {
                    _accessory        = AccessoryFactory.GetAccessory("1");
                    _accessory.Health = temp;
                    Console.Write(" Becoming Regular zombie.");
                }
            }
        }
コード例 #2
0
 public Zombie(string accessoryType)
 {
     isAlive    = true;
     health     = 50;
     _accessory = AccessoryFactory.GetAccessory(accessoryType);
 }