Ejemplo n.º 1
0
 private void HandleInput(MovementInstruction instruction)
 {
     if (_playerMovementManager.GetState() == this && _playerMovementManager.IsValidMove(instruction))
     {
         _playerMovementManager.SetState(new EntityMovingState(_playerMovementManager, instruction));
     }
 }
Ejemplo n.º 2
0
        private void HandleCollision(GameObject hit)
        {
            PlayerMovementManager playerMovementManager = hit.GetComponent <PlayerMovementManager>();

            if (playerMovementManager == null)
            {
                return;
            }

            IState            state             = playerMovementManager.GetState();
            EntityMovingState entityMovingState = state as EntityMovingState;

            if (entityMovingState == null)
            {
                return;
            }

            MovementInstruction instruction = new MovementInstruction(entityMovingState.Instruction.Direction);

            _movementManager.SetState(new EntityMovingState(_movementManager, instruction));
        }