public float GetHeight(TileData t, bool random) { TerrainTypeData tD = _TileTypeDataManager.GetTerrainData(t.Terrain); BuildingTypeData bD = _TileTypeDataManager.GetBuildingData(t.Building); Vector2 range; if (bD.SetHeight) { range = bD.Height; } else if (tD.SetHeight) { range = tD.Height; } else if (random) { range = new Vector2(); } else { return(t.Height); } return(Random.Range(range.x, range.y)); }
/// <summary> /// Draw the tile info panel /// </summary> private void DrawTileInfo() { if (!this.HasWorld) { return; } var position = new Position( this._overviewView.Position.X, this._overviewView.Position.Y + this._overviewView.Dimensions.Height + 1); if (!this._world.DetailedMap.IsDiscovered(this._detailedView.CursorPosition) && this._detailedView.DrawFogOfWar) { this._surface.DrawString(position, "Unknown", UiColors.ActiveText, DefaultColors.Black); return; } this._surface.DrawString(position, TerrainTypeData.GetInfo(this._world.DetailedMap.GetTerrainType(this._detailedView.CursorPosition)).Name, DefaultColors.White, DefaultColors.Black); if (this._detailedView.ShowResources && this._world.DetailedMap.Resources.ContainsKey(this._detailedView.CursorPosition)) { var resourceType = this._world.DetailedMap.Resources[this._detailedView.CursorPosition]; this._surface.DrawString(position + new Position(0, 1), resourceType.DisplayName, DefaultColors.White, DefaultColors.Black); } }
/// <summary> /// Build new tile array from terrain array /// </summary> public virtual void UpdateTiles() { var random = new Random(this.Seed); for (var ix = 0; ix < Dimensions.Width; ++ix) { for (var iy = 0; iy < Dimensions.Height; ++iy) { var terrainType = this.GetTerrainType(new Position(ix, iy)); var info = TerrainTypeData.GetInfo(terrainType); var tile = info.PickTile(random); this.Tiles[ix, iy] = tile; } } }
public void Initialise() { _terrainData = new Dictionary <TerrainType, TerrainTypeData>(); _buildingData = new Dictionary <BuildingType, BuildingTypeData>(); foreach (TileTypeDataBase data in BaseData) { if (data.Tile == TileType.Terrain) { TerrainTypeData tData = (TerrainTypeData)data; _terrainData.Add(tData.Type, tData); } else { BuildingTypeData bData = (BuildingTypeData)data; _buildingData.Add(bData.Type, bData); } } }
private void OnClearAllButtonPressed() { // TerrainTypeTexture.SetPixels(new byte[TerrainTypeTexture.width*TerrainTypeTexture.height].Select(b => defaultColor).ToArray()); Undo.Current.RegisterTerrainTypePaint(); TerrainTypeTexture = null; byte defaultIndex = layersSettings.GetFirstLayer().index; for (int j = 0; j < TerrainTypeSize.y; j++) { for (int i = 0; i < TerrainTypeSize.x; i++) { TerrainTypeData2D[i, j] = defaultIndex; } } TerrainTypeData = TerrainTypeData.Select(b => defaultIndex).ToArray(); ApplyTerrainTypeChanges(); ScmapEditor.Current.TerrainMaterial.SetTexture("_TerrainTypeAlbedo", TerrainTypeTexture); }
private void DrawTileInfo() { if (this._state == null) { return; } var position = new Position( this._overviewView.Position.X, this._overviewView.Position.Y + this._overviewView.Dimensions.Height + 1); if (this._currentCity != null) { this._surface.DrawString(position, $"In Territory: {this._currentCity.Name}", DefaultColors.White, DefaultColors.Black); position += new Position(0, 1); } if (this._cursorSite != null) { this._surface.DrawString(position, $"{this._cursorSite.TypeDescriptor}: {this._cursorSite.Name}", DefaultColors.White, DefaultColors.Black); position += new Position(0, 1); } this._surface.DrawString(position, TerrainTypeData.GetInfo(this._state.World.DetailedMap.GetTerrainType(this._detailedView.CursorPosition)).Name, DefaultColors.White, DefaultColors.Black); if (this._detailedView.ShowResources && this._state.World.DetailedMap.Resources.ContainsKey(this._detailedView.CursorPosition)) { var resourceType = this._state.World.DetailedMap.Resources[this._detailedView.CursorPosition]; this._surface.DrawString(position + new Position(0, 1), resourceType.DisplayName, DefaultColors.White, DefaultColors.Black); } }
/// <summary> /// Retrieves the terrain type info at given position /// </summary> public TerrainTypeInfo GetTerrainInfo(Position position) { return(TerrainTypeData.GetInfo(this.GetTerrainType(position))); }