public int ChangeState(string targetStateName, object parameters)
    {
        if (!allState.ContainsKey(targetStateName))
        {
            return(1);
        }

        string curStateName = _curState != null?_curState.GetName() : string.Empty;

        if (curStateName == targetStateName)
        {
            return(2);
        }

        if (_curState != null)
        {
            _curState.OnExit(targetStateName);
        }

        allState[targetStateName].OnEnter(curStateName, parameters);

        _curState = allState[targetStateName];

        return(0);
    }
    public ICommonState GetState(string key)
    {
        ICommonState ret = null;

        allState.TryGetValue(key, out ret);
        return(ret);
    }
    public IPlayerState GetState(string key)
    {
        if (_stateMachine != null)
        {
            ICommonState state = _stateMachine.GetState(key);

            if (state != null)
            {
                return((IPlayerState)state);
            }
        }

        return(null);
    }
    public bool RegisterState(ICommonState IState, object parameters)
    {
        string stateName = IState.GetName();

        if (allState.ContainsKey(stateName))
        {
            return(false);
        }

        IState.Init(parameters);

        allState.Add(stateName, IState);

        return(true);
    }
    public void UnInit()
    {
        UnRegisterALLState();

        _curState = null;
    }