Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 16th, 2012  |  syntax: None  |  size: 1.03 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public enum objectType { grass, road };
  6.  
  7. public class MakeGrid : MonoBehaviour {
  8.        
  9.         public int gridWidth;
  10.         public int gridHeight;
  11.         public int space;
  12.        
  13.         public GameObject roadObject;
  14.         public GameObject grassObject;
  15.        
  16.         public List<Vector3> objectPosition;
  17.         public List<objectType> objectRefType;
  18.         public List<int> objectSlotType;
  19.        
  20.        
  21.         // Use this for initialization
  22.         void Start () {
  23.                 objectPosition = new List<Vector3>();
  24.                 objectRefType = new List<objectType>();
  25.                 objectSlotType = new List<int>{ 10,11,12,14,15,16,19,21,23,25,27,28,30,31,32,34,43,46,47,48,49,50,52,55,59,61,64,65,66,68,69,70,75 };
  26.                
  27.                
  28.                 CreateGrid();
  29.         }
  30.        
  31.         void CreateGrid()
  32.         {
  33.                 int topSpace;
  34.                 int widthSpace;
  35.                
  36.                 for ( int x = 0; x < gridWidth; x++ )
  37.                 {
  38.                        
  39.                         for (int y = 0; y < gridHeight; y++ )
  40.                         {
  41.                                  topSpace =  (x * space );
  42.                                  widthSpace =  ( y * space );
  43.                                
  44.                                 objectPosition.Add(new Vector3 (topSpace, widthSpace,0));      
  45.                         }
  46.                        
  47.                 }
  48.         }
  49. }