private static void randomMove() { int rnd = Random.Range(1, 62); if (rnd == 1) { if (currentRoom.moveForward() != null) { currentRoom = currentRoom.moveForward(); } else { randomMove(); } } else if (rnd == 2) { if (currentRoom.moveBehind() != null) { currentRoom = currentRoom.moveBehind(); } else { randomMove(); } } else if (rnd == 3) { if (currentRoom.moveLeft() != null) { currentRoom = currentRoom.moveLeft(); } else { randomMove(); } } else if (rnd == 4) { if (currentRoom.moveRight() != null) { currentRoom = currentRoom.moveRight(); } else { randomMove(); } } else if (rnd == 5) { if (currentRoom.moveUp() != null) { currentRoom = currentRoom.moveUp(); } else { randomMove(); } } else if (rnd == 6) { if (currentRoom.moveDown() != null) { currentRoom = currentRoom.moveDown(); } else { randomMove(); } } }
void gameScreen() { List <int> coordinate = currentRoom.getCoordinate(); List <int> catCoordinate = Cat.currentRoom.getCoordinate(); print("x: " + coordinate [0] + " y: " + coordinate [1] + " level: " + coordinate [2]); print("Cat: x: " + catCoordinate [0] + " y: " + catCoordinate [1] + " level: " + catCoordinate [2]); if (Timer.isTimeUp()) { currentState = States.End; isGameOn = false; } if (CatDetector.catDistance() == 0) { isGameOn = false; isWin = true; currentState = States.End; } if (Input.GetKeyDown(KeyCode.W)) { if (currentRoom.moveForward() != null) { counter++; print("Move forward successful"); currentRoom = currentRoom.moveForward(); Cat.catMove(); } else { print("invalid move"); } } else if (Input.GetKeyDown(KeyCode.A)) { if (currentRoom.moveLeft() != null) { counter++; print("Move left successful"); currentRoom = currentRoom.moveLeft(); Cat.catMove(); } else { print("invalid move"); } } else if (Input.GetKeyDown(KeyCode.S)) { if (currentRoom.moveBehind() != null) { counter++; print("Move behind successful"); currentRoom = currentRoom.moveBehind(); Cat.catMove(); } else { print("invalid move"); } } else if (Input.GetKeyDown(KeyCode.D)) { if (currentRoom.moveRight() != null) { counter++; print("Move right successful"); currentRoom = currentRoom.moveRight(); Cat.catMove(); } else { print("invalid move"); } } else if (Input.GetKeyDown(KeyCode.C)) { if (currentRoom.moveUp() != null) { counter++; print("Move up successful"); currentRoom = currentRoom.moveUp(); Cat.catMove(); } else { print("invalid move"); } } else if (Input.GetKeyDown(KeyCode.V)) { if (currentRoom.moveDown() != null) { counter++; print("Move down successful"); currentRoom = currentRoom.moveDown(); Cat.catMove(); } else { print("invalid move"); } } }