public void Create(ClassicGame game) { var gamdat = LogicFactory.GetParameter <Burntime.Data.BurnGfx.Save.SaveGame>("gamdat"); if (gamdat == null) { return; } var container = game.Container; for (int i = 1; i <= gamdat.Locations.Length; i++) { var city = gamdat.Locations[i - 1]; Location loc = container.Create <Location>(); loc.Id = game.World.Locations.Count; loc.Source.Water = city.WaterSource; loc.Source.Reserve = city.Water; loc.Source.Capacity = city.WaterCapacity; loc.Production = city.Producing == -1 ? null : game.Productions[city.Producing]; loc.AvailableProducts = (int[])city.Production.Clone(); if (city.Danger != 0) { loc.Danger = Danger.Instance((city.Danger == 3) ? "radiation" : "gas", city.DangerAmount); } loc.IsCity = city.IsCity; loc.EntryPoint = city.EntryPoint; loc.Ways = (from x in city.Ways where x != -1 select x).ToArray(); loc.WayLengths = (from x in city.WayLengths where x > 0 select x).ToArray(); loc.NeighborIds = (from x in city.Neighbors where x != -1 select x).ToArray(); loc.Map = container.Create <Map>(new object[] { "maps/mat_" + i.ToString("D3") + ".burnmap??4" }); loc.Rooms = container.CreateLinkList <Room>(); for (int j = 0; j < loc.Map.Entrances.Length; j++) { RoomType type = loc.Map.Entrances[j].RoomType; Room room = container.Create <Room>(); room.IsWaterSource = type == RoomType.WaterSource; if (type != RoomType.Normal && type != RoomType.Rope && type != RoomType.WaterSource) { room.Items.MaxCount = 0; } else { room.Items.MaxCount = room.IsWaterSource ? 8 : 32; } room.EntryCondition.MaxDistanceOnMap = 15; if (loc.Map.Entrances[j].RoomType == RoomType.Rope) { room.EntryCondition.MaxDistanceOnMap = 75; room.EntryCondition.RequiredItem = game.ItemTypes["item_rope"]; } room.EntryCondition.RegionOnMap = loc.Map.Entrances[j].Area; room.EntryCondition.HasRegionOnMap = true; room.TitleId = loc.Map.Entrances[j].TitleId; loc.Rooms += room; } game.World.Locations += loc; } foreach (Location location in game.World.Locations) { foreach (int id in location.NeighborIds) { location.Neighbors.Add(game.World.Locations[id]); } } }
public void Create(ClassicGame game) { var resources = LogicFactory.GetParameter <ResourceManager>("resource"); var container = game.Container; // for the time being only add to existing locations for (int i = game.World.Locations.Count + 1; i < game.World.Map.Entrances.Length + 1; i++) { ConfigFile cfg = new ConfigFile(); cfg.Open("maps/mat_" + i.ToString("D3") + ".txt"); Location loc = container.Create <Location>(); loc.Id = i - 1; loc.Source.Water = cfg[""].GetInt("water_refresh"); loc.Source.Reserve = loc.Source.Water; loc.Source.Capacity = cfg[""].GetInt("water_capacity"); loc.Production = null; // city.Producing == -1 ? null : game.Productions[city.Producing]; loc.AvailableProducts = new int[] { }; // (int[])city.Production.Clone(); loc.Danger = resources.GetData(cfg[""].GetString("danger")) as Danger; loc.IsCity = cfg[""].GetBool("city"); loc.EntryPoint = cfg[""].GetVector2("entry_point"); loc.Ways = new int[] { }; loc.NeighborIds = cfg[""].GetInts("ways"); loc.WayLengths = cfg[""].GetInts("way_lengths"); // in case of a burngfx location we need to add new ways updateBurngfxLocation(loc.Id, loc.NeighborIds, loc.WayLengths, game.World.Locations); loc.Map = container.Create <Map>(new object[] { "maps/mat_" + i.ToString("D3") + ".burnmap??4" }); loc.Rooms = container.CreateLinkList <Room>(); for (int j = 0; j < loc.Map.Entrances.Length; j++) { RoomType type = loc.Map.Entrances[j].RoomType; Room room = container.Create <Room>(); room.IsWaterSource = type == RoomType.WaterSource; if (type != RoomType.Normal && type != RoomType.Rope && type != RoomType.WaterSource) { room.Items.MaxCount = 0; } else { room.Items.MaxCount = room.IsWaterSource ? 8 : 32; } room.EntryCondition.MaxDistanceOnMap = 15; if (loc.Map.Entrances[j].RoomType == RoomType.Rope) { room.EntryCondition.MaxDistanceOnMap = 75; room.EntryCondition.RequiredItem = game.ItemTypes["item_rope"]; } room.EntryCondition.RegionOnMap = loc.Map.Entrances[j].Area; room.EntryCondition.HasRegionOnMap = true; room.TitleId = loc.Map.Entrances[j].TitleId; loc.Rooms += room; } game.World.Locations += loc; i++; } // update neighbor links foreach (Location location in game.World.Locations) { for (int k = 0; k < location.NeighborIds.Length; k++) { if (location.NeighborIds[k] != -1) { var neighbor = game.World.Locations[location.NeighborIds[k]]; // only add if not already in the list if (!location.Neighbors.Contains(neighbor)) { location.Neighbors.Add(neighbor); } } } } }
public void CreateNewGame(NewGameInfo Info) { new LogicFactory(); // load game settings settings = new GameSettings("gamesettings.txt"); settings.SetDifficulty(Info.Difficulty); // set up game server SetupServer(); // get root game object ClassicGame game = container.Root as ClassicGame; LogicFactory.SetParameter("resource", app.ResourceManager); // open gam.dat IGameObjectCreator creator = new ClassicBurnGfxCreator(); creator.Create(game); var gamdat = LogicFactory.GetParameter <Burntime.Data.BurnGfx.Save.SaveGame>("gamdat"); // create world object game.World = container.Create <ClassicWorld>(); game.World.VictoryCondition = container.Create <VictoryCondition>(); // set difficulty game.World.Difficulty = Info.Difficulty; // add player objects AddPlayer(game, Info, gamdat, settings); // set main map game.World.Map = container.Create <Map>(new object[] { "maps/mat_000.burnmap" }); LogicFactory.SetParameter("mainmap", game.World.Map); game.World.Ways = container.Create <Ways>(new object[] { "ways@maps/mat_000-ways.txt" }); // set constructions game.Constructions = (Constructions)app.ResourceManager.GetData("*****@*****.**"); game.ItemTypes = container.Create <ItemTypes>(new object[] { "*****@*****.**" }); // set productions LoadProductions(game, gamdat); // create respawn class game.World.Respawn = container.Create <CharacterRespawn>(new object[] { settings.Respawn.NPC, settings.Respawn.Trader, settings.Respawn.Mutant, settings.Respawn.Dog }); // create locations creator = new OriginalLocationCreator(); creator.Create(game); creator = new LocationCreator(); creator.Create(game); // place npcs LoadNPCs(game, gamdat); // set start locations for player SetStartLocations(game); // place items LoadItems(game, gamdat); // set trader LoadTrader(game, gamdat); // set start inventory for player SetStartInventory(game); container.Synchronize(false); // DEBUG app.Server.Run(); }