private bool eligibleHumanMove(short[][][] maze, int x, int y, int newX, int newY) { if (Mummy.eligibleLivingThingsMove(maze, x, y, newX, newY)) { return(!(LivingThings.digit(maze[newX][newY][0], 5) == 1)); } else { return(false); } }
public static State keyCheck(State state, LivingThings objects) { if (LivingThings.digit(state.getMaze()[objects.getX()][objects.getY()][0], 6) == 1) { //Key check for (int i = 0; i < state.getKey().Length; i++) { if (state.getKey()[i].samePlace(objects)) { state.setMaze(state.getKey()[i].changeState(state.getMaze())); } } } return(state); }
public short[][][] changeState(short[][][] maze) { int otherSide = (LivingThings.digit(maze[this.xWall][this.yWall][0], this.side) + 1) % 2; maze[this.xWall][this.yWall][0] = editDigit(maze[this.xWall][this.yWall][0], this.side, otherSide); // Also changeState the relevant unit int xRelevant = 0, yRelevant = 0; if (this.side == 1) { //left --> Unit on the left changes right wall state xRelevant = this.xWall; yRelevant = this.yWall - 1; } else if (this.side == 2) { //down xRelevant = this.xWall + 1; yRelevant = this.yWall; } else if (this.side == 3) { //right xRelevant = this.xWall; yRelevant = this.yWall + 1; } else if (this.side == 4) { //up xRelevant = this.xWall - 1; yRelevant = this.yWall; } int relevantSide = (this.side + 2) % 4; if (relevantSide == 0) { relevantSide += 4; } maze[xRelevant][yRelevant][0] = editDigit(maze[xRelevant][yRelevant][0], relevantSide, otherSide); return(maze); }
public bool samePlace(LivingThings thing) { return((this.getX() == thing.getX()) && (this.getY() == thing.getY())); }