private void FillHeight(ref TextureProperties prop, int x, int y) { var center = _wd.HeightShowData[x][y]; var vals = GetData(_wd.HeightShowData, x, y, center); //var temperature = _wd.TempData[x][y]; var textureName = ""; //if (temperature == TemperatureGenerator.Frozen || temperature == TemperatureGenerator.Cold) //{ // switch (center) // { // case HeightGenerator.DeepOcean: // case HeightGenerator.Ocean: // case HeightGenerator.ShallowOcean: // textureName = "water_snow"; // break; // case HeightGenerator.Beach: // textureName = "beach"; // break; // case HeightGenerator.Plains: // case HeightGenerator.Hills: // case HeightGenerator.Mountains: // textureName = "snow"; // break; // } //} //else //{ switch (center) { case HeightGenerator.DeepOcean: textureName = "water_deep"; break; case HeightGenerator.Ocean: textureName = "water_ocean"; break; case HeightGenerator.ShallowOcean: textureName = "water_shallow"; break; case HeightGenerator.Beach: textureName = "beach"; break; case HeightGenerator.Plains: case HeightGenerator.Hills: case HeightGenerator.Mountains: textureName = "plains"; break; } //} //SetBounds(textureName, ref _land, vals, x, y); prop.SetLocations(textureName, vals); }
private bool CanFillTrees(ref TextureProperties prop, int x, int y) { var center = _wd.ForestShowData[x][y]; if (center == ForestGenerator.None) return false; //var temperature = _wd.TempData[x][y]; var vals = GetDataOther(_wd.ForestShowData, x, y); var textureName = ""; //switch (temperature) //{ // case TemperatureGenerator.Cold: // textureName = "trees_snow"; // break; // case TemperatureGenerator.Mild: textureName = "trees_plain"; // break; // case TemperatureGenerator.Warm: // textureName = "trees_jungle"; // break; // case TemperatureGenerator.Hot: // textureName = "trees_desert"; // break; //} //return SetBounds(textureName, ref _landFeature, vals, x, y); prop.SetLocations(textureName, vals); return true; }
public MiniTileManager() { _wd = WorldData.MyWorldData; _mainAtlas = PlayScreen.DecorationAtlas; _mainTextures = PlayScreen.DecorationTexture; _spriteBatch = PlayScreen.Spritebatch; //_mapMakerThread = new Thread(CheckMiniMap); _halfAmount = (int) (Math.Floor(Amount/2.0)); _xOffset = PlayScreen.SpawnX - _halfAmount; _yOffset = PlayScreen.SpawnY - _halfAmount; _land = new MiniTileCollection[Amount,Amount]; _landFeature = new MiniTileCollection[Amount,Amount]; _fog = new MiniFogCollection[Amount,Amount]; _landTextureLocations = new TextureProperties[MainGame.MapWidth][]; _landFeatureTextureLocations = new TextureProperties[MainGame.MapWidth][]; _graphicsDevice = MainGame.GraphicD; _miniMapFogTexture = new RenderTarget2D(MainGame.GraphicD, 256, 256, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.DiscardContents); _miniMapTerrainTexture = new RenderTarget2D(MainGame.GraphicD, 256, 256, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.DiscardContents); _miniMapTerrainTexture2 = new RenderTarget2D(MainGame.GraphicD, 256, 256, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.DiscardContents); _miniMapFinalDrawTexture = new RenderTarget2D(MainGame.GraphicD, 256, 256, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.DiscardContents); //testing _textureMask = CreateCircle(76); var m = Matrix.CreateOrthographicOffCenter(0, _miniMapFogTexture.Width, _miniMapFogTexture.Height, 0, 0,1); _a = new AlphaTestEffect(_graphicsDevice) { Projection = m }; _s1 = new DepthStencilState { StencilEnable = true, StencilFunction = CompareFunction.Always, StencilPass = StencilOperation.Replace, ReferenceStencil = 1, DepthBufferEnable = false, }; _s2 = new DepthStencilState { StencilEnable = true, StencilFunction = CompareFunction.LessEqual, StencilPass = StencilOperation.Keep, ReferenceStencil = 1, DepthBufferEnable = false, }; for (var x = 0; x < MainGame.MapWidth; x++) { _landTextureLocations[x] = new TextureProperties[MainGame.MapHeight]; _landFeatureTextureLocations[x] = new TextureProperties[MainGame.MapHeight]; for (var y = 0; y < MainGame.MapHeight; y++) { var landtext = new TextureProperties(); var landfeaturetext = new TextureProperties(); FillHeight(ref landtext, x, y); if (!CanFillTrees(ref landfeaturetext, x, y)) { if (!CanFillGrass(ref landfeaturetext, x, y)) { if (!CanFillMountains(ref landfeaturetext, x, y)) landfeaturetext.HasFeature = false; } } _landTextureLocations[x][y] = landtext; _landFeatureTextureLocations[x][y] = landfeaturetext; } } for (var i = 0; i < Amount; i++) { var left = i - 1 < 0 ? Amount - 1 : i - 1; var right = i + 1 >= Amount ? 0 : i + 1; for (var j = 0; j < Amount; j++) { _fog[i, j] = new MiniFogCollection(); var top = j - 1 < 0 ? Amount - 1 : j - 1; var bottom = j + 1 >= Amount ? 0 : j + 1; _land[i, j] = new MiniTileCollection(i + _xOffset, j + _yOffset, i, j, top, bottom, left, right); _landFeature[i, j] = new MiniTileCollection(i + _xOffset, j + _yOffset, i, j, top, bottom, left, right); if (i == 0 && j == 0) _topLeft = _land[i, j]; else if (i == Amount - 1 && j == Amount - 1) _bottomRight = _land[i, j]; var prop = _landTextureLocations[_land[i, j].MapLocX][_land[i, j].MapLocY]; SetBounds(prop.TextureName, ref _land[i, j], prop.Vals, false); _land[i, j].Visible = true; var prop2 = _landFeatureTextureLocations[_landFeature[i, j].MapLocX][_landFeature[i, j].MapLocY]; if (prop2.HasFeature) { SetBounds(prop2.TextureName, ref _landFeature[i, j], prop2.Vals, prop2.IsMountain); _landFeature[i, j].Visible = true; } else _landFeature[i, j].Visible = false; _fog[i, j].SetSpots(i, j); FillFog(i, j); } } InitialDraw(); }
private bool CanFillMountains(ref TextureProperties prop, int x, int y) { var center = _wd.HeightShowData[x][y]; if (center != HeightGenerator.Hills && center != HeightGenerator.Mountains) return false; // var temperature = _wd.TempData[x][y]; var forest = _wd.ForestData[x][y]; var textureName = center == HeightGenerator.Hills ? "hill_" : "mountain_"; //switch (temperature) //{ // case TemperatureGenerator.Cold: // textureName += "snow"; // break; // case TemperatureGenerator.Mild: textureName += "plain"; // break; // case TemperatureGenerator.Warm: // textureName += "jungle"; // break; // case TemperatureGenerator.Hot: // textureName += "desert"; // break; //} if (center != HeightGenerator.Mountains) textureName = forest > ForestGenerator.None ? textureName + "_trees" : textureName; if (textureName.Length != 0) { prop.SetLocations(textureName, true); return true; } #if DEBUG else System.Diagnostics.Debug.WriteLine("Bad news, check mini tile manager"); #endif return false; }