Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int width;
- public int height;
- public string seed;
- public bool useRandomSeed;
- [Range(0, 100)]
- public int randomFillPercent;
- int [,] map;
- void Start()
- {
- GenerateMap();
- }
- void GenerateMap()
- {
- map = new int[width,height];
- RandomFillMap();
- }
- void RandomFillMap()
- {
- if(useRandomSeed)
- {
- seed = Time.time.ToString();
- }
- System.Random psuedoRandom = new System.Random(seed.GetHashCode());
- for(int x = 0; x < width; x++)
- {
- for(int y = 0; y < height; y++)
- {
- map[x,y] = (psuedoRandom.Next(0, 100) < randomFillPercent) ? 1 : 0;
- }
- }
- }
- void OnDrawGizmos()
- {
- if(map != null)
- {
- //.. Draw Grid (but we never get here, because map == null)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement