예제 #1
0
        public void Attack(MonsterAbstract a, MonsterAbstract b)
        {
            if (a.CurrentState == MonsterState.Hostile || b.CurrentState == MonsterState.Hostile)
            {
                Console.WriteLine(a.Name + " is attacking " + b.Name + "!!!!");

                if (a.Damage < b.Hitpoints)
                {
                    double newHitpoints = a.Hitpoints -= b.Damage;
                    b.Hitpoints = newHitpoints;

                    Console.WriteLine(b.Name + " has taken " + a.Damage + " damage!");
                    Console.WriteLine(b.Name + " has " + b.Hitpoints + " hp left!");
                }
                else if (a.Damage > b.Hitpoints)
                {
                    b.Hitpoints = 0;

                    Console.WriteLine(b.Name + " Died!");
                }
            }
            else if (a.CurrentState == MonsterState.Neutral && b.CurrentState == MonsterState.Neutral)
            {
                Console.WriteLine("Oh sorry to bother you!");
            }
        }
예제 #2
0
 public void InteractCreature(MonsterAbstract monster)
 {
     if (monster.Position == Position && Name != monster.Name)
     {
         if (monster.CurrentState == MonsterState.Hostile)
         {
             Attack(this, monster);
         }
         else if (monster.CurrentState == MonsterState.Neutral)
         {
             Console.WriteLine("Hello, my name is " + monster.Name);
         }
     }
 }