Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void Move(GameObject[,] maze, int r, int c)
- {
- Debug.Log("Move");
- int dir = chooseDirection();
- // check the direction we've picked
- if (dir == 0) // checks north
- {
- if (maze[r + 1, c].tag == "path")
- {
- Vector3 target = new Vector3(maze[r + 1, c].transform.position.x, 2.5f, maze[r + 1, c].transform.position.z);
- transform.position = target;
- currRow += 1;
- }
- }
- else if (dir == 1) // checks east
- {
- if (maze[r, c + 1].tag == "path")
- {
- Vector3 target = new Vector3(maze[r, c + 1].transform.position.x, 2.5f, maze[r, c + 1].transform.position.z);
- transform.position = target;
- currCol += 1;
- }
- }
- else if (dir == 2) // checks south
- {
- if (maze[r - 1, c].tag == "path")
- {
- Vector3 target = new Vector3(maze[r - 1, c].transform.position.x, 2.5f, maze[r - 1, c].transform.position.z);
- transform.position = target;
- currRow -= 1;
- }
- }
- else if (dir == 3) // checks west
- {
- if (maze[r, c - 1].tag == "path")
- {
- Vector3 target = new Vector3(maze[r, c - 1].transform.position.x, 2.5f, maze[r, c - 1].transform.position.z);
- transform.position = target;
- currCol -= 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement