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


            return(JActionManager.Instance.AddAction(action, target, !target.IsRunning()));
        }
Exemplo n.º 2
0
 public static void AddAction(this GameObject target, JAction action, bool paused = false)
 {
     if (JActionManager.Instance != null)
     {
         JActionManager.Instance.AddAction(action, target, paused);
     }
 }
Exemplo n.º 3
0
        public static JActionState RunAction(this MonoBehaviour target, JAction action)
        {
            Debug.Assert(action != null, "Argument must be non-nil");

            GameObject curObj = target.gameObject;

            return(curObj.RunAction(action));
        }
Exemplo n.º 4
0
        public JActionState(JAction 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.º 5
0
        internal void RemoveAction(JAction 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 ("JUnityAction : RemoveAction: Action not found");//Comment Mark,Don't Delete
                }
            }
            else
            {
//				Debug.LogWarning ("JUnityAction : RemoveAction: Target not found");//Comment Mark,Don't Delete
            }
        }
Exemplo n.º 6
0
        public JActionState AddAction(JAction 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, "JUnityAction : Action is already running for this target.");
            var state = action.StartAction(target);

            element.ActionStates.Add(state);

            return(state);
        }