Exemple #1
0
        public bool AllConditionPass(LinkState linkstate, Event_FSM_EF_Event fsmevent)
        {
            foreach (KeyValuePair <string, List <string> > child in linkstate.m_AllConditions)
            {
                string        ConditionName = child.Key;
                List <string> Params        = child.Value;

                /*
                 * // For test
                 * bool bTrace;
                 * if(ConditionName == "QteEnd")
                 *  bTrace = true;
                 */

                if (m_FsmConditionDic.ContainsKey(ConditionName))
                {
                    if (!(m_FsmConditionDic[ConditionName](fsmevent, Params)))
                    {
                        return(false);
                    }
                }
                else
                {
                    Debug.LogWarning("Don't find " + ConditionName);
                }
            }
            return(true);
        }
Exemple #2
0
        public virtual void OnBegin(Event_FSM_EF_Event edata)
        {
            InitData(edata);


            Debug.Log(m_StateName + " OnBegin");
        }
Exemple #3
0
 protected override void InitDataFromNet(Event_FSM_EF_Event edata)
 {
     //int mstate =  edata.GetUserData<int>(1);
     //m_Creature.m_MoveComp.SettLastMoveState((eMoveStates)mstate);
     // m_Creature.m_MoveComp.SetMoveState(eMoveStates.MS_None);
     // Debug.Log("InitDataFromNet=" + m_Creature.m_MoveComp.GetLastMoveState());
 }
Exemple #4
0
        public override void OnBegin(Event_FSM_EF_Event edata)
        {
            base.OnBegin(edata);
            //GetCreaturetOwner().m_CompWeapon.ClearAttackList();
            //GetCreaturetOwner().m_CompBaseMovement.SetStop();
            //float alength = 0;
            //alength = GetOwner().SetAnimation("dead");
            //if (GetOwner().animator != null)
            //{
            //    GetOwner().animator.SetBool("dead", true);
            //}

            //sinktime = Time.time+ alength + 1f;
            //destorytime = sinktime + 2f;

            //BloodBarMgr.mInstance.RemoveBloodBar(GetOwner().m_InstanceID);
            //BloodBarMgr.mInstance.RemoveWarningSign(GetOwner().m_InstanceID);

            //Transform shadow = GetOwner().m_ObjInstance.transform.Find("P-SoldierShadow");
            //if(shadow != null)
            //{
            //    shadow.gameObject.SetActive(false);
            //}

            //if (GetOwner().m_Property.m_RtsObjData.m_iUnitType == 3 || GetOwner().m_Property.m_RtsObjData.m_iUnitType == 4) //飞机暂时直接删。
            //{
            //    GameApp.m_WorldManager.DestoryRtsObjLastUpdate(GetOwner().m_InstanceID);
            //}
        }
Exemple #5
0
        private ClashFsmStateBase GetNextState(Event_FSM_EF_Event edata)
        {
            if (m_CurState == null)
            {
                Debug.LogWarning("CurState is null!");
                return(null);
            }

            string statename = m_CurState.GetNextState(edata);

            if (statename == null)
            {
                // Debug.LogWarning("m_CurState="+m_CurState.GetStateName()+"  statename is null!");
                return(null);
            }
            //Debug.Log("GetNextState name=" + statename);
            if (m_StateDic.ContainsKey(statename))
            {
                return(m_StateDic[statename]);
            }
            else
            {
                Debug.LogWarning("don't find this state:" + statename);
            }
            return(null);
        }
Exemple #6
0
 public override void OnBegin(Event_FSM_EF_Event edata)
 {
     base.OnBegin(edata);
     //   Debug.Log("StateIdle-----------------------");
     //GetOwner().SetAnimation("idle");
     //m_GameObject.MoveComp.VelDir.Stop();
     // m_GameObject.MoveComp.Action.ChangeAction(GetAction(), false);
     //switch (m_Creature.m_MoveComp.GetLastMoveState())
     //{
     //    case eMoveStates.MS_Up:
     //        {
     //            ((Creature)m_GameObject).m_AvatarComp.SetAction((int)ePlayerAnima.PA_idle_up);
     //        } break;
     //    case eMoveStates.MS_Down:
     //        {
     //            ((Creature)m_GameObject).m_AvatarComp.SetAction((int)ePlayerAnima.PA_idle_down);
     //        } break;
     //    case eMoveStates.MS_Left:
     //        {
     //            ((Creature)m_GameObject).m_AvatarComp.SetAction((int)ePlayerAnima.PA_idle_left);
     //        } break;
     //    case eMoveStates.MS_Right:
     //        {
     //            ((Creature)m_GameObject).m_AvatarComp.SetAction((int)ePlayerAnima.PA_idle_right);
     //        } break;
     //}
     //Debug.Log(GetOwner().m_Property.m_RtsObjData.m_strName + GetOwner().m_InstanceID + " begin idle");
 }
