Exemplo n.º 1
0
    bool InitWithTwoActions(MtFiniteTimeAction actionOne, MtFiniteTimeAction actionTwo)
    {
        Debug.Assert(actionOne != null, "actionOne can't be null!");
        Debug.Assert(actionTwo != null, "actionTwo can't be null!");
        if (actionOne == null || actionTwo == null)
        {
            Debug.Log("MtSpawn.InitWithTwoActions error: action is null!!");
            return(false);
        }
        bool  ret = false;
        float d1  = actionOne.Duration;
        float d2  = actionTwo.Duration;

        if (base.InitWithDuration(Mathf.Max(d1, d2)))
        {
            m_one = actionOne;
            m_two = actionTwo;
            if (d1 > d2)
            {
                m_two = MtSequence.CreateWithTwoActions(actionTwo, MtDelayTime.Create(d1 - d2));
            }
            else if (d1 < d2)
            {
                m_one = MtSequence.CreateWithTwoActions(actionOne, MtDelayTime.Create(d2 - d1));
            }
            ret = true;
        }
        return(ret);
    }
Exemplo n.º 2
0
    public void RemoveAllActionsFromTarget(Transform target)
    {
        if (target == null || !m_dicActionElement.ContainsKey(target))
        {
            return;
        }

        LinkedListNode <MtActionElement> element = null;

        if (m_dicActionElement.ContainsKey(target))
        {
            element = m_dicActionElement[target];
        }

        if (element != null)
        {
            foreach (var item in element.Value.actions)
            {
                MtFiniteTimeAction action = item as MtFiniteTimeAction;
                if (action != null)
                {
                    action.Stop();
                }
            }
            element.Value.actions.Clear();
        }
        m_dicActionElement.Remove(target);
    }
Exemplo n.º 3
0
    public static MtRepeat Create(MtFiniteTimeAction action, int times)
    {
        MtRepeat repeat = new MtRepeat();

        if (repeat.InitWithAction(action, times))
        {
            return(repeat);
        }
        return(null);
    }
Exemplo n.º 4
0
    public static MtSequence CreateWithTwoActions(MtFiniteTimeAction actionOne, MtFiniteTimeAction actionTwo)
    {
        MtSequence sequence = new MtSequence();

        if (sequence.InitWithTwoActions(actionOne, actionTwo))
        {
            return(sequence);
        }
        return(null);
    }
Exemplo n.º 5
0
    public static MtSpawn CreateWithTwoActions(MtFiniteTimeAction actionOne, MtFiniteTimeAction actionTwo)
    {
        MtSpawn spawn = new MtSpawn();

        if (spawn.InitWithTwoActions(actionOne, actionTwo))
        {
            return(spawn);
        }
        return(null);
    }
Exemplo n.º 6
0
    bool InitWithTwoActions(MtFiniteTimeAction actionOne, MtFiniteTimeAction actionTwo)
    {
        Debug.Assert(actionOne != null, "actionOne can't be null!");
        Debug.Assert(actionTwo != null, "actionTwo can't be null!");
        if (actionOne == null || actionTwo == null)
        {
            Debug.Log("MtSequence.InitWithTwoActions error: action is null!!");
            return(false);
        }
        float d = actionOne.Duration + actionTwo.Duration;

        base.InitWithDuration(d);
        m_actions[0] = actionOne;
        m_actions[1] = actionTwo;
        return(true);
    }
Exemplo n.º 7
0
    public bool InitWithAction(MtFiniteTimeAction action, int times)
    {
        float d = action.Duration * times;

        if (action != null && base.InitWithDuration(d))
        {
            m_times       = times;
            m_innerAction = action;

            m_actionInstant = action.GetType().IsSubclassOf(typeof(MtActionInstant));
            //an instant action needs to be executed one time less in the update method since it uses startWithTarget to execute the action
            // minggo: instant action doesn't execute action in Repeat::startWithTarget(), so comment it.
            //        if (_actionInstant)
            //        {
            //            _times -=1;
            //        }
            m_total = 0;
            return(true);
        }

        return(false);
    }
Exemplo n.º 8
0
    public static MtSequence CreateWithVariableList(MtFiniteTimeAction action1, params MtFiniteTimeAction[] actions)
    {
        MtFiniteTimeAction now  = null;
        MtFiniteTimeAction prev = action1;
        bool bOneAction         = true;
        int  index = 0;

        while (index < actions.Length)
        {
            now = actions[index];
            index++;
            if (now != null)
            {
                prev       = CreateWithTwoActions(prev, now);
                bOneAction = false;
            }
        }
        // If only one action is added to Sequence, make up a Sequence by adding a simplest finite time action.
        if (bOneAction)
        {
            prev = CreateWithTwoActions(prev, MtExtraAction.Create());
        }
        return(prev as MtSequence);
    }
Exemplo n.º 9
0
    public static MtSequence Create(MtFiniteTimeAction action1, params MtFiniteTimeAction[] actions)
    {
        MtSequence ret = CreateWithVariableList(action1, actions);

        return(ret);
    }