void SetTerrainType() { for (int i = 0; i < cellCount; i++) { TriCell cell = grid.GetCell(i), hexCell = grid.GetCell(TriMetrics.TriToHex(cell.coordinates)); if (cell.coordinates == hexCell.coordinates) { float moisture = climate[hexCell.Index].moisture; TriDirection d = TriDirection.VERT; TriIsleland isle = TriIsleland.Instance; for (int j = 0; j < 6; j++) { if (!cell) { break; } if (!cell.IsUnderwater) { if (cell.Elevation > 10) { cell.TerrainTypeIndex = 4; } else if (moisture < 0.02f) { cell.TerrainTypeIndex = 3; if (Random.value < 0.5f && !cell.HasRiver) { Tree t = (Tree)Instantiate(TriIsleland.GetNaturalPrefabs((int)NaturalType.TREE, 0), isle.transform); t.Location = cell; t.EntranceDirection = (TriDirection)((int)(Random.value * 3f)); entities.AddNatural(t); } } else if (moisture < 0.12f) { cell.TerrainTypeIndex = 2; if (Random.value < 0.2f && !cell.HasRiver) { Tree t = (Tree)Instantiate(TriIsleland.GetNaturalPrefabs((int)NaturalType.TREE, 0), isle.transform); t.Location = cell; t.EntranceDirection = (TriDirection)((int)(Random.value * 3f)); entities.AddNatural(t); } } else if (moisture < 0.20f) { cell.TerrainTypeIndex = 1; } else if (moisture < 0.85f) { cell.TerrainTypeIndex = 0; } else { cell.TerrainTypeIndex = 0; } } else { cell.TerrainTypeIndex = 1; } cell = cell.GetNeighbor(d); if (hexCell.inverted) { d = d.Next(); } else { d = d.Previous(); } } } } }
public new static Tree Load(BinaryReader reader) { Tree ret = Instantiate((Tree)TriIsleland.GetNaturalPrefabs((int)NaturalType.TREE, 0)); return(ret); }