Exemple #7
0
 public virtual bool OnEvent(Event_FSM_EF_Event edata)
 {
     switch (edata.m_FsmEventID)
     {
     case  eFsmEvent.FE_StateDealData:
     {
         DealDataFromNet(edata);
     } break;
     }
     return(true);
 }
Exemple #8
0
 public override void OnBegin(Event_FSM_EF_Event gevent)
 {
     base.OnBegin(gevent);
     //GetCreaturetOwner().m_CompWeapon.ClearAttackList();
     //GetOwner().SetAnimation("move");
     //if (GetOwner().animator != null)
     //{
     //    GetOwner().animator.SetBool("move", true);
     //}
     //Debug.Log(GetOwner().m_Property.m_RtsObjData.m_strName+GetOwner().m_InstanceID+" begin run");
 }
Exemple #9
0
 public virtual string GetNextState(Event_FSM_EF_Event edata)
 {
     //Debug.Log("GetNextState-----------" + edata.m_FsmEventID);
     for (int i = 0; i < m_LinkStateList.Count; i++)
     {
         if ((int)edata.m_FsmEventID == m_LinkStateList[i].m_EventId)
         {
             //输入扭转事件,在扭转条件都成立的情况下,扭转到新状态。
             if (DBManager.m_DBFsm.m_BnBFsmConditions.AllConditionPass(m_LinkStateList[i], edata))
             {
                 return(m_LinkStateList[i].m_StateName);
             }
         }
     }
     return(null);
 }
Exemple #10
0
        protected virtual void InitData(Event_FSM_EF_Event edata)
        {
            if (edata == null)
            {
                return;
            }

            // FMS_EVENT_ChangeState和FMS_EVENT_StateDealData是网络事件包
            // FMS_EVENT_StateDealData包不会导致状态切换,而是在OnEvent中直接处理
            if (edata.m_FsmEventID == eFsmEvent.FE_ChangeState)
            {
                InitDataFromNet(edata);
            }
            else
            {
                InitDataFromLocal(edata);
            }
        }
Exemple #11
0
        public virtual void Update(float deltatime)
        {
            if (m_GameObject == null)
            {
                return;
            }

            if (m_LiveTime > -90.0f)
            {
                if (m_LiveTime > 0)
                {
                    m_LiveTime -= deltatime;
                }
                else
                {
                    m_LiveTime = -100.0f;
                    Event_FSM_EF_Event gevent = new Event_FSM_EF_Event(eFsmEvent.FE_LiveTimeEnd);
                    GameDispatch.DispatchEvent(gevent, m_GameObject);
                }
            }
        }
Exemple #12
0
        // ÉèÖóõʼ״̬,»ò¸ÄÍøÂçÍæ¼Ò״̬£»
        public bool SetState(string statename, Event_FSM_EF_Event edata = null)
        {
            //if (m_CurState != null && m_CurState.GetGameObject() is NetPlayer)
            //{
            //    //  Debug.Log("SetState" + statename);
            //}
            if (m_StateDic.ContainsKey(statename))
            {
                if (m_CurState != null)
                {
                    m_CurState.OnEnd();
                }

                m_CurState = m_StateDic[statename];
                m_CurState.OnBegin(edata);
                return(true);
            }
            else
            {
                Debug.LogWarning("SetCurState statename don't find!" + statename);
            }
            return(false);
        }
Exemple #13
0
        public override void OnBegin(Event_FSM_EF_Event edata)
        {
            base.OnBegin(edata);
            //  Debug.Log("OnBegin(Event_FSM_EF_Event edata)");
            float alength = 0;

            //alength=GetOwner().SetAnimation("attack");
            //mAnimator = GetOwner().animator;
            //m_fAtkInterval = GetOwner().m_Property.m_RtsObjData.m_iATKRate * 0.001f;
            //m_fStartAtkTime = GetCreaturetOwner().GetRtsArmyData().m_fStartAtkTime;
            //m_fEndTime = Time.realtimeSinceStartup + m_fAtkInterval + m_fStartAtkTime;
            //GetCreaturetOwner().m_CompWeapon.AddBulletTime(m_fStartAtkTime);
            //Debug.Log("m_fStartAtkTime " + m_fStartAtkTime + " interval " + m_fAtkInterval);
            if (mAnimator != null)
            {
                //Debug.Log(GetOwner().m_ObjInstance.name + "fire begin");
                mAnimator.SetBool("attack", true);
            }

            //m_bLoop = edata.GetUserData<bool>(0);
            //m_fEndTime = Time.realtimeSinceStartup +alength+ 0.1f;

            //Debug.Log(GetOwner().m_Property.m_RtsObjData.m_strName + GetOwner().m_InstanceID + " begin fire");
        }
