예제 #1
0
    private void AttackClosestMob()
    {
        if (Mobs.Count < 2)
        {
            return;
        }

        OwnerMob.Log("choosing closest mob");

        Mob   closestMob = null;
        float distance   = float.MaxValue;

        foreach (Mob mob in Mobs)
        {
            if (mob == OwnerMob || mob.IsDead())
            {
                continue;
            }

            float distanceToMob = OwnerMob.Position.DistanceTo(mob.Position);
            if (distanceToMob < distance)
            {
                distance   = distanceToMob;
                closestMob = mob;
            }
        }

        if (closestMob != null)
        {
            OwnerMob.AttackMob(closestMob);
        }
    }
예제 #2
0
 public void AttackHero(Mob hero, int position)
 {
     if (position == Position)
     {
         Console.WriteLine($"Mario meet monster on {Position}");
         hero.AttackMob(this);
         //this.AttackMob(hero);
     }
 }
예제 #3
0
파일: Game.cs 프로젝트: itlbv/evo
    public void RightCLickOnMob(Mob mobClicked)
    {
        if (SelectedMob == null ||
            SelectedMob == mobClicked ||
            SelectedMob.IsDead())
        {
            return;
        }

        SelectedMob.AttackMob(mobClicked);
    }