private void AddToRenderQueue(Page page)
        {
            RenderQueueEntry entry = new RenderQueueEntry(this, page);

            renderQueue.Add(entry);

            // The just-added entry could (possibly) resolve the waiting entries,
            // so we try to process the queue now to see.
            ProcessQueue(false);
        }
        /// <summary>
        ///     Try to process the queue from the first entry forward.  If an
        ///     entry can't be processed, then the queue can't move forward,
        ///     so return.
        /// </summary>
        /// <param name="force"></param>
        private void ProcessQueue(bool force)
        {
            while (renderQueue.Count > 0)
            {
                RenderQueueEntry entry = (RenderQueueEntry)renderQueue[0];
                if ((!force) && (!entry.isResolved()))
                {
                    break;
                }

                renderer.Render(entry.getPage());
                renderQueue.RemoveAt(0);
            }
        }
        // TODO: Return collection of render commands
        // TODO: Add try/catch statement?
        public RenderQueueEntry[] Execute(Actor source, IEnumerable <Actor> friendlyParty, IEnumerable <Actor> enemyParty)
        {
            var rqes = new List <RenderQueueEntry>();

            var playerReadyEntry = new RenderQueueEntry()
            {
                TargetCardIds = new[] { source.CardId },
                Animation     = "ReadyAttack"
            };

            rqes.Add(playerReadyEntry);

            var targetIds = new List <short>();

            foreach (var effect in Effects)
            {
                var newTargets = Targeters[effect.Targeter](friendlyParty, enemyParty);

                foreach (var newTarget in newTargets)
                {
                    if (newTarget != null)
                    {
                        targetIds.Add(AppliedEffects[effect.AppliedEffect](source, newTarget));
                    }
                }

                var newRQE = new RenderQueueEntry()
                {
                    TargetCardIds = targetIds.ToArray(),
                    Animation     = effect.Animation
                };

                rqes.Add(newRQE);
            }

            return(rqes.ToArray());
        }
Esempio n. 4
0
        private void AddToRenderQueue(Page page)
        {
            RenderQueueEntry entry = new RenderQueueEntry(this, page);
            renderQueue.Add(entry);

            // The just-added entry could (possibly) resolve the waiting entries, 
            // so we try to process the queue now to see.
            ProcessQueue(false);
        }