public ExpandShrunkWorld(Tile[,] tileGrid, ShrunkNode[,] shrunkMap, LoadingInfo loadingInfo) { float percentDone = 0; float percentJump = 100f / ShrunkWorldBuilder.shrunkWorldWidth; for (int x = 0; x < ShrunkWorldBuilder.shrunkWorldWidth; x++) { percentDone += percentJump; loadingInfo.UpdateLoading(LoadingType.ExpandingShrunkWorld, percentDone); for (int y = 0; y < ShrunkWorldBuilder.shrunkWorldHeight; y++) { for (int useX = (x * 2); useX < (x * 2) + 2; useX++) { for (int useY = (y * 2); useY < (y * 2) + 2; useY++) { LandType landType = shrunkMap[x, y].landType; if (landType == LandType.PLOT) { landType = LandType.OPEN; } tileGrid[useX, useY].SetTileLogistic(TileLogisticsController.GetTileLogistic(landType, 0)); } } } } }
public AddingRoadTiles(Tile[,] tileGrid, LoadingInfo loadingInfo) { float percentDone = 0; float percentJump = 100f / CreatingWorld.worldWidth; List <Point> pointsToUpdateList = new List <Point>(); for (int x = 0; x < CreatingWorld.worldWidth; x++) { percentDone += percentJump; loadingInfo.UpdateLoading(LoadingType.AddingRoadTiles, percentDone); for (int y = 0; y < CreatingWorld.worldHeight; y++) { if (CheckRoad(x, y, 0, tileGrid)) { int bitCount = BitMaskValue(x, y, tileGrid); if (bitCount > -1) { Tile tile = tileGrid[x, y]; int index = BitMask.GetTileIndexFromBitmask(bitCount); if (index > -1 && index < 56) { if (tile.GetLandType() == LandType.CITYROAD) { tile.AddLayer(GroundLayerController.GetLayerByIndex(LayerType.CITYROAD, index)); tile.SetTileLogistic(TileLogisticsController.GetTileLogistic(LandType.CITYROAD, index)); } else if (tile.GetLandType() == LandType.COUNTRYROAD) { tile.AddLayer(GroundLayerController.GetLayerByIndex(LayerType.COUNTRYROAD, index)); tile.SetTileLogistic(TileLogisticsController.GetTileLogistic(LandType.COUNTRYROAD, index)); } } /*else if (index == 56) * { * pointsToUpdateList.Add(new Point(x, y)); * }*/ } } } } }
private void FixSpot(Point point, Tile[,] tileGrid) { Point nextPoint = point; for (int i = 2; i < 7; i += 1) { if (CreatingWorld.IsRoad(tileGrid, nextPoint)) { int id = tileGrid[nextPoint.X, nextPoint.Y].tileLogistic.roadId; if (id < 12) //Lets try do every road { LandType landtype = tileGrid[nextPoint.X, nextPoint.Y].tileLogistic.landType; tileGrid[nextPoint.X, nextPoint.Y].SetTileLogistic(TileLogisticsController.GetTileLogistic(landtype, id + 12)); } } nextPoint = AngleStuff.AddPointToDirection(point, i); } }
//Instead of just having a level //make the level determine the chance of a tree landing there public AddingTrees(Tile[,] tileGrid, double[,] treeMap, LoadingInfo loadingInfo) { Random rnd = GameController.GetRandomWithSeed(); double treeLevel = 0; //-6 to positive 6 float percentDone = 0; float percentJump = 100f / CreatingWorld.worldWidth; for (int x = 0; x < CreatingWorld.worldWidth; x++) { percentDone += percentJump; loadingInfo.UpdateLoading(LoadingType.AddingTrees, percentDone); for (int y = 0; y < CreatingWorld.worldHeight; y++) { //basically between 0 and 200 int i = (int)((treeMap[x, y] + 8)) * 10; if (rnd.Next(0, 200) < i) { if (treeMap[x, y] > treeLevel) { if (tileGrid[x, y].GetChildObject() == null && tileGrid[x, y].GetLandType() == Game.LandType.OPEN) { float p = (float)(rnd.Next(500, 800)) / 1000f; int type = rnd.Next(0, 8); Tree tree = MapObjectController.GetTree(type); MapObject mapObject = new MapObject(tree, x, y, Color.White, p); TileLogistic tileLogistic = TileLogisticsController.GetTileLogistic(LandType.TREE, 0); tileGrid[x, y].AddMapObject(mapObject, false, false, true, tileLogistic, true); } } } } } }
protected override void Initialize() { debugDrawTimeStopwatch = new Stopwatch(); // Window.IsBorderless = false; Data.SetSettings(); ScreenController.graphicsDevice = GraphicsDevice; DisplayController.Init(this); EngineController.Init(); GraphicsManager.Init(Content); AudioManager.Init(Content); //Game specific init. this could probably be done in game load GroundLayerController.Init(); AngleStuff.Init(); PieceController.Init(); ShadowSpriteController.Init(); MapObjectController.Init(); TileLogisticsController.Init(); GraphicsDevice.Clear(Color.White); IsMouseVisible = true; base.Initialize(); ScreenController.ChangeScreen(new MenuMain()); }
private void AddBuildingToMap(Point topLeft, Building building, Tile[,] tileGrid, Random rnd) { Color color = building.GetColorFromAvailable(rnd); MapObject mapObject = new MapObject(building, topLeft.X, topLeft.Y, color, 1f); TileLogistic tileLogistic = TileLogisticsController.GetTileLogistic(LandType.BUILDING, 0); tileGrid[topLeft.X, topLeft.Y].AddMapObject(mapObject, false, false, false, tileLogistic, true); for (int x = 0; x < building.width; x++) { for (int y = 0; y < building.height; y++) { if (building.isPiece(x, y)) { tileGrid[x + topLeft.X, y + topLeft.Y].SetChildObject(mapObject, false, true, tileLogistic, true); } //add burn rates for hte tile etc //here we also need to switch the tile type to what it is //in this case, a } } }
public LandMass(Tile[,] tileGrid, double[,] waterMap, LoadingInfo loadingInfo) { //following number is amount of ground layers groundLevels = new double[50]; float value = -5.5f; for (int i = 0; i < groundLevels.Length; i++) { groundLevels[i] = value; value += 0.20f; } float percentDone = 0; float percentJump = 100f / CreatingWorld.worldWidth; for (int x = 0; x < CreatingWorld.worldWidth; x++) { percentDone += percentJump; loadingInfo.UpdateLoading(LoadingType.BuildingLandMass, percentDone); for (int y = 0; y < CreatingWorld.worldHeight; y++) { if (tileGrid[x, y] == null) { int layerIndex = GetLayerIndex(waterMap[x, y]); LayerType layerType = (LayerType)layerIndex; if (layerIndex > waterCoastline) { Tile tile = new Tile(GroundLayerController.GetRandomLayer(layerType), TileLogisticsController.GetTileLogistic(LandType.OPEN, 0), x, y); tileGrid[x, y] = tile; } else { Tile tile = new Tile(GroundLayerController.GetRandomLayer(layerType), TileLogisticsController.GetTileLogistic(LandType.WATER, 0), x, y); tileGrid[x, y] = tile; } if (x == 0 || x == CreatingWorld.worldWidth - 1 || y == 0 || y == CreatingWorld.worldHeight - 1) { Tile tile = new Tile(GroundLayerController.GetLayerByIndex(LayerType.BORDER, 0), TileLogisticsController.GetTileLogistic(LandType.BORDER, 0), x, y); tileGrid[x, y] = tile; } } } } }