示例#1
0
        public MTSequence(params MTFiniteTimeAction[] actions) : base()
        {
            Actions = new MTFiniteTimeAction[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)
            {
                InitMTSequence(prev, new MTExtraAction());
            }
            else
            {
                // Basically what we are doing here is creating a whole bunch of
                // nested MTSequences from the actions.
                for (int i = 1; i < actions.Length - 1; i++)
                {
                    prev = new MTSequence(prev, actions [i]);
                }

                InitMTSequence(prev, actions [actions.Length - 1]);
            }
        }
示例#2
0
        public MTParallel(params MTFiniteTimeAction[] 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 MTSequence (Actions [i], new MTDelayTime (Duration - actionDuration));
                }
            }
        }
示例#3
0
        public MTSequence(params MTFiniteTimeAction[] actions)
            : base()
        {
            Actions = new MTFiniteTimeAction[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)
            {
                InitMTSequence (prev, new MTExtraAction ());
            }
            else
            {
                // Basically what we are doing here is creating a whole bunch of
                // nested MTSequences from the actions.
                for (int i = 1; i < actions.Length - 1; i++)
                {
                    prev = new MTSequence (prev, actions [i]);
                }

                InitMTSequence (prev, actions [actions.Length - 1]);
            }
        }
示例#4
0
        public MTParallel(params MTFiniteTimeAction[] 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 MTSequence(Actions [i], new MTDelayTime(Duration - actionDuration));
                }
            }
        }
示例#5
0
 public MTSequenceState(MTSequence action, GameObject target)
     : base(action, target)
 {
     actionSequences   = action.Actions;
     hasInfiniteAction = (actionSequences [0] is MTRepeatForever) || (actionSequences [1] is MTRepeatForever);
     split             = actionSequences [0].Duration / Duration;
     last = -1;
 }
示例#6
0
        private void InitMTSpawn(MTFiniteTimeAction action1, MTFiniteTimeAction 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 MTSequence(action2, new MTDelayTime(d1 - d2));
            }
            else if (d1 < d2)
            {
                ActionOne = new MTSequence(action1, new MTDelayTime(d2 - d1));
            }
        }
示例#7
0
 public MTSequenceState(MTSequence action, GameObject target)
     : base(action, target)
 {
     actionSequences = action.Actions;
     hasInfiniteAction = (actionSequences [0] is MTRepeatForever) || (actionSequences [1] is MTRepeatForever);
     split = actionSequences [0].Duration / Duration;
     last = -1;
 }
示例#8
0
 public MTRepeatForever(params MTFiniteTimeAction[] actions)
 {
     Debug.Assert (actions != null);
     InnerAction = new MTSequence (actions);
 }
示例#9
0
        private void InitMTSpawn(MTFiniteTimeAction action1, MTFiniteTimeAction 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 MTSequence (action2, new MTDelayTime (d1 - d2));
            }
            else if (d1 < d2)
            {
                ActionOne = new MTSequence (action1, new MTDelayTime (d2 - d1));
            }
        }