IEnumerator MainPhase(Phase phase)
    {
        bool isActionCancelled = phase.owner.isCanceled;
        bool isCancelPhase     = phase.owner.cancel == phase;

        if (isActionCancelled ^ isCancelPhase) // Logical exclusive-OR
        {
            yield break;
        }

        var reactions = openReactions = new List <GameAction>();

        var flow = phase.Flow(container);

        while (flow.MoveNext())
        {
            yield return(null);
        }

        flow = ReactPhase(reactions);
        while (flow.MoveNext())
        {
            yield return(null);
        }
    }
示例#2
0
    public void PhaseTriggersHandlerWithoutKeyFrame()
    {
        var action = new TestAction(10, -1);
        var phase  = new Phase(action, action.KeyFrameHandler);

        phase.viewer = action.KeyFrameViewer;

        var flow = phase.Flow(null);

        while (flow.MoveNext())
        {
        }
        Assert.IsTrue(action.isComplete);
    }
示例#3
0
    public void PhaseRunsCompleteViewerFlow()
    {
        var action = new TestAction(10, 5);
        var phase  = new Phase(action, action.KeyFrameHandler);

        phase.viewer = action.KeyFrameViewer;

        var flow = phase.Flow(null);

        while (flow.MoveNext())
        {
        }
        Assert.AreEqual(action.step, action.loopCount);
    }
示例#4
0
        public void RunningPhaseWithoutKeyframe_HandlerIsTriggered()
        {
            var action = new TestAction(10, -1);
            var phase  = new Phase(action, action.KeyFrameHandler)
            {
                Viewer = action.KeyframeViewer
            };

            var flow = phase.Flow(null);

            while (flow.MoveNext())
            {
            }

            Assert.IsTrue(action.IsComplete);
        }
示例#5
0
        public void RunningPhase_CompletesViewerFlow()
        {
            var action = new TestAction(10, 5);
            var phase  = new Phase(action, action.KeyFrameHandler)
            {
                Viewer = action.KeyframeViewer
            };

            var flow = phase.Flow(null);

            while (flow.MoveNext())
            {
            }

            Assert.AreEqual(action.Step, action.LoopCount);
        }
示例#6
0
    public void PhaseTriggersOnKeyFrame()
    {
        var action = new TestAction(10, 5);
        var phase  = new Phase(action, action.KeyFrameHandler);

        phase.viewer = action.KeyFrameViewer;

        var flow = phase.Flow(null);

        while (flow.MoveNext())
        {
            if (action.step < action.keyframe)
            {
                Assert.IsFalse(action.isComplete);
            }
            else if (action.step > action.keyframe)
            {
                Assert.IsTrue(action.isComplete);
            }
        }
    }
示例#7
0
        public void RunningPhaseWithKeyframe_HandlerIsTriggeredOnKeyframe()
        {
            var action = new TestAction(10, 5);
            var phase  = new Phase(action, action.KeyFrameHandler)
            {
                Viewer = action.KeyframeViewer
            };

            var flow = phase.Flow(null);

            while (flow.MoveNext())
            {
                if (action.Step < action.Keyframe)
                {
                    Assert.IsFalse(action.IsComplete);
                }
                else if (action.Step > action.Keyframe)
                {
                    Assert.IsTrue(action.IsComplete);
                }
            }
        }
示例#8
0
        private IEnumerator MainPhase(Phase phase)
        {
            if (phase.Owner.IsCanceled ^ phase == phase.Owner.CancelPhase)
            {
                yield break;
            }

            var reactions = _openReactions = new List <GameAction>();

            var flow = phase.Flow(Container);

            while (flow.MoveNext())
            {
                yield return(null);
            }

            flow = ReactPhase(reactions);
            while (flow.MoveNext())
            {
                yield return(null);
            }
        }