Exemplo n.º 1
0
        public static MTActionState RunAction(this GameObject target, MTAction action)
        {
            Debug.Assert(action != null, "Argument must be non-nil");


            return(MTActionManager.Instance.AddAction(action, target, !target.IsRunning()));
        }
Exemplo n.º 2
0
 public static void AddAction(this GameObject target, MTAction action, bool paused = false)
 {
     if (MTActionManager.Instance != null)
     {
         MTActionManager.Instance.AddAction(action, target, paused);
     }
 }
Exemplo n.º 3
0
        public MTActionState AddAction(MTAction action, GameObject target, bool paused = false)
        {
            Debug.Assert(action != null);
            Debug.Assert(target != null);

            HashElement element;
            if (!targets.TryGetValue(target, out element))
            {
                element = new HashElement();
                element.Paused = paused;
                element.Target = target;
                targets.Add(target, element);
                targetsAvailable = true;
            }

            ActionAllocWithHashElement(element);
            var isActionRunning = false;

            for (int i = 0; i < element.ActionStates.Count; i++) {
                var existingState = element.ActionStates [i];
                if (existingState.Action == action)
                {
                    isActionRunning = true;
                    break;
                }
            }

            Debug.Assert(!isActionRunning, "MTUnityAction : Action is already running for this target.");
            var state = action.StartAction(target);
            element.ActionStates.Add(state);

            return state;
        }
Exemplo n.º 4
0
        public static MTActionState RunAction(this MonoBehaviour target, MTAction action)
        {
            Debug.Assert(action != null, "Argument must be non-nil");

            GameObject curObj = target.gameObject;

            return(curObj.RunAction(action));
        }
Exemplo n.º 5
0
 public MTActionState(MTAction action, GameObject target)
 {
     this.Action = action;
     this.Target = target;
     this.OriginalTarget = target;
     //            if (target != null)
     //                this.Layer = target.Layer;
     //				Debug.Assert(false,"not implement");
 }
Exemplo n.º 6
0
        public MTActionState(MTAction action, GameObject target)
        {
            this.Action         = action;
            this.Target         = target;
            this.OriginalTarget = target;
//            if (target != null)
//                this.Layer = target.Layer;
//				Debug.Assert(false,"not implement");
        }
Exemplo n.º 7
0
        internal void RemoveAction(MTAction action, GameObject target)
        {
            if (action == null || target == null)
            {
                return;
            }

            HashElement element;

            if (targets.TryGetValue(target, out element))
            {
                int  limit       = element.ActionStates.Count;
                bool actionFound = false;

                for (int i = 0; i < limit; i++)
                {
                    var actionState = element.ActionStates[i];

                    if (actionState.Action == action && actionState.OriginalTarget == target)
                    {
                        RemoveActionAtIndex(i, element);
                        actionFound = true;
                        break;
                    }
                }

                if (!actionFound)
                {
//					Debug.LogWarning ("MTUnityAction : RemoveAction: Action not found");//Comment Mark,Don't Delete
                }
            }
            else
            {
//				Debug.LogWarning ("MTUnityAction : RemoveAction: Target not found");//Comment Mark,Don't Delete
            }
        }
Exemplo n.º 8
0
        public MTActionState AddAction(MTAction action, GameObject target, bool paused = false)
        {
            Debug.Assert(action != null);
            Debug.Assert(target != null);

            HashElement element;

            if (!targets.TryGetValue(target, out element))
            {
                element        = new HashElement();
                element.Paused = paused;
                element.Target = target;
                targets.Add(target, element);
                targetsAvailable = true;
            }

            ActionAllocWithHashElement(element);
            var isActionRunning = false;

            for (int i = 0; i < element.ActionStates.Count; i++)
            {
                var existingState = element.ActionStates [i];
                if (existingState.Action == action)
                {
                    isActionRunning = true;
                    break;
                }
            }

            Debug.Assert(!isActionRunning, "MTUnityAction : Action is already running for this target.");
            var state = action.StartAction(target);

            element.ActionStates.Add(state);

            return(state);
        }
Exemplo n.º 9
0
        public static MTActionState RunAction(this GameObject target, MTAction action)
        {
            Debug.Assert(action != null, "Argument must be non-nil");

            return  MTActionManager.instance.AddAction(action, target, !target.IsRunning());
        }
Exemplo n.º 10
0
        public static MTActionState RunAction(this MonoBehaviour target, MTAction action)
        {
            Debug.Assert(action != null, "Argument must be non-nil");

            GameObject curObj = target.gameObject;
            return  curObj.RunAction (action);
        }
Exemplo n.º 11
0
 public static void AddAction(this GameObject target,MTAction action, bool paused = false)
 {
     if (MTActionManager.instance != null)
         MTActionManager.instance.AddAction(action, target, paused);
 }
Exemplo n.º 12
0
        internal void RemoveAction(MTAction action, GameObject target)
        {
            if (action == null || target == null)
                return;

            HashElement element;
            if (targets.TryGetValue(target, out element))
            {
                int limit = element.ActionStates.Count;
                bool actionFound = false;

                for (int i = 0; i < limit; i++)
                {
                    var actionState = element.ActionStates[i];

                    if (actionState.Action == action && actionState.OriginalTarget == target)
                    {
                        RemoveActionAtIndex(i, element);
                        actionFound = true;
                        break;
                    }
                }

                if (!actionFound)
                   Debug.Log("MTUnityAction : RemoveAction: Action not found");
            }
            else
            {
               Debug.Log("MTUnityAction : RemoveAction: Target not found");
            }
        }