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