Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 KB | None | 0 0
  1. private void Move(GameObject[,] maze, int r, int c)
  2.     {
  3.         Debug.Log("Move");
  4.         int dir = chooseDirection();
  5.  
  6.         // check the direction we've picked
  7.         if (dir == 0) // checks north
  8.         {
  9.             if (maze[r + 1, c].tag == "path")
  10.             {
  11.                 Vector3 target = new Vector3(maze[r + 1, c].transform.position.x, 2.5f, maze[r + 1, c].transform.position.z);
  12.  
  13.                 transform.position = target;
  14.                 currRow += 1;
  15.                 }
  16.         }
  17.         else if (dir == 1) // checks east
  18.         {
  19.             if (maze[r, c + 1].tag == "path")
  20.             {
  21.                 Vector3 target = new Vector3(maze[r, c + 1].transform.position.x, 2.5f, maze[r, c + 1].transform.position.z);
  22.  
  23.                 transform.position = target;
  24.                 currCol += 1;
  25.             }
  26.         }
  27.         else if (dir == 2) // checks south
  28.         {
  29.             if (maze[r - 1, c].tag == "path")
  30.             {
  31.                 Vector3 target = new Vector3(maze[r - 1, c].transform.position.x, 2.5f, maze[r - 1, c].transform.position.z);
  32.  
  33.                 transform.position = target;
  34.                 currRow -= 1;
  35.             }
  36.         }
  37.         else if (dir == 3) // checks west
  38.         {
  39.             if (maze[r, c - 1].tag == "path")
  40.             {
  41.                 Vector3 target = new Vector3(maze[r, c - 1].transform.position.x, 2.5f, maze[r, c - 1].transform.position.z);
  42.  
  43.                 transform.position = target;
  44.                 currCol -= 1;
  45.             }
  46.         }
  47.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement