CastleGame.Enemies.Enemy.receiveDamage C# (CSharp) Method

receiveDamage() public method

public receiveDamage ( Weapon weapon ) : void
weapon Weapon
return void
        public void receiveDamage(Weapon weapon)
        {
            health -= weapon.damageToEnemy;
        }

Usage Example

示例#1
0
        protected void attack(Enemy enemy, Weapon weapon)
        {
            playerone.currentRoom.battle.steps++;
            enemy.receiveDamage(weapon);
            playerone.receiveDamage(enemy, weapon);

            if (playerone.health > 0)
            {
                Console.WriteLine("You are now at " + playerone.health + "HP");
            }

            if (enemy.health > 0)
            {
                Console.WriteLine("Enemy " + enemy.name + " is now at " + enemy.health + "HP\n\n");
                printFleeText();
            } else {
                Console.WriteLine("The enemy " + enemy.name + " is dead!");
                playerone.currentRoom.battle.enemies.Remove(enemy);
                Console.WriteLine("You can now continue your journey in this castle.");
                printRoomInfo = true;
            }
        }