示例#1
0
    protected override void InitStateMachine()
    {
        m_FSM      = new FSMSystem();
        m_FSM.attr = attr;

        idleState  = new EnemyIdleState();
        moveState  = new EnemyMoveState();
        fightState = new EnemyFightState();
        deathState = new EnemyDeathState();



        m_FSM.AddState(idleState, this);
        idleState.AddTransition(Transition.IsMove, StateID.Move);
        idleState.AddTransition(Transition.IsFight, StateID.Fight);


        m_FSM.AddState(moveState, this);
        moveState.AddTransition(Transition.IsIdle, StateID.Idle);
        moveState.AddTransition(Transition.IsFight, StateID.Fight);


        m_FSM.AddState(fightState, this);
        fightState.AddTransition(Transition.IsIdle, StateID.Idle);

        m_FSM.AddState(deathState, this);

        //初始状态为Idle
        m_FSM.SetCurrentState(idleState);
    }
示例#2
0
    void MakeFSM()
    {
        fsm = new FSMSystem();
        FSMState[] states = GetComponentsInChildren <FSMState>();
        foreach (FSMState state in states)
        {
            fsm.AddState(state, this);
        }
        MenuState s = GetComponentInChildren <MenuState>();             //设置菜单为默认状态

        fsm.SetCurrentState(s);
    }
示例#3
0
文件: Ctrl.cs 项目: kismy/DesignMode
    void MakeFSM()
    {
        fsm = new FSMSystem();
        FSMState[] states = GetComponentsInChildren <FSMState>();
        foreach (var state in states)
        {
            fsm.AddState(state, this);
        }
        MenuState defualtState = GetComponentInChildren <MenuState>();

        fsm.SetCurrentState(defualtState);
    }
示例#4
0
    void MakeFSM()
    {
        mFSM = new FSMSystem();

        var states = gameObject.GetComponentsInChildren <FSMState>();

        states.ForEach(state => { mFSM.AddState(state); });

        var menuState = states.First(state => state is MenuState);

        mFSM.SetCurrentState(menuState);
    }
示例#5
0
    private void MakeFSM()
    {
        fsm = new FSMSystem();
        FSMState[] states = GetComponentsInChildren <FSMState>(); // 得到 State 物体上挂载的所有的状态
        foreach (FSMState state in states)
        {
            fsm.AddState(state, this); // 将所有的状态添加到状态机里面
        }
        // 设置默认状态
        MenuState s = GetComponentInChildren <MenuState>(); // 获取菜单状态

        fsm.SetCurrentState(s);                             // 将菜单状态设置为当前状态
    }
示例#6
0
    void MakeFSM()
    {
        fsm = new FSMSystem();
        FSMState[] states = GetComponentsInChildren <FSMState>();
        foreach (FSMState state in states)
        {
            fsm.AddState(state, this);
        }
        // 状态机创建初始状态: Menu状态
        MenuState s = GetComponentInChildren <MenuState>();

        fsm.SetCurrentState(s);
    }
示例#7
0
  void MakeFSM()
  {
      fsm = new FSMSystem();
      FSMState[] states = GetComponentsInChildren <FSMState>();
      foreach (FSMState state in states)
      {
          fsm.AddState(state, this);
      }
      StartState s = GetComponentInChildren <StartState>();

      fsm.SetCurrentState(s);

      playState = GetComponentInChildren <PlayState>();
  }
示例#8
0
    void MakeFSM()
    {
        fsm = new FSMSystem();
        FSMState[] states = GetComponentsInChildren <FSMState>();
        //将所有状态添加到状态机中管理
        foreach (FSMState state in states)
        {
            fsm.AddState(state, this);
        }
        //设置默认状态
        MenuState s = GetComponentInChildren <MenuState>();

        fsm.SetCurrentState(s);
    }
示例#9
0
    void MakeFSM()//构造状态机
    {
        fSM = new FSMSystem();
        FSMState[] states = GetComponentsInChildren <FSMState>();
        //获取四种状态加载到状态机中
        foreach (FSMState state in states)
        {
            fSM.AddState(state, this);
        }
        //设置默认状态
        MenuState m = GetComponentInChildren <MenuState>();

        fSM.SetCurrentState(m);
    }
示例#10
0
    private void MakekFSM()
    {
        FSMSystem = new FSMSystem();
        FSMState[] states = GetComponentsInChildren <FSMState>(true);
        MenuState  s      = null;

        foreach (FSMState state in states)
        {
            FSMSystem.AddState(state, this);
            if (state is MenuState)
            {
                s = (MenuState)state;
            }
        }
        FSMSystem.SetCurrentState(s);
    }
