Exemplo n.º 1
0
        private void AddRemainderOffscreen(ChildObjectCreateMethod factoryMethod, int maxCreateCount, int createdCount)
        {
            var remainderCount = maxCreateCount - createdCount;

            for (var count = 0; count < remainderCount; count++)
            {
                _offScreenObjects.Add(new OffscreenQueueObject
                {
                    DistanceToWait = GenerateDistance(),
                    Object         = factoryMethod(new Position(0, 0))
                });
            }
        }
Exemplo n.º 2
0
        private void CreateQueueObjects(ChildObjectCreateMethod factoryMethod, int maxCreateCount)
        {
            var createdCount = 0;

            var xpos = (int)Position.XPos;

            do
            {
                CreateQueueObject(factoryMethod, xpos);

                if (++createdCount >= maxCreateCount)
                {
                    return;
                }
            } while (EnumerateXPosRange(ref xpos));

            AddRemainderOffscreen(factoryMethod, maxCreateCount, createdCount);
        }
Exemplo n.º 3
0
        private void CreateQueueObject(ChildObjectCreateMethod factoryMethod, int xPos)
        {
            var newObject = factoryMethod(new Position(xPos, Position.YPos));

            ChildObjects.Add(newObject);
        }
Exemplo n.º 4
0
        /// <param name="intitialPosition">Only the YPos of the Position is used. The vertical position of the queue on the screeen.</param>
        /// <param name="initialDirection">The direction all objects in the queue are traveling.</param>
        /// <param name="moveSpeed">The horizontal distance all object of the queue will travel each frame that is rendered.</param>
        /// <param name="childCreateMethod">The factory method that will create the objects managed by this queue.</param>
        /// <param name="numQueueObjects">The maximum number of objects the queue can create and manage.</param>
        /// <param name="winConditions">Used to determine if this object has won the game.</param>
        protected GameObjectQueue(Position intitialPosition, Direction initialDirection, int moveSpeed, ChildObjectCreateMethod childCreateMethod, int numQueueObjects, IWinCondition[] winConditions)
            : base(intitialPosition, new NullRenderer(), initialDirection, moveSpeed, winConditions)
        {
            _offScreenObjects = new List <OffscreenQueueObject>();
            _numGenerator     = new Random();

            CreateQueueObjects(childCreateMethod, numQueueObjects);
        }
Exemplo n.º 5
0
 public GameObjectQueueRight(int yPos, int moveSpeed, ChildObjectCreateMethod childCreateMethod, int numQueueObjects, IWinCondition[] winConditions)
     : base(new Position(GameConfig.LEFT_OFFSCREEN_X_POS, yPos), Direction.Right, moveSpeed, childCreateMethod, numQueueObjects, winConditions)
 {
 }