Exemplo n.º 1
0
        internal void killBoardObject(ControllableBoardObject obj)
        {
            Ant ant = (obj as Ant);

            if (obj.isAnt() && ant.Inventory > 0)
            {
                Sugar s = new Sugar();
                s.Coords = ant.Coords;
                s.Amount = ant.Inventory;
                BoardObjects.add(s);
            }
            BoardObjects.remove(obj);
        }
Exemplo n.º 2
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);
 }
Exemplo n.º 3
0
        private void generateSugar(int min, int max)
        {
            Random rand      = new Random();
            int    boardArea = conf.BoardHeight * conf.BoardWidth;
            double factor    = Convert.ToDouble(rand.Next(min, max + 1)) / 100;
            int    count     = Convert.ToInt32(Math.Round(boardArea * factor));

            for (int i = 0; i < count; i++)
            {
                Sugar s = new Sugar();
                s.Coords = Utils.generateCoords(conf.BoardWidth, conf.BoardHeight);
                if (BoardObjects.hasBaseOnCoords(s.Coords) || BoardObjects.hasSugarOnCoords(s.Coords))
                {
                    i--;
                    continue;
                }
                s.Amount = rand.Next(conf.SugarAmountMin, conf.SugarAmountMax + 1);
                BoardObjects.add(s);
                SugarAmount += s.Amount;
            }
        }
Exemplo n.º 4
0
 private void generateSugar(int min, int max)
 {
     Random rand = new Random();
     int boardArea = conf.BoardHeight * conf.BoardWidth;
     double factor = Convert.ToDouble(rand.Next(min, max + 1)) / 100;
     int count = Convert.ToInt32(Math.Round(boardArea * factor));
     for (int i = 0;i < count;i++) {
         Sugar s = new Sugar();
         s.Coords = Utils.generateCoords(conf.BoardWidth, conf.BoardHeight);
         if (BoardObjects.hasBaseOnCoords(s.Coords) || BoardObjects.hasSugarOnCoords(s.Coords)) {
             i--;
             continue;
         }
         s.Amount = rand.Next(conf.SugarAmountMin, conf.SugarAmountMax + 1);
         BoardObjects.add(s);
         SugarAmount += s.Amount;
     }
 }
Exemplo n.º 5
0
 internal void killBoardObject(ControllableBoardObject obj)
 {
     Ant ant = (obj as Ant);
     if (obj.isAnt() && ant.Inventory > 0) {
         Sugar s = new Sugar();
         s.Coords = ant.Coords;
         s.Amount = ant.Inventory;
         BoardObjects.add(s);
     }
     BoardObjects.remove(obj);
 }
Exemplo n.º 6
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;
 }