Ejemplo n.º 1
0
        /// <summary>
        /// Initialize all registered TurnTakers to begin ticking.
        /// </summary>
        private void InitializeTickingEntities()
        {
            tickingEntities = new Queue <ITurnTaker>(turnTakers.Count);

            for (int i = 0; i < turnTakers.Count; i++)
            {
                ITurnTaker turnTaker = turnTakers[i];
                turnTaker.SetTickState(TurnTakerState.WAITING);
                tickingEntities.Enqueue(turnTaker);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Process all the currently registered TurnTakers.
        /// </summary>
        private void ProcessTickingEntities(float delta)
        {
            Queue <ITurnTaker> tickedEntities = new Queue <ITurnTaker>();

            while (tickingEntities.Count > 0)
            {
                ITurnTaker turnTaker = tickingEntities.Dequeue();
                if (turnTaker.GetTickState() == TurnTakerState.WAITING)
                {
                    turnTaker.InitTick();
                    turnTaker.SetTickState(TurnTakerState.TICKING);
                    tickedEntities.Enqueue(turnTaker);
                }
                else if (turnTaker.GetTickState() == TurnTakerState.TICKING)
                {
                    turnTaker.Tick(delta);
                    tickedEntities.Enqueue(turnTaker);
                }
            }

            tickingEntities = tickedEntities;
        }