void OnGUI()
        {
            if (GUI.Button(new Rect(0, 100, 200, 100), "Run"))
            {
                mFSM.HandleEvent(RUN_CLICK_EVENT);
                Debug.LogError("Cur State:" + mFSM.State);
            }

            if (GUI.Button(new Rect(0, 200, 200, 100), "Walk"))
            {
                mFSM.HandleEvent(WALK_CLICK_EVENT);
                Debug.LogError("Cur State:" + mFSM.State);
            }

            if (GUI.Button(new Rect(0, 300, 200, 100), "Jump"))
            {
                mFSM.HandleEvent(JUMP_CLICK_EVENT);
                Debug.LogError("Cur State:" + mFSM.State);
            }

            if (GUI.Button(new Rect(0, 400, 200, 100), "Reset"))
            {
                mFSM.Start(IDLE_STATE);
                Debug.LogError("Cur State:" + mFSM.State);
            }
        }
Exemple #2
0
        // Update is called once per frame
        void OnGUI()
        {
            if (GUI.Button(new Rect(0, 0, 200, 100), "用户:输入跳跃"))
            {
                mPlayerFsm.HandleEvent(EVENT_TOUCH_DOWN);
            }

            if (GUI.Button(new Rect(0, 100, 200, 100), "碰撞器:输入着陆"))
            {
                mPlayerFsm.HandleEvent(EVENT_LAND);
            }
        }
Exemple #3
0
        public void FSMLiteTest_AddTranslation()
        {
            string str1 = "work->rest true";
            string str2 = "work->rest false";

            mFSMLite.AddState("work");
            mFSMLite.AddState("rest");

            mFSMLite.AddTranslation("work", "work->rest", "rest", delegate {
                str2 = "work->rest true";
            });

            mFSMLite.Start("work");

            mFSMLite.HandleEvent("work->rest");

            Assert.IsNotNull(mFSMLite);
            Assert.AreEqual(str1, str2);
        }
Exemple #4
0
        /// <summary>
        /// 处理消息
        /// </summary>
        void ProcessEvent(int key, params object[] paramList)
        {
            Example5UIEvent eventName = (Example5UIEvent)paramList[0];

            mFSM.HandleEvent(eventName.ToString());
        }
Exemple #5
0
        /// <summary>
        /// 处理消息
        /// </summary>
        void ProcessEvent(object[] paramList)
        {
            string eventName = (string)paramList[0];

            mFSM.HandleEvent(eventName);
        }