// Use this for initialization void Start() { _Tiles = new GroundTile[_Width] []; for (int x = 0; x < _Width; x++) { _Tiles[x] = new GroundTile[Depth]; } _gemLimits[GemType.BRONZE] = new Vector2 (0, 60); _gemLimits[GemType.SILVER] = new Vector2 (10, 80); _gemLimits[GemType.GOLD] = new Vector2 (30, 100); Random.seed = (int)Time.time; for (int i = 0; i < _Width; i++) { for (int j = 0; j < Depth; j++) { float gemProbability = 0.2f + 0.6f * (j / (float)Depth); bool isGem = gemProbability > Random.Range(0.0f, 1.0f); if (isGem) { _Tiles[i][j] = new GroundTile (GroundTileType.GEM); float probaSum = 0.0f; Dictionary<GemType, float> gemProbas = new Dictionary<GemType, float>(); for(int g = 0; g < (int)GemType.GEM_TYPE_COUNT; g++) { gemProbas[(GemType)g] = getProbability(j, (GemType)g); probaSum += gemProbas[(GemType)g]; } float r = Random.Range(0.0f, probaSum); float offset = 0.0f; for(int g = 0; g < (int)GemType.GEM_TYPE_COUNT; g++) { if(r < offset + gemProbas[(GemType)g]) { _Tiles[i][j].setGemType((GemType)g); break; } else { offset += gemProbas[(GemType)g]; } } } else { _Tiles[i][j] = new GroundTile (GroundTileType.EARTH); } } } _Tiles[4][0] = new GroundTile (GroundTileType.INDESTRUCTIBLE); _Tiles[5][0] = new GroundTile (GroundTileType.INDESTRUCTIBLE); string test = ""; for (int j = 0; j < Depth; j++) { test += j + " "; for (int i = 0; i < _Width; i++) { GroundTileType type = _Tiles[i][j].getGroundType(); if (type == GroundTileType.EARTH) { test += "X "; } else if (type == GroundTileType.INDESTRUCTIBLE) { test += "I "; } else if (type == GroundTileType.GEM) { int gem = (int)_Tiles[i][j].getGemType(); test += gem + " "; } } test += "\n"; } Debug.Log (test); }