// Spawn an event tile if it isn't already spawned. public void SpawnEventTile(EventTileDataInstance eventTileData, bool staySpawned) { if (!IsEventTileSpawned(eventTileData)) { EventTile tile = EventTile.CreateEvent(eventTileData); AddEventTile(tile); } if (staySpawned) { eventTileData.Properties.Set("enabled", true); } }
public void BeginRoom(Room room) { this.room = room; this.roomLocation = room.Location; this.dungeon = room.Dungeon; this.isSideScrolling = room.Zone.IsSideScrolling; // Discover the room. room.IsDiscovered = true; room.Level.IsDiscovered = true; // Clear event tiles. eventTiles.Clear(); // Clear all entities from the old room (except for the player). entities.Clear(); if (Player != null) { Player.Initialize(this); Player.EntityIndex = 0; entities.Add(Player); } // Create the tile grid. tileManager.Initialize(room); for (int x = 0; x < room.Width; x++) { for (int y = 0; y < room.Height; y++) { for (int i = 0; i < room.LayerCount; i++) { TileDataInstance data = room.TileData[x, y, i]; if (data != null && data.IsAtLocation(x, y) && data.ModifiedProperties.GetBoolean("enabled", true)) { // Place the tile. Tile tile = Tile.CreateTile(data); PlaceTile(tile, x, y, i, false); } } } } // Create the event tiles. eventTiles.Capacity = room.EventData.Count; for (int i = 0; i < room.EventData.Count; i++) { EventTileDataInstance data = room.EventData[i]; if (data.Properties.GetBoolean("enabled", true)) { EventTile eventTile = EventTile.CreateEvent(data); eventTiles.Add(eventTile); } } // Initialize the tiles. tileManager.InitializeTiles(); // Initialize the event tiles. for (int i = 0; i < eventTiles.Count; i++) { eventTiles[i].Initialize(this); } tileManager.PostInitializeTiles(); entityCount = entities.Count; viewControl.Bounds = RoomBounds; viewControl.ViewSize = GameSettings.VIEW_SIZE; // Fire the RoomStart event. GameControl.FireEvent(room, "event_room_start"); allMonstersDead = false; }