private void setColor(Bitmap bitmap, Coordinates coords, Color player1Color, Color player2Color, Player player1) { if (player1 == null || player1 == game.Player1) { bitmap.SetPixel(coords.X, coords.Y, player1Color); } else { bitmap.SetPixel(coords.X, coords.Y, player2Color); } }
public bool Equals(Coordinates coords) { return coords != null && X == coords.X && Y == coords.Y; }
public bool isInRange(int range, Coordinates c) { return Math.Abs(c.X - X) <= range && Math.Abs(c.Y - Y) <= range; }
/// <summary> /// Lässt die Einheit diagonal nach rechts oben bewegen. /// </summary> /// <returns>true wenn das Bewegen erfolgreich war, false wenn etwas im Weg ist.</returns> public bool moveUpperRight() { Coordinates newCoords = new Coordinates(Coords.X + 1, Coords.Y - 1); return move(newCoords); }
private bool move(Coordinates to) { if (!canMove()) { die(); } else if (!TookAction && board.BoardObjects.move(this, to)) { TookAction = true; UnitsGone++; return true; } return false; }
/// <summary> /// Lässt die Einheit nach oben bewegen /// </summary> /// <returns>true wenn das Bewegen erfolgreich war, false wenn etwas im Weg ist</returns> public bool moveUp() { Coordinates newCoords = new Coordinates(Coords.X, Coords.Y - 1); return move(newCoords); }
/// <summary> /// Lässt die Einheit diagonal nach links oben bewegen. /// </summary> /// <returns>true wenn das Bewegen erfolgreich war, false wenn etwas im Weg ist.</returns> public bool moveUpperLeft() { Coordinates newCoords = new Coordinates(Coords.X - 1, Coords.Y - 1); return move(newCoords); }
private void nullTick(Player player, Coordinates baseCoords) { Base b = new Base(player); b.Coords = baseCoords; if (!BoardObjects.add(b)) { throw new RuntimeException("Could not add base"); } player.AI.nextTick(); }
/// <summary> /// Lässt die Einheit nach unten bewegen /// </summary> /// <returns>true wenn das Bewegen erfolgreich war, false wenn etwas im Weg ist</returns> public bool moveDown() { Coordinates newCoords = new Coordinates(Coords.X, Coords.Y + 1); return move(newCoords); }
private void addBoardObjectsToArrayForPartCoordinates(Coordinates coords, Coordinates current, int viewrange, ref BoardObject[] result) { int x1 = coords.X; int x2 = Math.Abs(x1); int y1 = coords.Y; int y2 = Math.Abs(y1); viewrange++; if (coords.X == 0 && coords.Y == 0) { mergeWithoutAnt(x1 + current.X, y1 + current.Y, ref result); // middle return; } merge(x1 + current.X, y1 + current.Y, ref result); // upper left if (coords.X == 0) { merge(current.X, y2 + current.Y, ref result); // middle horizontal return; } if (coords.Y == 0) { merge(x2 + current.X, current.Y, ref result); // middle vertical return; } merge(x2 + current.X, y1 + current.Y, ref result); // upper right merge(x1 + current.X, y2 + current.Y, ref result); // lower left merge(x2 + current.X, y2 + current.Y, ref result); // lower right }
private BoardObject[] getBoardObjectsInView(Coordinates antCoords, int viewRange) { BoardObject[] result = new BoardObject[0]; Coordinates[] coords = CircleCalculator.calculatePartCircle(viewRange); for (int i = 0;i < coords.Length;i++) { addBoardObjectsToArrayForPartCoordinates(coords[i], antCoords, viewRange, ref result); } return result; }
/// <summary> /// </summary> /// <returns>true wenn das BoardObject gemoved wurde andernfalls false.</returns> public bool move(BoardObject obj, Coordinates coords) { if (!isValidCoords(coords) || containsType(getBoardObjectsFromCoords(coords.X, coords.Y), obj)) { return false; } removeFromMap(obj); obj.Coords = coords; addToMap(obj); return true; }
/// <returns>true wenn die Koordinaten nicht außerhalb des Spielfeldes sind.</returns> public bool isValidCoords(Coordinates coords) { return isValidCoords(coords.X, coords.Y); }
/// <summary> /// Überprüft ob Zucker auf den Koordinaten sind. /// </summary> /// <param name="coords">Die Koordinaten</param> /// <returns>true wenn Zucker auf den Koordinaten liegt</returns> public bool hasSugarOnCoords(Coordinates coords) { foreach (BoardObject obj in getBoardObjectsFromCoords(coords)) { if (obj.isSugar()) { return true; } } return false; }
/// <summary> /// </summary> /// <param name="coords">Die Koordinaten</param> /// <param name="sugar">out den Zucker der gefunden wurde oder null</param> /// <returns>true wenn Zucker gefunden wurde</returns> public bool getSugar(Coordinates coords, out Sugar sugar) { BoardObject[] objs = getBoardObjectsFromCoords(coords); for (int i = 0; i < objs.Length; i++) { BoardObject boardObject = objs[i]; if (boardObject.isSugar()) { sugar = (Sugar) boardObject; return true; } } sugar = null; return false; }
public BoardObject[] getBoardObjectsFromCoords(Coordinates coords) { return getBoardObjectsFromCoords(coords.X, coords.Y); }