示例#1
0
 public void addState(Currency_FSMState playerState)
 {
     if (playerState == null)
     {
         Debug.LogError("FSMState不能为空"); return;
     }
     if (states.ContainsKey(playerState.ID))
     {
         Debug.LogError("状态" + playerState.ID + "已经存在,无法重复添加"); return;
     }
     states.Add(playerState.ID, playerState);
 }
示例#2
0
    public void performTransition(int id)
    {
        if (states.ContainsKey(id) == false)
        {
            Debug.LogError("在状态机里面不存在状态" + id + ",无法进行状态转换!"); return;
        }
        if (id == currentStateID)
        {
            Debug.Log("当前就是" + id.ToString() + "状态"); return;
        }

        Currency_FSMState state = states[id];

        if (currentState != null)
        {
            currentState.exitAction();
        }
        currentState   = state;
        currentStateID = id;
        currentState.startAction();
    }