Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static function IsWin(tile : GameObject)
- { var hit : RaycastHit;
- if(tile.renderer.material.color == Color.blue)
- if(tile.transform.position != Vector3(2,4,0))
- {
- if(Physics.Raycast(tile.transform.position,Vector3.right,hit,1))
- if(hit.transform.gameObject.renderer.material.color == Color.blue)
- {
- if(!lastLeft || lastLeft == null)
- {
- lastRight = true;
- lastLeft = false;
- lastUp = false;
- lastDown =false;
- Debug.Log("IT WORKS RIGHT " + hit.transform.position);
- IsWin(hit.transform.gameObject);
- }
- }
- else if(Physics.Raycast(tile.transform.position,Vector3(-1,0,0),hit,1))
- {
- if(hit.transform.gameObject.renderer.material.color == Color.blue)
- {
- if(!lastRight || lastRight == null)
- {
- lastRight = false;
- lastLeft = true;
- lastUp = false;
- lastDown = false;
- Debug.Log("IT WORKS LEFT " + hit.transform.position);
- IsWin(hit.transform.gameObject);
- }
- }
- }
- if(Physics.Raycast(tile.transform.position,Vector3(0,1,0),hit,1))
- {
- if(hit.transform.gameObject.renderer.material.color == Color.blue)
- {
- if(!lastDown || lastDown == null)
- {
- lastRight = false;
- lastLeft = false;
- lastUp = true;
- lastDown =false;
- Debug.Log("IT WORKS UP " + hit.transform.position);
- IsWin(hit.transform.gameObject);
- }
- }
- }
- if(Physics.Raycast(tile.transform.position,Vector3(0,-1,0),hit,1))
- {
- if(hit.transform.gameObject.renderer.material.color == Color.blue)
- {
- if(!lastUp || lastUp == null)
- {
- lastRight = false;
- lastLeft = false;
- lastUp = false;
- lastDown = true;
- Debug.Log("IT WORKS DOWN " + hit.transform.position);
- IsWin(hit.transform.gameObject);
- }
- }
- }
- else
- {
- return;
- }
- }
- else
- {
- Debug.Log("YOU MOTHERFUCKING WON");
- win = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement