public virtual void draw(int coordNS, int coordWE, TilePart tilePart, TilePerspective perspective, SpriteBatch spriteBatch) { foreach (TileSection tile in tileSections) { tile.draw(coordNS, coordWE, tilePart, perspective, spriteBatch); } }
private TilePartComponent[] DecodePackets(TilePartHeader tilePartHeader) { var tile = Image.Tiles[tilePartHeader.SOT.I_TileIndexNumber]; var tilePart = new TilePart(tile, tilePartHeader); var tilePartComponents = new TilePartComponent[Image.Components.Length]; for (var iComponent = 0; iComponent < Image.Components.Length; iComponent++) { var tileComponent = tile.TileComponents[iComponent]; tilePartComponents[iComponent] = new TilePartComponent(tilePart, tileComponent); } var progressionOrder = tilePartHeader.COD.SG_ProgressionOrder; if (progressionOrder == ProgressionOrder.LayerResolutionComponentPosition) { DecodePacketsInLayerResolutionComponentPositionOrder(tilePartHeader, tilePartComponents); } else { throw NotSupported(progressionOrder); } return(tilePartComponents); }
public virtual void draw(int coordNS, int coordWE, TilePart tilePart, TilePerspective perspective, SpriteBatch spriteBatch) { float[] heights = drawablePack.getHeightRange(tilePart, minHeight, maxHeight); TileDrawInfo tdi; foreach (float height in heights) { tdi = perspective.getTileDrawInfo(coordNS, coordWE, height, tilePart, slopeInfo); drawablePack.draw(tdi, spriteBatch); } }
public TileDrawInfo(int coordNS, int coordWE, float baseHeight, float adjustedHeight, Direction facing, TilePart tilePart, TileSlopeInfo slopeInfo, Vector2 pos, Vector2 scale, float depth, int depthDigits) { this.coordNS = coordNS; this.coordWE = coordWE; this.baseHeight = baseHeight; this.adjustedHeight = adjustedHeight; this.facing = facing; this.tilePart = tilePart; this.slopeInfo = slopeInfo; this.pos = pos; this.scale = scale; this.depth = depth; this.depthDigits = depthDigits; }
public virtual float[] getHeightRange(TilePart part, float minHeight, float maxHeight) { switch (part) { case TilePart.STRUCTURE: return getHeightRangeStructure(minHeight, maxHeight); case TilePart.SURFACE: return getHeightRangeSurface(minHeight, maxHeight); case TilePart.LEFTFACE: return getHeightRangeLeftFace(minHeight, maxHeight); case TilePart.RIGHTFACE: return getHeightRangeRightFace(minHeight, maxHeight); } return new float[] {minHeight, maxHeight}; }
public virtual void update(TilePart part, int elapsedMillis) { if (part == TilePart.STRUCTURE) { foreach (Drawable dbl in structures) { dbl.update(elapsedMillis); } } else { Drawable dbl = getDrawable(part, -1); dbl.update(elapsedMillis); } }
/* * helpers */ /// <summary> /// returns the drawable based on the TilePart provided and /// the structure index where applicable. /// </summary> /// <param name="part">Specifies which drawable to return</param> /// <param name="structureIndex">Only used when 'part' is STRUCTURE</param> /// <returns></returns> public virtual Drawable getDrawable(TilePart part, int structureIndex) { switch (part) { case TilePart.STRUCTURE: return structures[structureIndex]; case TilePart.SURFACE: return surface; case TilePart.LEFTFACE: return leftFace; case TilePart.RIGHTFACE: return rightFace; } return null; }
public virtual float getTileDepth(int extraDigits, int coordNS, int coordWE, TilePart part) { int digitsNeeded = getDepthDigitsNeeded(extraDigits); Tuple<float, float> dist = getTileDistance(getTopCoord(), new Vector2(coordNS, coordWE)); int drawOrder = -(int)dist.Item2 * getTilesBLtoTR(); drawOrder += (int)dist.Item1; float depth = Utils.shiftRight(drawOrder, digitsNeeded - 1); float partDepth = Utils.shiftRight((int)part, digitsNeeded); depth += partDepth; return depth; }
// TODO use 'part' public virtual Vector2 getTilePixelPosition(int coordNS, int coordWE, float height, TilePart part) { // TODO take scale into account float halfWidth = tilePixelWidth / 2; float halfHeight = tilePixelHeight / 2; Vector2 centerCoord = getCenterCoord(); Tuple<float, float> dist = getTileDistance(centerCoord, new Vector2(coordNS, coordWE)); // item1 is rel. tile coord top left to bottom right // item2 is rel. tile coord bottom left to top right float xAdjust = dist.Item1 + dist.Item2; xAdjust *= halfWidth; float yAdjust = -dist.Item2 + dist.Item1; yAdjust *= halfHeight; Vector2 pxPos = new Vector2(position.X + xAdjust, position.Y + yAdjust); pxPos.Y -= height * tilePixelAltitudeUnit; return pxPos; }
public virtual TileDrawInfo getTileDrawInfo(int coordNS, int coordWE, float height, TilePart part, TileSlopeInfo slopeInfo) { Direction facing = getDirectionFacing(); Vector2 pxPos = getTilePixelPosition(coordNS, coordWE, height, part); Vector2 scale = getScale(); float depth = getTileDepth(depthShift, coordNS, coordWE, part); int digitCount = getDepthDigitsNeeded(depthShift); TileDrawInfo tdi = new TileDrawInfo(coordNS, coordWE, height, height, facing, part, slopeInfo, pxPos, scale, depth, digitCount); adjusters.adjust(tdi); return tdi; }
public TileSummary(int x, int y, TilePart tilePart) { X = x; Y = y; TilePart = tilePart; }