Exemple #1
0
        ///Returns true if a transitions was valid and thus made
        public bool CheckTransitions()
        {
            for (var i = 0; i < outConnections.Count; i++)
            {
                var connection = (FSMConnection)outConnections[i];
                var condition  = connection.condition;

                if (!connection.isActive)
                {
                    continue;
                }

                if ((condition != null && condition.CheckCondition(graphAgent, graphBlackboard)) || (condition == null && status != Status.Running))
                {
                    AppEventsManager.Publish_StateTransition(
                        (FSMState)connection.sourceNode,
                        (FSMState)connection.targetNode
                        );

                    FSM.EnterState((FSMState)connection.targetNode);
                    connection.status = Status.Success; //editor vis
                    return(true);
                }

                connection.status = Status.Failure; //editor vis
            }

            return(false);
        }
        new public void Update()
        {
            if (outConnections.Count == 0)
            {
                return;
            }

            status = Status.Running;

            for (var i = 0; i < outConnections.Count; i++)
            {
                var connection = (FSMConnection)outConnections[i];
                var condition  = connection.condition;

                if (!connection.isActive || connection.condition == null)
                {
                    continue;
                }

                if (dontRetriggerStates && FSM.currentState == (FSMState)connection.targetNode)
                {
                    continue;
                }

                if (condition.CheckCondition(graphAgent, graphBlackboard))
                {
                    FSM.EnterState((FSMState)connection.targetNode);
                    connection.status = Status.Success;                     //editor vis
                    return;
                }

                connection.status = Status.Failure;                 //editor vis
            }
        }
Exemple #3
0
        bool CheckTransition()
        {
            if (status == Status.Running && transitionEvaluation == TransitionEvaluation.CheckAfterStateFinished)
            {
                return(false);
            }

            for (int i = 0; i < outConnections.Count; i++)
            {
                var connection = outConnections[i] as FSMConnection;
                if (connection.CheckCondition(graphAgent, graphBlackboard))
                {
                    if (status != Status.Running || connection.condition != null)
                    {
                        FSM.EnterState(connection.targetNode as FSMState);

                        //this is done for editor
                        connection.connectionStatus = Status.Success;
                        //

                        return(true);
                    }
                }
            }

            return(false);
        }
Exemple #4
0
 //...
 protected override UnityEditor.GenericMenu OnContextMenu(UnityEditor.GenericMenu menu)
 {
     if (Application.isPlaying)
     {
         menu.AddItem(new GUIContent("Enter State"), false, () => { FSM.EnterState(this, FSM.TransitionCallMode.Normal); });
     }
     else
     {
         menu.AddDisabledItem(new GUIContent("Enter State"));
     }
     menu.AddItem(new GUIContent("Breakpoint"), isBreakpoint, () => { isBreakpoint = !isBreakpoint; });
     return(menu);
 }
Exemple #5
0
 protected override GenericMenu OnContextMenu(GenericMenu menu)
 {
     if (allowAsPrime)
     {
         if (Application.isPlaying)
         {
             menu.AddItem(new GUIContent("Enter State"), false, delegate { FSM.EnterState(this); });
         }
         else
         {
             menu.AddDisabledItem(new GUIContent("Enter State"));
         }
     }
     return(menu);
 }
Exemple #6
0
        protected override void OnNodeGUI()
        {
            if (inIconMode)
            {
                GUILayout.Label("<i>" + nodeName + "</i>");
            }

            if (Application.isPlaying)
            {
                if (allowAsPrime && Event.current.type == EventType.MouseDown && Event.current.alt)
                {
                    FSM.EnterState(this);
                }
            }
        }
Exemple #7
0
 //...
 protected override GenericMenu OnContextMenu(GenericMenu menu)
 {
     if (allowAsPrime)
     {
         if (Application.isPlaying)
         {
             menu.AddItem(new GUIContent("Enter State"), false, () => { FSM.EnterState(this); });
         }
         else
         {
             menu.AddDisabledItem(new GUIContent("Enter State"));
         }
         menu.AddItem(new GUIContent("Breakpoint"), isBreakpoint, () => { isBreakpoint = !isBreakpoint; });
     }
     return(menu);
 }
Exemple #8
0
        ///Returns true if a transitions was valid and thus made
        public bool CheckTransitions()
        {
            for (var i = 0; i < outConnections.Count; i++)
            {
                var connection = (FSMConnection)outConnections[i];
                var condition  = connection.condition;

                if (!connection.isActive)
                {
                    continue;
                }

                if ((condition != null && condition.CheckCondition(graphAgent, graphBlackboard)) || (condition == null && status != Status.Running))
                {
                    FSM.EnterState((FSMState)connection.targetNode);
                    connection.connectionStatus = Status.Success;                     //purely for editor feedback
                    return(true);
                }

                connection.connectionStatus = Status.Failure;
            }

            return(false);
        }
Exemple #9
0
        public void UpdateAnyState()
        {
            if (outConnections.Count == 0)
            {
                return;
            }

            status = Status.Running;

            for (int i = 0; i < outConnections.Count; i++)
            {
                var connection = outConnections[i] as FSMConnection;
                if (connection.condition == null)
                {
                    continue;
                }

                if (connection.CheckCondition(graphAgent, graphBlackboard))
                {
                    FSM.EnterState(connection.targetNode as FSMState);
                    return;
                }
            }
        }