public float GetIfMountine(int x, int y) { if (!tiles[x, y].IsMountain) { return(0); } bool temp = GetContinuesly(x, y, 1, 0); int m = tiles[x, y].Height; while (temp && m < 50) { m++; temp = GetContinuesly(x, y, m + 1, m); } if (m > 3) { if (x + 1 < size_x) { tiles[x + 1, y].Height = m - 1; if (y + 1 < size_y) { tiles[x + 1, y + 1].Height = m - 1; tiles[x, y + 1].Height = m - 1; } } else if (y + 1 < size_y) { tiles[x, y + 1].Height = m - 1; } } tiles[x, y].Height = m; TCSV t = TileProp[tiles[x, y].type]; return((float)m * Random.Range(t.Height.x, t.Height.y) * t.HeightScale); }
public TDMap(int size_x, int size_y, MapType type, TCSV[] TileChanceC, int MaxHeightForPlants, int MaxWalkableHeight) { CreateTileTypes(TileChanceC); this.size_x = size_x; this.size_y = size_y; MHP = MaxHeightForPlants; MWH = MaxWalkableHeight; tiles = new TDTile[size_x, size_y]; float chance = 0; TCSV tile_t = TileChanceC[0]; for (int x = 0; x < size_x; x++) { for (int y = 0; y < size_y; y++) { chance = 0; foreach (TCSV t in TileChanceC) { float temp = Random.Range(0, (int)TileChance[t.tile_name]); if (temp > chance) { chance = temp; tile_t = t; } } tiles[x, y] = new TDTile(x, y, this, tile_t.tile_name); } } for (int x = 0; x < size_x; x++) { for (int y = 0; y < size_y; y++) { int a = Mathf.Clamp((int)type, 0, 1); GetMoreRealisticTile(x, y, 2 + a); } } for (int x = 0; x < size_x; x++) { for (int y = 0; y < size_y; y++) { int a = Mathf.Clamp(-(int)type, 0, 1); GetMoreRealisticTile(x, y, 2 - a); } } for (int x = 0; x < size_x; x++) { for (int y = 0; y < size_y; y++) { GetMoreRealisticTile(x, y, 1); } } for (int x = 0; x < size_x; x++) { for (int y = 0; y < size_y; y++) { GetMoreRealisticTile(x, y, 2); } } GlobalMap = this; }