示例#11
0
文件: Player.cs 项目: wuguanyang/FSM
    private void Awake()
    {
        fsm = new FSMSystem <PlayerST, PlayerSN> ();

        var idle = new PlayerIdle(PlayerSN.Idle);

        idle.AddTransition(PlayerST.InputA, PlayerSN.Run);

        var run = new PlayerRun(PlayerSN.Run);

        run.AddTransition(PlayerST.InputB, PlayerSN.Idle);

        fsm.AddState(idle);
        fsm.AddState(run);

        fsm.SetCurrentState(PlayerSN.Idle);

        Debug.Log(fsm.states.Count);
    }
示例#12
0
    /// <summary>
    /// 初始化状态机
    /// 状态和转换条件在这统一初始化添加
    /// 默认 除了skill和fight状态 其余状态要切换到其他状态的时候 要先切换到idle状态
    /// </summary>
    protected override void InitStateMachine()
    {
        stateDic   = new Dictionary <StateID, FSMState>();
        m_FSM      = new FSMSystem();
        idleState  = new PlayerIdleState();
        moveState  = new PlayerMoveState();
        fightState = new PlayerFightState();
        skillState = new PlayerSkillState();


        //attr = player.GetComponent<AttrController>();
        m_FSM.attr = attr;

        m_FSM.AddState(idleState, this);
        stateDic.Add(idleState.ID, idleState);
        idleState.AddTransition(Transition.IsIdle, StateID.Idle);
        idleState.AddTransition(Transition.IsMove, StateID.Move);
        idleState.AddTransition(Transition.IsDeath, StateID.Death);
        idleState.AddTransition(Transition.IsFight, StateID.Fight);
        idleState.AddTransition(Transition.IsCast_Skill, StateID.Cast_Skill);
        idleState.AddTransition(Transition.IsRiding, StateID.Riding);
        idleState.AddTransition(Transition.IsVigilance, StateID.Vigilance);
        idleState.AddTransition(Transition.IsChatStart, StateID.ChatStart);
        idleState.AddTransition(Transition.IsChatEnd, StateID.ChatEnd);


        m_FSM.AddState(moveState, this);
        stateDic.Add(moveState.ID, moveState);
        moveState.AddTransition(Transition.IsIdle, StateID.Idle);

        m_FSM.AddState(fightState, this);
        stateDic.Add(fightState.ID, fightState);
        fightState.AddTransition(Transition.IsIdle, StateID.Idle);
        fightState.AddTransition(Transition.IsCast_Skill, StateID.Cast_Skill);
        fightState.AddTransition(Transition.IsMove, StateID.Move);

        m_FSM.AddState(skillState, this);
        stateDic.Add(skillState.ID, skillState);
        skillState.AddTransition(Transition.IsIdle, StateID.Idle);
        skillState.AddTransition(Transition.IsFight, StateID.Fight);

        //初始状态分主城(Idle)和地下城(Fight)
        //设置初始状态(idle状态)

        if (AttrController.Instance.Fight())
        {
            m_FSM.SetCurrentState(fightState);
            m_FSM.CurrentState.m_MyJoystick = ETCInput.GetControlJoystick("MyJoystick");
            //m_FSM.attr.StartCoroutine(fightState.DoLogic());
        }
        else
        {
            m_FSM.SetCurrentState(idleState);
            m_FSM.CurrentState.m_MyJoystick = ETCInput.GetControlJoystick("MyJoystick");
        }
        //m_FSM.attr.StartCoroutine(idleState.DoLogic());
        //idleState.RunLogic();

        //测试战斗状态
        //m_FSM.SetCurrentState(fightState);
        //m_FSM.CurrentState.m_MyJoystick = ETCInput.GetControlJoystick("MyJoystick");
        //m_FSM.attr.StartCoroutine(fightState.DoLogic());
    }
示例#13
0
	private void MakeFSM()
	{
		StayStillState stay = new StayStillState();
		stay.AddTransition(Transition.SawPlayer, StateID.ChasingPlayer);
		
		ChasePlayerState chase = new ChasePlayerState();
		chase.AddTransition(Transition.LostPlayer, StateID.FindPlayer);
		chase.AddTransition(Transition.ReachPlayer, StateID.AttackPlayer);
		
		AttackPlayerState attack = new AttackPlayerState();
		attack.AddTransition(Transition.LostPlayer, StateID.ChasingPlayer);
		
		//StayStillState stay = new StayStillState();
		
		fsm = new FSMSystem();
		fsm.AddState(stay);
		fsm.AddState(chase);
		fsm.AddState(attack);
		//fsm.AddState(stay);
		fsm.SetCurrentState(stay);
	}
示例#14
0
 private void MakeFSM()
 {
     fsm = facade.Fsm;
     fsm.SetCurrentState(facade.MainMenuState);
 }