Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void step() {
- if (askedToGo != null) {
- Position thisPos = owner.getPosition(this);
- Position lclNextPos = thisPos.moveDirection(askedToGo);
- if (owner.canGo(lclNextPos)) {
- IBDObject nextSquare = owner.get(lclNextPos);
- if (nextSquare instanceof BDDiamond)
- diamondCnt++;
- if (nextSquare instanceof BDBug)
- kill();
- if (nextSquare instanceof BDRock) {
- nextSquare = new BDRock(owner);
- BDRock rock = (BDRock) owner.get(lclNextPos);
- if (rock.push(askedToGo)){
- prepareMoveWithTry(lclNextPos);
- }
- else return;
- }
- prepareMoveWithTry(lclNextPos);
- }
- askedToGo = null;
- }
- super.step();
- }
- //Hjelpemetode slik at step() blir noe kortere grunnet try/catch rundt prepareMove()
- private void prepareMoveWithTry(Position pos) {
- try {
- prepareMove(pos);
- } catch (IllegalMoveException e) {
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement