public override void OnInspectorGUI()
        {
            fsm     = target as FStateMachineMono;
            fsmImpl = fsm.FSM;

            base.OnInspectorGUI();
            bool repos = false;
            bool regen = false;

            ProcessMouseDeltaPos();
            DrawFSMGraph(ref regen, ref repos);
            ProcessMouseEvent(ref regen, ref repos);
            ProcessFocusCenter();
            serializedObject.ApplyModifiedProperties();
            if (regen)
            {
                GenerateStateMachine(serializedObject);
                GetCopys();
            }
            else if (repos)
            {
                GetCopys();
            }
            if (repaint || regen || repos || Application.isPlaying)
            {
                Repaint();
                repaint = false;
            }
        }
Exemplo n.º 2
0
 public StateChangeEvent(FStateMachine <T> targetStateMachine)
 {
     Target             = targetStateMachine.Target;
     TargetStateMachine = targetStateMachine;
     NewState           = targetStateMachine.CurrentState;
     PreviousState      = targetStateMachine.PreviousState;
 }
Exemplo n.º 3
0
    private void Start()
    {
        _testMovement = GetComponent <TestMovement>();
        _movement     = _testMovement.MovementState;
        _conditions   = _testMovement.ConditionState;

        _movement.ChangeState(CharacterStates.MovementStates.Running);
    }
        void DrawFSMGraph()
        {
            FStateMachineMono f = target as FStateMachineMono;

            fsmImpl = f.FSM;
            if (fsm != f)
            {
                fsm         = f;
                fsm.IsDirty = true;
            }
            if (fsm.IsDirty)
            {
                Reposition(fsm);
                fsm.IsDirty = false;
            }
            foldoutStates = QuickGUI.DrawHeader("状态预览图", "foldout", false);
            if (foldoutStates)
            {
                QuickGUI.BeginContents(50);
                GUILayout.Space(10);
                EditorGUILayout.BeginHorizontal();
                float scale = EditorGUILayout.Slider("滑动缩放视图", cellScale, 0.5f, 3f);
                EditorGUI.BeginDisabledGroup(Application.isPlaying);
                bool regen = GUILayout.Button("刷新", GUILayout.Height(20));
                EditorGUI.EndDisabledGroup();
                EditorGUILayout.EndHorizontal();


                if (regen || reloaded)
                {
                    fsm.GenerateStateMachine();
                    fsm.IsDirty = true;
                    reloaded    = false;
                }
                if (Mathf.Abs(scale - cellScale) > 0.01f)
                {
                    cellScale   = scale;
                    fsm.IsDirty = true;
                }
                if (fsm.IsDirty)
                {
                    Reposition(fsm);
                    fsm.IsDirty = false;
                }
                QuickGUI.ReportView(ref stateClipRect, stateViewPos, OnDrawFSMGraphCallback, Mathf.Max(350f, stateClipRect.width * 0.75f), 80);
                stateClipRectCenter = stateClipRect.size * 0.5f;

                QuickGUI.EndContents();
            }
            if (fsm.IsDirty)
            {
                Reposition(fsm);
                fsm.IsDirty = false;
            }
        }
Exemplo n.º 5
0
 private void Start()
 {
     MovementState  = new FStateMachine <CharacterStates.MovementStates>(gameObject, false);
     ConditionState = new FStateMachine <CharacterStates.CharacterConditionns>(gameObject, false);
 }