예제 #1
0
        private void DoMove(HFSMEvent evt)
        {
            Vector2 dir = (Vector2)evt.obj0;

            mOwner.Forward = dir;
            mOwner.Move(dir * propertyMoveSpeed.ValueFixed * Time.deltaTime);
        }
        private void DoMove(HFSMEvent evt)
        {
            Vector2     dir           = (Vector2)evt.obj0;
            const float tempMoveSpeed = 0.1f;

            mOwner.Forward = dir;
            mOwner.Move(dir * tempMoveSpeed);
            if (!ignoreMoveAnim)
            {
                mOwner.PlayAnimation(0, mOwner.GetAnimNameByState("move"), true);
                mOwner.PlayAnimation(2, mOwner.GetAnimNameByState("move_tui"), true);
            }
            ignoreMoveAnim = true;
        }
예제 #3
0
        public override HFSMEvent PostEvent(HFSMEvent evt)
        {
            string nextState = "";
            Func <HFSMEvent, string> func;

            if (mActionMap.TryGetValue(evt.msg, out func))
            {
                nextState = func(evt);
                return(new HFSMEvent(nextState, evt.obj0, evt.obj1, evt.obj2, evt.obj3, evt.obj4, evt.obj5));
            }
            else
            {
                if (FatherState == null)
                {
                    return(new HFSMEvent(nextState));
                }
                return(FatherState.PostEvent(evt));
            }
        }
예제 #4
0
        public bool Post(HFSMEvent evt)
        {
            //HFSMEvent nextStateEvt = null;
            //try
            //{
            //    nextStateEvt = mCurState.PostEvent(evt);
            //}
            //catch (Exception)
            //{
            //    UnityEngine.Debug.LogError(string.Format("出错!当前状态{0}, 要切换的状态{1}, 对象是{2}", master.GetCurState().Name, evt.msg, master.name));
            //    throw;
            //}
            HFSMEvent nextStateEvt = mCurState.PostEvent(evt);

            if (nextStateEvt.msg != "")
            {
                Transform(nextStateEvt);
                return(true);
            }
            return(false);
        }
예제 #5
0
        private void Transform(HFSMEvent evt)
        {
            if (evt.msg == mCurState.Name)
            {
                return;
            }

            List <State> curPathList = GetStatePath(mCurState.Name);
            List <State> aimPathList = GetStatePath(evt.msg);

            SplitSamePath(ref curPathList, ref aimPathList);

            for (int i = curPathList.Count - 1; i >= 0; i--)
            {
                curPathList[i].OnOver();
                mCurState = curPathList[i].FatherState;
            }
            for (int i = 0; i < aimPathList.Count; i++)
            {
                mCurState = aimPathList[i];
                aimPathList[i].OnStart(evt.obj0, evt.obj1, evt.obj2, evt.obj3, evt.obj4, evt.obj5);
            }
        }
예제 #6
0
 public virtual HFSMEvent PostEvent(HFSMEvent evt)
 {
     return(new HFSMEvent(""));
 }
예제 #7
0
 public bool Post(HFSMEvent evt)
 {
     return(hfsm.Post(evt));
 }