public void Load() { int nG, nGX, nGY; ushort nGId, cGId; int cGPriority, nGPriority; int x, y; int i; for (x = 0; x < tileData.Length; x++) { activeTiles[x] = new ActiveTile(tileData[x]); } for (y = 0; y < Config.CHUNK_SIZE; y++) { for (x = 0; x < Config.CHUNK_SIZE; x++) { i = (y * Config.CHUNK_SIZE) + x; cGId = tileData[i].GroundTileId; cGPriority = Array.IndexOf(GroundIds.priorities, cGId); foreach (KeyValuePair <byte, Vector2> entry in edgeOffsets) { nGX = x + (int)entry.Value.X; nGY = y + (int)entry.Value.Y; if (nGY >= 0 && nGX >= 0 && nGY < Config.CHUNK_SIZE && nGX < Config.CHUNK_SIZE) { nG = (nGY * Config.CHUNK_SIZE) + nGX; nGId = tileData[nG].GroundTileId; nGPriority = Array.IndexOf(GroundIds.priorities, nGId); if (nGPriority < cGPriority) { activeTiles[nG].IncrementEdgeTransition(cGId, entry.Key); } } } foreach (KeyValuePair <byte, Vector2> entry in cornerOffsets) { nGX = x + (int)entry.Value.X; nGY = y + (int)entry.Value.Y; if (nGY >= 0 && nGX >= 0 && nGY < Config.CHUNK_SIZE && nGX < Config.CHUNK_SIZE) { nG = (nGY * Config.CHUNK_SIZE) + nGX; nGId = tileData[nG].GroundTileId; nGPriority = Array.IndexOf(GroundIds.priorities, nGId); if (nGPriority < cGPriority) { activeTiles[nG].IncrementCornerTransition(cGId, entry.Key); } } } } } foreach (ActiveTile tile in activeTiles) { tile.PrepTransitionData(); } }
public void PrintTileData(int tileX, int tileY) { ActiveTile tile = worldData.GetActiveTile((tileY * worldData.GetWidth()) + tileX); tile.PrintDebugInfo(); }
/// <summary> /// Place the given object At the given location /// </summary> /// <param name="objId">Id of the object to place</param> /// <param name="tileX">Global x tile position of the object to remove</param> /// <param name="tileY">Global y tile position of the object to remove</param> public void PlaceObjectAt(ushort objId, int tileX, int tileY) { ActiveTile tile = worldData.GetActiveTile(tileX, tileY); tile.PlaceObject(objId); }
/// <summary> /// Removes the object at the given location /// </summary> /// <param name="tileX">Global x tile position of the object to remove</param> /// <param name="tileY">Global y tile position of the object to remove</param> public void RemoveObjectAt(int tileX, int tileY) { ActiveTile tile = worldData.GetActiveTile(tileX, tileY); tile.ClearObject(); }