Exemple #14
0
 // 本地切换状态时需要的数据
 protected virtual void InitDataFromLocal(Event_FSM_EF_Event edata)
 {
 }
Exemple #15
0
        void OnEvent(GameEventData edata)
        {
            Event_FSM_EF_Event fsmEvent = (Event_FSM_EF_Event)edata;

            //Debug.Log(fsmEvent.m_FsmEventID);
            //if (m_CurState != null && m_CurState.GetGameObject() is NetPlayer)
            //{
            //    //  Debug.Log(" mfs OnEvent" + ml2event.m_iEventID);
            //}
            if (m_CurState == null || edata == null)
            {
                Debug.LogWarning("Warning,BnBFsm is null!");
            }

            switch (fsmEvent.m_FsmEventID)
            {
            case eFsmEvent.FE_ChangeState:
            {
                int    stateid   = ((Event_FSM_EF_Event)edata).GetUserData <int>(0);
                string statename = GetStateName(stateid);
                Debug.Log("FMS_EVENT_ChangeState==" + statename + "/stateid=" + stateid);
                if (statename != null)
                {
                    SetState(statename, fsmEvent);
                }
            }
            break;

            case  eFsmEvent.FE_StateDealData:
            {
                if (m_CurState != null)
                {
                    m_CurState.OnEvent(fsmEvent);
                }
            }
            break;

            default:
            {
                if (fsmEvent.m_FsmEventID <= eFsmEvent.FE_Begin || fsmEvent.m_FsmEventID >= eFsmEvent.FE_End)
                {
                    break;
                }
                // if
                //(((CharacterBase)m_ML2GameObject).MoveComp.OwnerIsType(EOwnerType.MainPlayer)
                //|| ((CharacterBase)m_ML2GameObject).MoveComp.OwnerIsType(EOwnerType.MasterMonster)
                //|| ((CharacterBase)m_ML2GameObject).MoveComp.OwnerIsType(EOwnerType.Pet)
                //|| (CharacterBase)m_ML2GameObject is UIPlayer
                //|| ((CharacterBase)m_ML2GameObject).MoveComp.OwnerIsType(EOwnerType.AutoPlayer))
                {
                    ClashFsmStateBase tempState = null;
                    tempState = GetNextState(fsmEvent);
                    if (tempState == null)
                    {
                        //if (IsDebug == true || ((CharacterBase)m_ML2GameObject).MoveComp.OwnerIsType(EOwnerType.AutoPlayer))
                        // Debug.LogWarning("OnEvent() DestState==null; SourceState = " + m_CurState.GetStateName() + ";Event =" + fsmEvent.m_FsmEventID);
                        return;
                    }

                    //Debug.Log("change from " + m_CurState.GetStateName() + " to " + fsmEvent.m_FsmEventID.ToString());
                    m_CurState.OnEnd();
                    m_CurState = tempState;
                    m_CurState.OnBegin(fsmEvent);
                }
            }
            break;
            }
        }
Exemple #16
0
 private bool testCondition(Event_FSM_EF_Event ml2event, List <string> param)
 {
     return(true);
 }
Exemple #17
0
        // 当前状态能否被打断
        //private bool CanBreak(GameEventData ml2event, List<string> param)
        //{
        //    if (ml2event.Receiver != null)
        //        return ((CharacterBase)ml2event.Receiver).m_BnBFsmComp.GetCurState().CanBreak();
        //    return true;
        //}

        //// 判断角色是否有速度(摇杆是否按下),参数和实际情况符合,则返回true
        //private bool CheckSpeed(GameEventData ml2event, List<string> param)
        //{
        //    if (ml2event.Receiver is Player)
        //    {
        //        if (ml2event.Receiver == null || ((Player)ml2event.Receiver).m_InputComp == null)
        //            return false;

        //        bool value = Convert.ToBoolean(param[0]);
        //        bool hasSpeed = (((Player)ml2event.Receiver).m_InputComp.Dir2 != Vector2.zero);
        //        return (value == hasSpeed);
        //    }
        //    return true;
        //}

        // 能够移动
        private bool CanMove(Event_FSM_EF_Event edata, List <string> param)
        {
            //if (ml2event.Receiver != null)
            // return ((CharacterBase)ml2event.Receiver).CanMove();
            return(true);
        }
Exemple #18
0
 // 处理该状态下的同步包
 protected virtual void DealDataFromNet(Event_FSM_EF_Event edata)
 {
 }