public static eTileType GetTileTypeFromTileProperties(cTileProperties properties) { float tempIntegrated = properties.IntegratedTemperature; float tempCurrent = properties.TemperatureInKelvin; float tempMean = (tempCurrent + 99.0f * tempIntegrated) / 100.0f; float height = properties.HeightInMeters; eTileType ret = eTileType.TILETYPE_GRASS; if (tempIntegrated <= _worldProperties.WaterFreezingTemperature) { if (height >= _grassHeightOffset + tempMean * _grassHeightSlope) { ret = eTileType.TILETYPE_SNOW; } else { ret = eTileType.TILETYPE_ICE; } } else { if (height >= _worldProperties.MountainHeight) { ret = eTileType.TILETYPE_MOUNTAIN; } else { if (height <= _grassHeightOffset + _grassHeightSlope * tempMean) { ret = eTileType.TILETYPE_WATER; } else if (height >= _desertHeightOffset + _desertHeightSlope * tempMean) { ret = eTileType.TILETYPE_DESERT; } else { ret = eTileType.TILETYPE_GRASS; } } } return(ret); }
public cTile(Vector2i position, cTileProperties tileProperties, cWorld world) { _positionInTiles = position; _tileProperties = tileProperties; _world = world; _localTime = 0.0f; _refreshTimerMax = (float)RandomGenerator.GetRandomDouble(0.5, 1.5); _refreshTimer = _refreshTimerMax; _tileShape = new RectangleShape(new Vector2f(TileSizeInPixels, TileSizeInPixels)); _tileShape.FillColor = cTileSetter.GetColorFromTileProperties(_tileProperties); _dayNightShape = new RectangleShape(new Vector2f(TileSizeInPixels, TileSizeInPixels)); _dayNightShape.FillColor = new Color(0, 0, 0, 255); _heightShape = new RectangleShape(new Vector2f(TileSizeInPixels, TileSizeInPixels)); _heightShape.FillColor = new Color(0, 0, 0, 255); float centerY = (float)world.GetWorldProperties().WorldSizeInTiles.Y / 2.0f; float yCoordinate = (float)position.Y; //float yFactor = (yCoordinate <= centerY) ? 0.9f + 0.2f/centerY * yCoordinate : 1.3f - 0.2f / centerY * yCoordinate; float yFactor = 0.85f + (float)(0.3 * Math.Sin((float)position.Y / (float)world.GetWorldProperties().WorldSizeInTiles.Y *Math.PI)); //float yFactor = 1.0f; _tileProperties.DayNightCyclePhase = (float)(position.X) / (float)(_world.GetWorldProperties().WorldSizeInTiles.X) * (float)(2.0 * Math.PI) * yFactor; _temperatureControlList = new List <TemperatureControlStrategies.cAbstractTemperatureControlStragegy>(); _temperatureControlList.Add(new TemperatureControlStrategies.cBasicDayNightCycleStrategy(this)); //_temperatureControlList.Add(new TemperatureControlStrategies.cTemperatureExchangeStrategy(this)); NeighbourTiles = new List <ITile>(); _lastTemperaturesList = new Queue <float>(100); for (int i = 0; i != 100; i++) { _lastTemperaturesList.Enqueue(_world.GetWorldProperties().DesiredTemperature); } _temperatureIntegrationTimerMax = _world.GetWorldProperties().TileTemperatureIntegrationTimer; _temperatureIntegrationTimer = _temperatureIntegrationTimerMax; }
public static float GetMoveSpeedOnTileProperties(cTileProperties properties) { float tempCurrent = properties.TemperatureInKelvin; float ret = 2.25f; //float slope = 4.0f/60.0f; //float xOffset = 2.25f - 300.0f* slope; if (tempCurrent <= 270) { ret = 1.0f; } else if (tempCurrent >= 330) { ret = 3.0f; } else { ret = 2.0f; } return(ret); }
public static Color GetColorFromTileProperties(cTileProperties properties) { eTileType type = GetTileTypeFromTileProperties(properties); return(GetColorFromTileType(type)); }
public static void CreateWorld(ref IWorldInCreation world, cWorldProperties properties) { // do all the fancy shit here int sizeX = properties.WorldSizeInTiles.X; int sizeY = properties.WorldSizeInTiles.Y; world.SetWorldProperties(properties); cTileSetter.SetWorldProperties(properties); float heightMapNoiseFrequency = properties.HeightMapNoiseLength; float heightMapMaxHeightInMeter = properties.MaxHeightInMeter; float[,] heightMap1 = new float[sizeX, sizeY]; float[,] heightMap2 = new float[sizeX, sizeY]; float[,] temperattureMap = new float[sizeX, sizeY]; float height1HighestValue = -1; float height1LowestValue = 1; float height2HighestValue = -1; float height2LowestValue = 1; for (int i = 0; i < sizeX; i++) { for (int j = 0; j < sizeY; j++) { heightMap1[i, j] = (Noise.Generate(i / heightMapNoiseFrequency, j / heightMapNoiseFrequency)); if (heightMap1[i, j] >= height1HighestValue) { height1HighestValue = heightMap1[i, j]; } if (heightMap1[i, j] < height1LowestValue) { height1LowestValue = heightMap1[i, j]; } heightMap2[i, j] = (Noise.Generate(i / (heightMapNoiseFrequency * 10.0f), j / (heightMapNoiseFrequency * 10.0f))); if (heightMap2[i, j] >= height2HighestValue) { height2HighestValue = heightMap2[i, j]; } if (heightMap2[i, j] < height2LowestValue) { height2LowestValue = heightMap2[i, j]; } } } for (int i = 0; i < sizeX; i++) { for (int j = 0; j < sizeY; j++) { heightMap2[i, j] = (heightMap2[i, j] - height2LowestValue) / (height2HighestValue - height2LowestValue) * 0.5f + 0.5f; heightMap1[i, j] = (heightMap1[i, j] - height1LowestValue) / (height1HighestValue - height1LowestValue) * heightMapMaxHeightInMeter * heightMap2[i, j]; //Console.WriteLine(heightMap1[i, j]); cTileProperties tileprops = new cTileProperties(); tileprops.HeightInMeters = heightMap1[i, j]; // TODO Do Something about the ugly World Cast cTile tile = new cTile(new Vector2i(i, j), tileprops, world as cWorld); tile.GetTileProperties().TemperatureInKelvin = properties.DesiredTemperature + (float)(RandomGenerator.Random.NextDouble() * 25.0 - 12.0); tile.GetTileProperties().SetFoodAmountOnTile(eFoodType.FOOD_TYPE_MEAT, 0); tile.GetTileProperties().SetFoodAmountOnTile(eFoodType.FOOD_TYPE_PLANT, 0); world.AddTille(tile); } } // ToDo: Overlap on the edges Blend it here. System.Console.WriteLine("Building Tile Neighbour Lists"); world.BuildTileNeighbourLists(); world.CreateClouds(); }