Пример #1
0
 public bool LeftTwo(Coords pos)
 {
     bool canGo = true;
     Position.X = pos.X;
     for (int i = 0; i < checkfld; i++)
     {
         if (Position.X > 0)
         {
             Position.X = Position.X - 1;
             Position.Y = pos.Y;
             if (Map.MapArray[Position.X, Position.Y] != null)
             {
                 if (Map.MapArray[Position.X, Position.Y].OwnerId == -1 && canGo == true)
                 {
                     canGo = true;
                 }
                 else
                 {
                     canGo = false;
                 }
             }
         }
         else
         {
             canGo = false;
         }
     }
     return canGo;
 }
Пример #2
0
 public bool Left(Coords pos)
 {
     if (pos.X > 0)
     {
         Position.X = pos.X - 1;
         Position.Y = pos.Y;
         if (Map.MapArray[Position.X, Position.Y] != null)
         {
             if (Map.MapArray[Position.X, Position.Y].OwnerId == -1)
                 return true;
         }
     }
     return false;
 }
Пример #3
0
 public bool Down(Coords pos)
 {
     if (pos.Y < 19)
     {
         Position.X = pos.X;
         Position.Y = pos.Y + 1;
         if (Map.MapArray[Position.X, Position.Y] != null)
         {
             if (Map.MapArray[Position.X, Position.Y].OwnerId == -1)
                 return true;
         }
     }
     return false;
 }
Пример #4
0
        public static string GetOrientation(Coords my, Enemy enemy)
        {
            string where = "";

            var enemyCords = GetNextCell(enemy.LastPosition, enemy.Position);

            if (my.X < enemyCords.X)
            {
                where = Move.Right;
            }
            else if (my.X > enemyCords.X)
            {
                where = Move.Left;
            }
            else if (my.Y < enemyCords.Y)
            {
                where = Move.Down;
            }
            else if (my.Y > enemyCords.Y)
            {
                where = Move.Up;
            }

            return where;
        }
Пример #5
0
        public static Coords GetNextCell(Coords prevCoords, Coords currCoords)
        {
            Coords where = currCoords;
            if (prevCoords == null)
                prevCoords = currCoords;
            if (prevCoords.X == currCoords.X)
            {
                where.X = currCoords.X;
                if (prevCoords.Y < currCoords.Y)
                {
                    where.Y = currCoords.Y + 1;
                }
                else
                {
                    where.Y = currCoords.Y - 1;
                }

            }
            else
            {
                where.Y = currCoords.Y;
                if (prevCoords.X < currCoords.X)
                {
                    where.X = currCoords.X + 1;
                }
                else
                {
                    where.X = currCoords.X - 1;
                }
            }

            return where;
        }
Пример #6
0
 public double GetDistance(Coords start, Coords end)
 {
     int y = end.Y - start.Y;
     int x = end.X - start.X;
     double dist = Math.Sqrt(x * x + y * y);
     return dist;
 }
Пример #7
0
 public Game()
 {
     MyId = -1;
     MyPosition = new Coords { X = -1, Y = -1 };
     Targets = new List<Enemy>(3);
 }