public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (!EditorApplication.isPlaying)
            {
                EditorGUILayout.HelpBox("Available during runtime only.", MessageType.Info);
                return;
            }

            FsmComponent t = (FsmComponent)target;

            if (PrefabUtility.GetPrefabType(t.gameObject) != PrefabType.Prefab)
            {
                EditorGUILayout.LabelField("FSM Count", t.Count.ToString());

                FsmBase[] fsms = t.GetAllFsms();
                foreach (FsmBase fsm in fsms)
                {
                    DrawFsm(fsm);
                }
            }

            Repaint();
        }
Esempio n. 2
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (!EditorApplication.isPlaying)
            {
                EditorGUILayout.HelpBox("Available during runtime only.", MessageType.Info);
                return;
            }

            FsmComponent t = target as FsmComponent;

            if (IsPrefabInHierarchy(t.gameObject))
            {
                EditorGUILayout.LabelField("FSM Count", t.Count.ToString());    //状态机数量

                FsmBase[] fsms = t.GetAllFsms();
                for (int i = 0; i < fsms.Length; i++)
                {
                    var fsm = fsms[i];
                    //打印状态机运行信息
                    EditorGUILayout.LabelField(Utility.Text.GetFullName(fsm.OwnerType, fsm.Name), fsm.IsRunning ? Utility.Text.Format("{0}, {1} s", fsm.CurrentStateName, fsm.CurrentStateTime.ToString("F1")) : (fsm.IsDestroyed ? "Destroyed" : "Not Running"));
                }
            }

            Repaint();
        }
Esempio n. 3
0
 /// <summary>
 /// 框架组件初始化。
 /// </summary>
 protected override void Awake()
 {
     base.Awake();
     m_FsmManager = CentorPivot.This.GetComponent <FsmComponent>();
     if (m_FsmManager == null)
     {
         Log.Fatal("FSM manager is invalid.");
         return;
     }
 }
Esempio n. 4
0
    public virtual void SendFsmEvent(string eventName, float delay = 0)
    {
        Action action = () =>
        {
            string beforeActievStateName = ActiveStateName;
            FsmComponent.SendEvent(eventName);
#if BUILD_TYPE_DEBUG
            Debug.Log("[FSM]CALL SendFsmEvent goName:" + name + " event:" + eventName + " before:" + beforeActievStateName + " after:" + ActiveStateName);
#endif
        };

        if (delay == 0)
        {
            action();
            return;
        }
        this.ExecuteLater(delay, action);
    }
Esempio n. 5
0
    protected override void OnInit(object userData)
    {
        base.OnInit(userData);

        Fsm = UnityGameFramework.Runtime.GameEntry.GetComponent <FsmComponent>();

        /* 英雄的所有状态类 */
        FsmState <Demo10_HeroLogic>[] heroStates = new FsmState <Demo10_HeroLogic>[] {
            new Demo10_HeroIdleState(),
            new Demo10_HeroWalkState(),
        };

        /* 创建状态机 */
        m_HeroFsm = Fsm.CreateFsm <Demo10_HeroLogic> (this, heroStates);

        /* 启动站立状态 */
        m_HeroFsm.Start <Demo10_HeroIdleState> ();
    }