Advertisement
Guest User

Untitled

a guest
Oct 24th, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. public GameObject pre;
  2.  
  3. public int counter = 0;
  4. public int worldWidth = 20;
  5. public int worldHeight = 20;
  6.  
  7. private float positionX;
  8. private float positionY;
  9.  
  10. void Start()
  11. {
  12. chessBoardCube = Resources.Load<GameObject>("Prefabs/pre");
  13. positionX = -11.24f;
  14. positionY = 4.8f;
  15. counter = 0;
  16. }
  17.  
  18. void Update()
  19. {
  20. for (int x = 0; x < worldWidth; x++)
  21. {
  22. for (int z = 0; z < worldHeight; z++)
  23. {
  24. if (counter % 2 == 0)
  25. {
  26. GameObject block = Instantiate(pre, Vector3.zero, Quaternion.identity) as GameObject;
  27. block.renderer.material.color = Color.black;
  28. block.transform.parent = transform;
  29. float xP = positionX * 3;
  30. float yP = positionY * z;
  31.  
  32. block.transform.localScale = new Vector3(2, 2, 1);
  33. block.transform.localPosition = new Vector3(xP, 0);
  34. }
  35. else
  36. {
  37. GameObject block = Instantiate(pre, Vector3.zero, Quaternion.identity) as GameObject;
  38. block.renderer.material.color = Color.red;
  39. block.transform.parent = transform;
  40. float xP = positionX * x;
  41. float yP = positionY * z;
  42. block.transform.localScale = new Vector3(2, 2, 1);
  43. block.transform.localPosition = new Vector3(xP, 0);
  44. }
  45. }
  46. counter++;
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement