//public bool IsActive => Tile != null; public void Change(TileSpot tileSpot, uint tileID) { DestroyTile(); Spot = tileSpot; TileID = tileID; Instantiate(); }
public TileTemplate(TileSpot tileSpot, uint tileID) { Provider = null; Spot = tileSpot; TileID = tileID; Provider = TileMap.TileSet[tileID]; }
/// <summary> /// Creates the GameObjects for a tile at a specified position. /// </summary> /// <param name="position">Position in X and Y tile coordinates.</param> public void CreateGameObjectsForTile(Point position) { Point actualPos = new Point(position.X * SceneManager._TILE_SIZE, position.Y * SceneManager._TILE_SIZE); TileSpot tileSpot = GetTileSpotAtPoint(actualPos); tileSpot.CreateGameObjects(actualPos); }
public void RemoveTile(Point tilePoint, uint tileID) { Point chunkPos = Snap(tilePoint, ChunkSize); for (int i = 0; i < Chunks.Count; i++) { TileChunk chunk = Chunks[i]; if (chunk.Position == chunkPos) { Point chunkTilePos = chunk.ToLocalPoint(tilePoint); TileSpot t = chunk.TileTemplates[chunkTilePos.X][chunkTilePos.Y]; t.RemoveTile(tileID); } } }
public void Initialize(TileMap tileMap, Point position) { Position = position; TileMap = tileMap; TileTemplates = new TileSpot[tileMap.ChunkSize][]; for (int x = 0; x < tileMap.ChunkSize; x++) { TileTemplates[x] = new TileSpot[tileMap.ChunkSize]; for (int y = 0; y < tileMap.ChunkSize; y++) { TileTemplates[x][y] = new TileSpot(this, new Point(x + position.X, y + position.Y)); } } }
/// <summary> /// Creates and initializes the level, giving it a specified size. /// </summary> /// <param name="size">Amount of tiles on the X and Y axis.</param> public void CreateLevel(Point size) { MapData = new TileSpot[size.X][]; for (int x = 0; x < size.X; x++) { MapData[x] = new TileSpot[size.Y]; for (int y = 0; y < size.Y; y++) { MapData[x][y] = new TileSpot(this); } } SetTilesCount(size.X, size.Y); SceneManager.WorldSize = new Point(TilesCount.X * SceneManager._TILE_SIZE, TilesCount.Y * SceneManager._TILE_SIZE); //NavigationManager.Initialize(new Rectangle(0, 0, SceneManager.WorldSize.X, SceneManager.WorldSize.Y)); //LightingSystem.Initialize(new Rectangle(0, 0,LevelManager.WorldSize.X, LevelManager.WorldSize.Y), LevelManager._TILE_SIZE); }
private void LoadData(LevelData data) { int totalTiles = data.TilesCount.X * data.TilesCount.Y; int curTilesLoaded = 0; CreateLevel(data.TilesCount); MapData = new TileSpot[TilesCount.X][]; for (int x = 0; x < data.MapData.Length; x++) { MapData[x] = new TileSpot[TilesCount.Y]; for (int y = 0; y < data.MapData[x].Length; y++) { MapData[x][y] = new TileSpot(this); MapData[x][y].TileTemplates = data.MapData[x][y]; CreateGameObjectsForTile(new Point(x, y)); curTilesLoaded++; } LoadingScreen.SetProgress("Loading", (float)curTilesLoaded / totalTiles); } MarkerData = data.MarkerData; MarkerGraphicData = data.MarkerGraphicData; }