예제 #1
0
 private bool containsType(IList <BoardObject> objs, BoardObject objectToCheck)
 {
     foreach (BoardObject obj in objs)
     {
         if (obj == null)
         {
             continue;
         }
         // the OR is a workaround due to Carry != Scout in type so we use our isAnt() method
         if (obj.GetType() == objectToCheck.GetType() || (obj.isAnt() && objectToCheck.isAnt()))
         {
             return(true);
         }
     }
     return(false);
 }
예제 #2
0
 private void mergeWithoutAnt(int x, int y, ref BoardObject[] result)
 {
     BoardObject[] boardObjectsFromCoords = BoardObjects.getBoardObjectsFromCoords(x, y).Clone() as BoardObject[];
     if (boardObjectsFromCoords.Length - 1 != 0)
     {
         for (int i = 0; i < boardObjectsFromCoords.Length; i++)
         {
             BoardObject obj = boardObjectsFromCoords[i];
             if (obj.isAnt())
             {
                 ArrayUtils.remove(ref boardObjectsFromCoords, obj);
                 break;
             }
         }
         ArrayUtils.merge(ref result, boardObjectsFromCoords);
     }
 }
예제 #3
0
 /// <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);
 }
예제 #4
0
        /// <summary>
        /// Benachrichtigt andere Ameisen.
        /// </summary>
        /// <param name="coords">Die Koordinaten welche den anderen Ameisen mitgeteilt werden soll</param>
        /// <param name="ant">Die Ameise welche mitteilt</param>
        public void notifyAnts(HashSet <Coordinates> coords, Ant ant)
        {
            BoardObject[] objs = getBoardObjectsInView(ant.Coords, ant.ViewRange * 2);
            for (int i = 0; i < objs.Length; i++)
            {
                BoardObject obj = objs[i];
                if (obj == ant)
                {
                    continue;
                }

                if (obj.isAnt())
                {
                    Ant antToNotify = obj as Ant;
                    antToNotify.AI.notify(coords);
                }
            }
        }
예제 #5
0
        /// <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;
        }
예제 #6
0
        /// <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);
        }
예제 #7
0
 private bool containsType(IList<BoardObject> objs, BoardObject objectToCheck)
 {
     foreach (BoardObject obj in objs) {
         if (obj == null)
             continue;
         // the OR is a workaround due to Carry != Scout in type so we use our isAnt() method
         if (obj.GetType() == objectToCheck.GetType() || (obj.isAnt() && objectToCheck.isAnt())) {
             return true;
         }
     }
     return false;
 }
예제 #8
0
 /// <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);
 }