/// <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); }
/// <summary> /// Entfernt ein BoardObject vom Spielfeld /// </summary> /// <param name="boardObject">Das Boardobject was gelöscht werden soll.</param> public void remove(BoardObject boardObject) { ArrayUtils.remove(ref boardObjects, boardObject); if (boardObject.isAnt()) { ants.Remove((Ant)boardObject); } else if (boardObject.isBase()) { bases.Remove((Base)boardObject); } else if (boardObject.isSugar()) { sugars.Remove((Sugar)boardObject); } removeFromMap(boardObject); }
/// <summary> /// Fügt ein BoardObject hinzu. /// </summary> /// <returns>true wenn er hinzugefügt wurde andernfalls false</returns> public bool add(BoardObject boardObject) { if (!addToMap(boardObject)) { return false; } ArrayUtils.add(ref boardObjects, boardObject); if (boardObject.isAnt()) { Ant ant = (Ant) boardObject; ants.Add(ant); ant.Owner.incrementAnts(ant); } else if (boardObject.isBase()) { bases.Add((Base) boardObject); } else if (boardObject.isSugar()) { sugars.Add((Sugar) boardObject); } return true; }
/// <summary> /// Fügt ein BoardObject hinzu. /// </summary> /// <returns>true wenn er hinzugefügt wurde andernfalls false</returns> public bool add(BoardObject boardObject) { if (!addToMap(boardObject)) { return(false); } ArrayUtils.add(ref boardObjects, boardObject); if (boardObject.isAnt()) { Ant ant = (Ant)boardObject; ants.Add(ant); ant.Owner.incrementAnts(ant); } else if (boardObject.isBase()) { bases.Add((Base)boardObject); } else if (boardObject.isSugar()) { sugars.Add((Sugar)boardObject); } return(true); }
private void setColor(BoardObject obj, Bitmap bitmap) { if (obj.isCarry()) { setColor(bitmap, obj.Coords, COLOR_PLAYER1_CARRY, COLOR_PLAYER2_CARRY, (obj as Ant).Owner); } else if (obj.isScout()) { setColor(bitmap, obj.Coords, COLOR_PLAYER1_SCOUT, COLOR_PLAYER2_SCOUT, (obj as Ant).Owner); } else if (obj.isWarrior()) { setColor(bitmap, obj.Coords, COLOR_PLAYER1_WARRIOR, COLOR_PLAYER2_WARRIOR, (obj as Ant).Owner); } else if (obj.isBase()) { Base playerbase = obj as Base; if (playerbase.RangeLevel > 0) { for (int i = 0;i < playerbase.RangeCoords.Count;i++) { setColor(bitmap, playerbase.RangeCoords[i], COLOR_PLAYER1_BASE, COLOR_PLAYER2_BASE, playerbase.Player); } } setColor(bitmap, obj.Coords, COLOR_PLAYER1_BASE, COLOR_PLAYER2_BASE, (obj as Base).Player); } else if (obj.isSugar()) { setColor(bitmap, obj.Coords, COLOR_GAME_SUGAR, Color.Transparent, null); } }
/// <summary> /// Entfernt ein BoardObject vom Spielfeld /// </summary> /// <param name="boardObject">Das Boardobject was gelöscht werden soll.</param> public void remove(BoardObject boardObject) { ArrayUtils.remove(ref boardObjects, boardObject); if (boardObject.isAnt()) { ants.Remove((Ant) boardObject); } else if (boardObject.isBase()) { bases.Remove((Base) boardObject); } else if (boardObject.isSugar()) { sugars.Remove((Sugar) boardObject); } removeFromMap(boardObject); }