// public Layer vehicle1; // public Layer vehicle2; public Tile(GroundLayer baseLayer, TileLogistic tileLogistic, int tileX, int tileY) { //landtype just all starts as water //when we expand our shunk map the landtype gets set? this.tileLogistic = tileLogistic; this.baseLayer = baseLayer; location = new Vector2((tileX * GroundLayerController.tileSize) + GroundLayerController.halfTileSize, (tileY * GroundLayerController.tileSize) + GroundLayerController.halfTileSize); }
public MoveMarker(Point tilePoint) { sprite = new Sprite(new Rectangle(0, 0, 64, 64), GraphicsManager.GetTextureSheet(TextureSheet.WorldUI)); TileLogistic tileLogistic = WorldController.GetTileLogistic(tilePoint); location = new Vector2(tilePoint.X * GroundLayerController.tileSize + tileLogistic.center.X, tilePoint.Y * GroundLayerController.tileSize + tileLogistic.center.Y); fadeIn = true; fade = 0; }
public Location(int tileX, int tileY, VehicleParameters vehicleParameters, Sprite sprite) { this.vehicleParameters = vehicleParameters; this.tileX = tileX; this.tileY = tileY; TileLogistic tileLogistic = WorldController.world.tileGrid[tileX, tileY].tileLogistic; position = new Vector2((tileX * GroundLayerController.tileSize), (tileY * GroundLayerController.tileSize)) + tileLogistic.center; direction = tileLogistic.GetDefaultDirectionRadian(); Point newPoint = AngleStuff.AddPointToDirection(new Point(tileX, tileY), tileLogistic.GetDefaultDirectionMirror()); backTileX = newPoint.X; backTileY = newPoint.Y; WorldController.world.tileGrid[backTileX, backTileY].vehicle = vehicleParameters.vehicle; WorldController.world.tileGrid[tileX, tileY].vehicle = vehicleParameters.vehicle; }
//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); } } } } } }
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 void Draw(SpriteBatch spriteBatch, List <VAction> actionList) { Vector2 start; Vector2 end; float rotation; Vector2 scale; start = location.position; outerScale = switcher(outerScaleUp, out outerScaleUp, outerScale, 0.8f, 1f, 0.01f); outerFade = switcher(outerFadeUp, out outerFadeUp, outerFade, 0.5f, 0.8f, 0.01f); lineFade = switcher(lineFadeUp, out lineFadeUp, lineFade, 0.5f, 0.8f, 0.01f); if (actionList.Count > 0) { spriteBatch.Draw(innerCircleSprite.texture2D, start, innerCircleSprite.location, Color.White * 0.8f, 0, innerCircleSprite.rotationCenter, 0.7f, SpriteEffects.None, 0); } foreach (VAction action in actionList) { if (action.actionState != ActionState.Cancelling && !action.ignoreDraw) { TileLogistic tileLogistic = WorldController.GetTileLogistic(action.destinationPoint); end = new Vector2(action.destinationPoint.X * GroundLayerController.tileSize + tileLogistic.center.X, action.destinationPoint.Y * GroundLayerController.tileSize + tileLogistic.center.Y); scale = new Vector2(Vector2.Distance(start, end), 1); rotation = (float)Math.Atan2(end.Y - start.Y, end.X - start.X); spriteBatch.Draw(spriteLineSprite.texture2D, start, spriteLineSprite.location, Color.White * 0.5f, rotation, spriteLineSprite.rotationCenter, scale, SpriteEffects.None, 0); start = end; //Draw end circle spriteBatch.Draw(outerCircleSprite.texture2D, end, outerCircleSprite.location, Color.White * outerFade, 0, outerCircleSprite.rotationCenter, outerScale, SpriteEffects.None, 0); spriteBatch.Draw(innerCircleSprite.texture2D, end, innerCircleSprite.location, Color.White * 0.9f, 0, innerCircleSprite.rotationCenter, 1f, SpriteEffects.None, 0); } } }
private bool EndOrDirectionBlock(Point newPoint, TileLogistic newLogistic, int directionBlock) { return(newLogistic.IsDirectionBlock(directionBlock) || newPoint == endPoint); }
public void SetChildObject(MapObject mapObject, bool deleteBase, bool deleteLayerList, TileLogistic tileLogistic, bool changeTileLogistic) { childObject = mapObject; if (deleteLayerList) { layerList = null; } if (deleteBase) { baseLayer = null; } if (changeTileLogistic) { this.tileLogistic = tileLogistic; } }
//to save a variable we only use child object. to find if its a parent object we just need to see //if mapobject is not null public void AddMapObject(MapObject mapObject, bool deleteBase, bool deleteLayerList, bool includeChildObject, TileLogistic tileLogistic, bool changeTileLogistic) { //We could also change this to have a bool of drawlayers or not this.mapObject = mapObject; if (includeChildObject) { childObject = mapObject; } if (deleteLayerList) { layerList = null; } if (deleteBase) { baseLayer = null; } if (changeTileLogistic) { this.tileLogistic = tileLogistic; } }
public void SetTileLogistic(TileLogistic tileLogistic) { this.tileLogistic = tileLogistic; }