Beispiel #1
0
        public String HeroAttacks(Character.Movement Move)
        {
            Hero h      = map.getHero();
            Tile Target = new EmptyTile(0, 0);

            switch (Move)
            {
            case Character.Movement.Up:
                Target = map.getMap()[h.getY() - 1, h.getX()];
                break;

            case Character.Movement.Down:
                Target = map.getMap()[h.getY() + 1, h.getX()];
                break;

            case Character.Movement.Left:
                Target = map.getMap()[h.getY(), h.getX() - 1];
                break;

            case Character.Movement.Right:
                Target = map.getMap()[h.getY(), h.getX() + 1];
                break;
            }

            if (Target is Enemy)
            {
                h.Attack((Character)Target);
                Character c_Target = (Character)Target;

                if (c_Target.IsDead())
                {
                    map.removeTile(c_Target);
                }

                moveEnemies();

                if (!c_Target.IsDead())
                {
                    return("1" + c_Target.ToString());
                }
                else
                {
                    return("The enemy is dead");
                }
            }
            else
            {
                return("0");
            }
        }
 private void generateEmptyMap()
 {
     for (int i = 0; i < Height; ++i)
     {
         for (int k = 0; k < Width; ++k)
         {
             if (i == 0 || i == (Height - 1))
             {
                 map[i, k] = new Obstacle(i, k);
             }
             else if (k == 0 || k == (Width - 1))
             {
                 map[i, k] = new Obstacle(i, k);
             }
             else
             {
                 map[i, k] = new EmptyTile(i, k);
             }
         }
     }
 }
Beispiel #3
0
        public string HeroAttacks(Character h, Character.Movement dir, Tile t)
        {
            Tile target = new EmptyTile(0, 0);

            switch (dir)
            {
            case Character.Movement.Up:
                target = map.getMap()[h.getY() - 1, h.getX()];
                break;

            case Character.Movement.Down:
                target = map.getMap()[h.getY() + 1, h.getX()];
                break;

            case Character.Movement.Left:
                target = map.getMap()[h.getY(), h.getX() - 1];
                break;

            case Character.Movement.Right:
                target = map.getMap()[h.getY(), h.getX() + 1];
                break;

            default:
                target = t;
                break;
            }


            if ((h is Hero && target is Enemy && !h.IsDead()) || (h is Goblin && target is Hero) || (h is Mages && target is Character))
            {
                h.Attack((Character)target);
                Character c_target = (Character)target;

                if (c_target.IsDead())
                {
                    map.removeTile(c_target);
                }


                if (h is Hero)
                {
                    enemyAttacks();
                    if (!c_target.IsDead())
                    {
                        return("1" + c_target.ToString());
                    }
                    else
                    {
                        return("1The enemy is dead");
                    }
                }
                else
                {
                    return("");
                }
            }
            else
            {
                return("0");
            }
        }