public TrainImageLayer(GameData gameData, TileSet tileSet, int imageIndex, int minMSTimeBeforeShow, int maxMSTimeBeforeShow, double minTrainSpeed, double maxTrainSpeed) { this.minMSTimeBeforeShow = minMSTimeBeforeShow; this.maxMSTimeBeforeShow = maxMSTimeBeforeShow; this.minTrainSpeed = minTrainSpeed; this.maxTrainSpeed = maxTrainSpeed; this.tileSet = tileSet; this.imageIndex = imageIndex; this.gameData = gameData; pxPerFrameSpeed = 0; pixelShiftSizeAccumulator = 0; xOffset = 0; yOffset = 0; fixedXOffset = 0; fixedYOffset = 0; maxLoopCount = 0; curLoopCount = 0; showImage = false; msLeftBeforeShow = getNextTime(); }
public ImageLayer(GameData gameData, TileSet tileSet, int imageIndex) { this.tileSet = tileSet; this.imageIndex = imageIndex; this.gameData = gameData; pxPerFrameSpeed = 0; pixelShiftSizeAccumulator = 0; xOffset = 0; yOffset = 0; fixedXOffset = 0; fixedYOffset = 0; }
private List<TileSet> getTileSets(ContentManager content, XElement tileSetsElement) { List<TileSet> tileSets = new List<TileSet>(); foreach (XElement set in tileSetsElement.Elements("tileset")) { TileSet s = new TileSet(); s.name = (string)set.Attribute("name"); string filename = (string)set.Attribute("fileName"); s.texture = loadTexture(content, filename); s.width = (int)set.Attribute("TileWidth"); s.height = (int)set.Attribute("TileHeight"); int hCount = (int)set.Attribute("HorizontalTileCount"); int vCount = (int)set.Attribute("VerticalTileCount"); s.count = (int)set.Attribute("TileCount"); int k = 0; for (int i = 0; i < vCount; i++) { for (int j = 0; j < hCount; j++) { if (k++ > s.count) break; s.coords.Add(new Rectangle(j * s.width, i * s.height, s.width, s.height)); } } tileSets.Add(s); Debug.Print("Added Tileset: " + s.name); } return tileSets; }
public TileSet.Bounds getMapTileBounds(int px, int py, Map mapData, TileSet tileSet) { TileSet.Bounds bounds = TileSet.Bounds.BOUNDS_NONE; //get the tile position for the pixel coords int row, col; convertScreenPxToTile(px, py, out row, out col); row %= mapData.height; col %= mapData.width; //get the bounds for the tile int tileTypeIndex = mapData.data[row][col]; bounds = tileSet.bounds[tileTypeIndex]; return bounds; }
public Rectangle getTileRect(TileSet tileSet) { return tileSet.coords[RectIndex]; }