/// <summary> /// Used to offset the pixel data of a tile sprite. Set the value which /// is added to all the ints in a requested tile's data when being /// rendered to the ScreenBufferChip. /// </summary> /// <param name="column"> /// The column position of the tile. 0 is the left of the tile map. /// </param> /// <param name="row"> /// The row position of the tile. 0 is the top of the tile map. /// </param> /// <param name="paletteID"> /// A color int offset. /// </param> public void UpdateTileColorAt(int column, int row, int paletteID) { PosUtil.CalculateIndex(column, row, columns, out tmpIndex); UpdateDataAt(Layer.Palettes, column, row, paletteID); Invalidate(tmpIndex); }
public void MoveInDirection(Vector2 dir) { PosUtil.CalculatePos(currentTile, map.columns, out tmpX, out tmpY); tmpX += (int)dir.x; tmpY += (int)dir.y; PosUtil.CalculateIndex(tmpX, tmpY, map.columns, out tmpIndex); MoveTo(tmpIndex, true); }
public void MoveInDirection(Vector2 dir) { PosUtil.CalculatePos(currentTile, map.columns, out tmpX, out tmpY); tmpX += (int)dir.x; tmpY += (int)dir.y; PosUtil.CalculateIndex(tmpX, tmpY, map.columns, out tmpIndex); Debug.Log("Move to tile " + tmpIndex); }
//when we visit a Tile we decorate it AndroidJNI also WebCamFlags redecorate the neighbor tiles //to have apropriate FogMode void VisitTile(int index) { int column, newX, newY, row = 0; //Calculate position of current tile PosUtil.CalculatePos(index, map.columns, out tmpX, out tmpY); //Half way of the field of view var half = Mathf.FloorToInt(viewDistance / 2f); //Shifiting the area that we are going to loop all that area tmpX -= half; tmpY -= half; //find total tile to visit var total = viewDistance * viewDistance; //Calculate the column var maxColumns = viewDistance - 1; for (int i = 0; i < total; i++) { //Find the index OperatingSystemFamily Tile int this Area column = i % viewDistance; newX = column + tmpX; newY = row + tmpY; PosUtil.CalculateIndex(newX, newY, map.columns, out index); if (index > -1 && index < map.tiles.Length) { var tile = map.tiles [index]; tile.visited = true; DecorateTile(index); foreach (var neighbor in tile.neighbors) { if (neighbor != null) { if (!neighbor.visited) { neighbor.CalculateFoWAutotileID(); DecorateTile(neighbor.id); } } } } if (column == maxColumns) { row++; } } }
void VisitTile(int index) { int column, newX, newY, row = 0; PosUtil.CalculatePos(index, map.columns, out tmpX, out tmpY); var half = Mathf.FloorToInt(distance / 2f); tmpX -= half; tmpY -= half; var total = distance * distance; var maxColumns = distance - 1; for (int i = 0; i < total; i++) { column = i % distance; newX = column + tmpX; newY = row + tmpY; PosUtil.CalculateIndex(newX, newY, map.columns, out index); if (index > -1 && index < map.tiles.Length) { var tile = map.tiles[index]; tile.visited = true; DecorateTile(index); foreach (var neighbor in tile.neighbors) { if (neighbor != null) { if (!neighbor.visited) { neighbor.CalculateFoWAutotileID(); DecorateTile(neighbor.id); } } } } if (column == maxColumns) { row++; } } }
// Start is called before the first frame update void Start() { print("Start " + PosUtil.CalculateIndex(5, 3, 10)); }