コード例 #1
0
        public JParallel(params JFiniteTimeAction[] actions) : base()
        {
            // Can't call base(duration) because max action duration needs to be determined here
            float maxDuration = 0.0f;


            for (int i = 0; i < actions.Length; ++i)
            {
                var action = actions[i];
                if (action.Duration > maxDuration)
                {
                    maxDuration = action.Duration;
                }
            }


            Duration = maxDuration;

            Actions = actions;

            for (int i = 0; i < Actions.Length; i++)
            {
                var actionDuration = Actions [i].Duration;
                if (actionDuration < Duration)
                {
                    Actions [i] = new JSequence(Actions [i], new JDelayTime(Duration - actionDuration));
                }
            }
        }
コード例 #2
0
        public JSequence(params JFiniteTimeAction[] actions) : base()
        {
            Actions = new JFiniteTimeAction[2];

            var prev = actions [0];

            // Can't call base(duration) because we need to calculate duration here
            float combinedDuration = 0.0f;

            for (int i = 0; i < actions.Length; ++i)
            {
                var action = actions[i];
                combinedDuration += action.Duration;
            }

            Duration = combinedDuration;

            if (actions.Length == 1)
            {
                InitJSequence(prev, new JExtraAction());
            }
            else
            {
                // Basically what we are doing here is creating a whole bunch of
                // nested JSequences from the actions.
                for (int i = 1; i < actions.Length - 1; i++)
                {
                    prev = new JSequence(prev, actions [i]);
                }

                InitJSequence(prev, actions [actions.Length - 1]);
            }
        }
コード例 #3
0
 public JSequenceState(JSequence action, GameObject target)
     : base(action, target)
 {
     actionSequences   = action.Actions;
     hasInfiniteAction = (actionSequences [0] is JRepeatForever) || (actionSequences [1] is JRepeatForever);
     split             = actionSequences [0].Duration / Duration;
     last = -1;
 }
コード例 #4
0
        private void InitJSpawn(JFiniteTimeAction action1, JFiniteTimeAction action2)
        {
            Debug.Assert(action1 != null);
            Debug.Assert(action2 != null);

            float d1 = action1.Duration;
            float d2 = action2.Duration;

            ActionOne = action1;
            ActionTwo = action2;

            if (d1 > d2)
            {
                ActionTwo = new JSequence(action2, new JDelayTime(d1 - d2));
            }
            else if (d1 < d2)
            {
                ActionOne = new JSequence(action1, new JDelayTime(d2 - d1));
            }
        }