Пример #1
0
 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);
     }
 }
Пример #2
0
 public bool Equals(Coordinates coords)
 {
     return coords != null && X == coords.X && Y == coords.Y;
 }
Пример #3
0
 public bool isInRange(int range, Coordinates c)
 {
     return Math.Abs(c.X - X) <= range && Math.Abs(c.Y - Y) <= range;
 }
Пример #4
0
 /// <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);
 }
Пример #5
0
 private bool move(Coordinates to)
 {
     if (!canMove()) {
         die();
     } else if (!TookAction && board.BoardObjects.move(this, to)) {
         TookAction = true;
         UnitsGone++;
         return true;
     }
     return false;
 }
Пример #6
0
 /// <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);
 }
Пример #7
0
 /// <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);
 }
Пример #8
0
        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();
        }
Пример #9
0
 /// <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);
 }
Пример #10
0
        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
        }
Пример #11
0
        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;
        }
Пример #12
0
 /// <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;
 }
Пример #13
0
 /// <returns>true wenn die Koordinaten nicht außerhalb des Spielfeldes sind.</returns>
 public bool isValidCoords(Coordinates coords)
 {
     return isValidCoords(coords.X, coords.Y);
 }
Пример #14
0
 /// <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;
 }
Пример #15
0
 /// <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;
 }
Пример #16
0
 public BoardObject[] getBoardObjectsFromCoords(Coordinates coords)
 {
     return getBoardObjectsFromCoords(coords.X, coords.Y);
 }