Exemplo n.º 1
0
        /// <summary>
        /// Raised each frame while action is running.
        /// Calling GPAction.End or GPAction.Stop will stop updates.
        /// </summary>
        /// <param name="dt">Dt.</param>
        protected override void OnUpdate()
        {
            if (this.HasEnded)
            {
                return;
            }

            int endedCount = 0;

            for (int i = 0; i < ActionCount(); i++)
            {
                GPAction action = ActionAtIndex(i);

                if (!action.HasEnded)
                {
                    action.Update();
                }

                // Note that HasEnded can change during
                // update.

                if (action.HasEnded)
                {
                    endedCount++;
                }
            }

            if (endedCount == ActionCount())
            {
                End();
            }
        }
Exemplo n.º 2
0
        public void Disconnect(GPAction Action)
        {
            if (m_action == null)
            {
                return;
            }

            m_action._leftNode._connection = null;
            EventNode._connection          = null;
        }
Exemplo n.º 3
0
        public virtual void SetActionAt(int idx, GPAction action)
        {
#if UNITY_EDITOR
            /*
             * _rightNodes[idx]._connection = new ActionEditorConnection(_rightNodes[idx],action._leftNode);
             * m_actions[idx]._leftNode._connection = _rightNodes[idx]._connection;
             */
            CreateAllRightNodes();
#endif
            m_actions[idx] = action;
        }
Exemplo n.º 4
0
        public virtual GPAction AddAction(System.Type actionType)
        {
            GPAction action = GetGPActionObjectMapperOrCreate().AddAction(this, actionType);

            action.enabled = false;

            action._name = System.Guid.NewGuid().ToString();

            action.SetParentHandler(this);

            return(action);
        }
Exemplo n.º 5
0
        public void Connect(GPAction action)
        {
            if (action == null)
            {
                return;
            }

            if (action._leftNode._connection != null)
            {
                ((IActionOwner)action._leftNode._connection._nodeParent._owner).Disconnect(action);
            }

            EventNode._connection        = new ActionEditorConnection(EventNode, action._leftNode);
            action._leftNode._connection = EventNode._connection;
        }
        public override void SetAction(GPAction action)
        {
            base.SetAction(action);

            GPActionEnableComponent ecAction = (GPActionEnableComponent)TargetAction;

            if (ecAction._component == null)
            {
                return;
            }

            m_componentParentObject = ecAction._component.gameObject;

            CreateComponentList();
        }
Exemplo n.º 7
0
        public static System.Type InspectorTypeForAction(GPAction action)
        {
            System.Type actionType    = action.GetType();
            System.Type inspectorType = null;

            while (inspectorType == null && actionType != typeof(GPAction))
            {
                if (s_gpactionInspectorMap.TryGetValue(actionType, out inspectorType))
                {
                    return(inspectorType);
                }

                actionType = actionType.BaseType;
            }

            return(typeof(GPActionDefaultInspector));
        }
Exemplo n.º 8
0
        public virtual GPAction AddAction(GPAction action)
        {
            m_actions.Add(action);

#if UNITY_EDITOR
            /*
             * _rightNodes[m_actions.Count-1]._connection =
             *      new ActionEditorConnection(_rightNodes[m_actions.Count],m_actions.Last()._leftNode);
             *
             * m_actions.Last()._leftNode._connection = _rightNodes[m_actions.Count]._connection;
             *
             * AddRightNode();
             */
            CreateAllRightNodes();
#endif
            return(m_actions.Last());
        }
Exemplo n.º 9
0
        protected virtual void DisplayBlueprint()
        {
            ComputeScrollView();

            float xInspector = position.width - m_inspectorWidth;

            Handles.BeginGUI();

            GUILayout.BeginArea(new Rect(0, 0, xInspector, position.height));

            m_blueprintScrollPosition = GUI.BeginScrollView(new Rect(0, 0, xInspector, position.height),
                                                            m_blueprintScrollPosition,
                                                            m_blueprintScrollView);

            BeginWindows();

            GUI.backgroundColor = m_eventHandlerColor;

            m_handler._windowRect = GUI.Window(-1, m_handler._windowRect, DisplayHandler, "Event");

            for (int i = 0; i < m_actions.Length; i++)
            {
                GPAction box = m_actions[i];

                SetBoxColor(box);

                string name = GetDisplayName(box.GetType());

                Rect newRect = GUI.Window(i, box._windowRect, DisplayAction, name);

                if (box._windowRect != newRect)
                {
                    box._windowRect = newRect;
                    m_actionInspectors[i].SerialObject.FindProperty("_windowRect").rectValue = newRect;
                }
            }

            EndWindows();

            GUI.EndScrollView();

            GUILayout.EndArea();

            Handles.EndGUI();
        }
Exemplo n.º 10
0
        public void RemoveSelectedAction()
        {
            if (m_selectedBoxID == -1)
            {
                return;
            }

            GPAction action = m_actions[m_selectedBoxID];

            if (action is GPActionRelatedObject)
            {
                return;
            }

            if (action._leftNode._connection != null)
            {
                if (m_actions[m_selectedBoxID]._leftNode._connection._nodeParent == null)
                {
                    m_actions[m_selectedBoxID]._leftNode._connection._nodeChild._connection = null;
                    m_actions[m_selectedBoxID]._leftNode._connection = null;
                }
                else if (m_actions[m_selectedBoxID]._leftNode._connection._nodeParent._owner != null)
                {
                    ((IActionOwner)m_actions[m_selectedBoxID]._leftNode._connection._nodeParent._owner)
                    .Disconnect(m_actions[m_selectedBoxID]);
                }
            }

            if (action is IActionOwner)
            {
                ((IActionOwner)action).DisconnectAll();
            }

            DestroyImmediate(m_actions[m_selectedBoxID]);

            m_selectedBoxID       = -1;
            m_layoutSelectedBoxID = -1;

            Repaint();
        }
Exemplo n.º 11
0
        protected virtual void SetBoxColor(GPAction box)
        {
            Color c;

            switch (box.State)
            {
            case GPAction.ActionState.NONE:
                c = m_actionNoneColor;
                break;

            case GPAction.ActionState.RUNNNING:
                c = m_actionRunningColor;
                break;

            case GPAction.ActionState.TERMINATED:
                c = m_actionTerminatedColor;
                break;

            case GPAction.ActionState.FAILURE:
                c = m_actionFailureColor;
                break;

            default:
                c = Color.gray;
                break;
            }

            if (m_selectedBoxID >= 0 &&
                m_selectedBoxID < m_actions.Length &&
                m_actions[m_selectedBoxID] != box)
            {
                c *= 0.5f;
            }

            c.a = 1.0f;

            GUI.backgroundColor = c;
        }
Exemplo n.º 12
0
 public void Disconnect(GPAction child)
 {
     RemoveAction(child);
 }
Exemplo n.º 13
0
 public void Connect(GPAction child)
 {
     AddAction(child);
 }
Exemplo n.º 14
0
        public virtual void RemoveAction(GPAction action)
        {
            int idx = m_actions.IndexOf(action);

            RemoveActionAt(idx);
        }