예제 #1
0
 private void HandleInput(MovementInstruction instruction)
 {
     if (_playerMovementManager.GetState() == this && _playerMovementManager.IsValidMove(instruction))
     {
         _playerMovementManager.SetState(new EntityMovingState(_playerMovementManager, instruction));
     }
 }
예제 #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));
        }