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; }
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; }
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; }
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; }
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; }
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; }
public Game() { MyId = -1; MyPosition = new Coords { X = -1, Y = -1 }; Targets = new List<Enemy>(3); }