Exemplo n.º 1
0
    public PlayerState(IEventManager playerEvent)
    {
        #region Player State Initialization
        _StateIdle              = new IdleState(this);
        _StateWalk              = new WalkState(this);
        _StateSprint            = new SprintState(this);
        _StateFall              = new FallState(this);
        _StateCrouch            = new CrouchState(this);
        _StateJump              = new JumpState(this);
        _StateCrouchWalk        = new CrouchWalkState(this);
        _StateSlide             = new SlideState(this);
        _StateCrouchJump        = new CrouchJumpState(this);
        _StateCrouchFall        = new CrouchFallState(this);
        _StateAirMoveCrouchFall = new AirMoveCrouchFallState(this);
        _StateAirMoveCrouchJump = new AirMoveCrouchJumpState(this);
        _StateAirMoveFall       = new AirMoveFallState(this);
        _StateAirMoveJump       = new AirMoveJumpState(this);
        #endregion

        _ActiveProxies      = new HashSet <IDynamicProxy>();
        _EventPlayer        = playerEvent;
        _CurrentPlayerState = _StateIdle;

        #region State Proxy Initialization
        _MediatorToggleProxy             = new ToggleProxyMediator();
        _ProxySprint                     = new SprintProxy(this, _MediatorToggleProxy);
        _ProxyCrouch                     = new CrouchProxy(this, _MediatorToggleProxy);
        _MediatorToggleProxy.ProxyCrouch = _ProxyCrouch;
        _MediatorToggleProxy.ProxySprint = _ProxySprint;

        _ProxyWalk = new WalkProxy(this, _MediatorToggleProxy);
        _ProxyFall = new FallProxy(this);
        _ProxyJump = new JumpProxy(this, _MediatorToggleProxy);
        #endregion
    }
Exemplo n.º 2
0
    private void Start()
    {
        controller = gameObject.GetComponent <CharacterController>();
        initialFov = theCamera.fieldOfView;

        initialControllerHeight = controller.height;
        initialControllerOffset = controller.center;

        _cameraInitialPos = theCamera.transform.localPosition;

        stateMachine    = new StateMachine();
        idleState       = new IdleState(this, stateMachine);
        walkState       = new WalkState(this, stateMachine);
        runState        = new RunState(this, stateMachine);
        jumpState       = new JumpState(this, stateMachine);
        crouchState     = new CrouchState(this, stateMachine);
        crouchWalkState = new CrouchWalkState(this, stateMachine);
        peekState       = new PeekState(this, stateMachine);
        zoomState       = new ZoomState(this, stateMachine);
        lookBackState   = new LookBackState(this, stateMachine);
        //more states here

        stateMachine.Initialize(idleState);
    }