Пример #1
0
        public void SwitchToNewState(MotorStates newStateType)
        {
            if (currentStateType != newStateType)
            {
                currentStateType = newStateType;

                currentStateClass.StateExit();
                currentStateClass = stateClassLookup[newStateType];
                currentStateClass.StateEntry();
            }
        }
Пример #2
0
        void Awake()
        {
            //Reference
            Rb               = GetComponent <Rigidbody>();
            Raycaster        = GetComponent <MotorRaycaster>();
            feedback         = GetComponentInChildren <PlayerFeedbacks>();
            cameraController = GetComponent <Player3rdPersonCamera>();

            //Initialize
            Instance = this;

            status           = new PlayerControllerStatus();
            stateClassLookup = new Dictionary <MotorStates, MotorStateBase>
            {
                { MotorStates.OnGround, new MotorState_MoveOnGround(this, feedback) },
                { MotorStates.Aerial, new MotorState_Aerial(this, feedback) },
                { MotorStates.Dead, new MotorState_Dead(this, feedback) },
                //{MotorStates.Hurt,      new MotorState_Hurt(this, Feedbacks)},
            };

            currentStateType  = MotorStates.OnGround;
            currentStateClass = stateClassLookup[currentStateType];
        }