Esempio n. 1
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();
        }
Esempio n. 2
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);
        }
Esempio 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;
            }
        }