Advertisement
Guest User

Untitled

a guest
Oct 5th, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static function IsWin(tile : GameObject)
  2. { var hit : RaycastHit;
  3. if(tile.renderer.material.color == Color.blue)
  4.  
  5.   if(tile.transform.position != Vector3(2,4,0))
  6.   {
  7.       if(Physics.Raycast(tile.transform.position,Vector3.right,hit,1))
  8.         if(hit.transform.gameObject.renderer.material.color == Color.blue)
  9.         {  
  10.             if(!lastLeft || lastLeft == null)
  11.             {
  12.             lastRight = true;
  13.             lastLeft = false;
  14.             lastUp = false;
  15.             lastDown =false;
  16.             Debug.Log("IT WORKS RIGHT   " + hit.transform.position);   
  17.             IsWin(hit.transform.gameObject);
  18.             }
  19.         }
  20. else  if(Physics.Raycast(tile.transform.position,Vector3(-1,0,0),hit,1))
  21.       {
  22.         if(hit.transform.gameObject.renderer.material.color == Color.blue)
  23.         {
  24.        
  25.             if(!lastRight || lastRight == null)
  26.             {
  27.             lastRight = false;
  28.             lastLeft = true;
  29.             lastUp = false;
  30.             lastDown  = false;
  31.             Debug.Log("IT WORKS LEFT  " + hit.transform.position);
  32.             IsWin(hit.transform.gameObject);
  33.             }
  34.  
  35.         }
  36.       }
  37.       if(Physics.Raycast(tile.transform.position,Vector3(0,1,0),hit,1))
  38.       {
  39.         if(hit.transform.gameObject.renderer.material.color == Color.blue)
  40.         {  
  41.        
  42.             if(!lastDown || lastDown == null)
  43.             {
  44.                 lastRight = false;
  45.                 lastLeft = false;
  46.                 lastUp  = true;
  47.                 lastDown  =false;
  48.        
  49.             Debug.Log("IT WORKS UP  " + hit.transform.position);
  50.             IsWin(hit.transform.gameObject);
  51.             }
  52.         }
  53.       }
  54.       if(Physics.Raycast(tile.transform.position,Vector3(0,-1,0),hit,1))
  55.       {
  56.         if(hit.transform.gameObject.renderer.material.color == Color.blue)
  57.         {  
  58.        
  59.             if(!lastUp || lastUp == null)
  60.             {
  61.                 lastRight = false;
  62.                 lastLeft = false;
  63.                 lastUp  = false;
  64.                 lastDown  = true;
  65.        
  66.             Debug.Log("IT WORKS DOWN  " + hit.transform.position);
  67.             IsWin(hit.transform.gameObject);
  68.             }
  69.         }
  70.       }
  71.      
  72.       else
  73.         {
  74.             return;
  75.         }
  76.      
  77.   }
  78.   else
  79.   {
  80.   Debug.Log("YOU MOTHERFUCKING WON");
  81.   win = true;
  82.    
  83.   }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement