public void AddBuilding(RhitLocation location) { if (!Buildings.Contains(location)) { Buildings.Add(location); } }
public void Initiate() { // starts the beginning situation of the game // create the buildings Buildings.Add(new House(new Location(100, 100), "house")); Buildings.Add(new Warehouse(new Location(300, 300), "warehouse")); Buildings.Add(new ResourceHub(new Location(100, 300), "resources", 9999999)); // add roadpoints to them Buildings[0].AddRoadpoint(new Location(200, 200)); Buildings[1].AddRoadpoint(Buildings[0].Roadpoint.BeginLocation); Buildings[2].AddRoadpoint(Buildings[0].Roadpoint.BeginLocation); // put a dude in the building's spawn Dude dude = new Dude(1, Buildings[0].Spawn.Location); Buildings[0].EnterBuilding(dude); Dudes.Add(dude); EndGame = false; // initiate a thread with the gameloop. This separates the GUI thread with the code thread. threads.Add(new Thread(PerformDudePrio)); // makes all the dudes perform their prioritary task threads.Add(new Thread(KeepRoadsUpdated)); // makes sure that roads get generated when new buildings pop up threads[0].Start(); // start managing the dudes } //
public void AddBuilding(BuildingEntity entity) { if (entity != null) { Buildings.Add(entity); } }
public void Create(FormCollection collection) { var msg = new Msg(); try { // 初始化对象 Entity.T_Building building = new Entity.T_Building() { Building_nickname = collection["name"], Building_note = collection["note"], Building_vid = collection["vid"], Building_dorm_id = Convert.ToInt32(collection["pid"]), }; var buildings = new Buildings(); if (buildings.Add(building)) { msg.Message = "添加成功!"; } else { throw new Exception("发生未知错误,添加失败!"); } } catch (Exception ex) { msg.Code = -1; msg.Message = ex.Message; } Response.Write(msg.ToJson()); Response.End(); }
/// <summary> /// Változtatások mentése. /// </summary> private void SaveChanges() { // ellenőrzések if (String.IsNullOrEmpty(EditedBuilding.Name)) { OnMessageApplication("Az épületnév nincs megadva!"); return; } if (EditedBuilding.City == null) { OnMessageApplication("A város nincs megadva!"); return; } if (EditedBuilding.ShoreId == null) { OnMessageApplication("A tengerpart típus nincs megadva!"); return; } // mentés if (EditedBuilding.Id == 0) // ha új az épület { _model.CreateBuilding(EditedBuilding); Buildings.Add(EditedBuilding); SelectedBuilding = EditedBuilding; } else // ha már létezik az épület { _model.UpdateBuilding(EditedBuilding); } EditedBuilding = null; OnBuildingEditingFinished(); }
public void Generate() { for (int i = 0; i < NumBuildings; i++) { if (random.Next(0, 2) == 0) { if (random.Next(0, 2) == 0) { ResourceBuilding r = new ResourceBuilding(random.Next(0, mapWidth), random.Next(0, mapHeight), 20, 0, "{}", random.Next(0, 3), 0, 10, 500); Buildings.Add(r); } else { FactoryBuilding f = new FactoryBuilding(random.Next(0, mapWidth), random.Next(0, mapHeight), 15, 0, "[]", random.Next(0, 3), 4); Buildings.Add(f); } } else { if (random.Next(0, 2) == 0) { ResourceBuilding r = new ResourceBuilding(random.Next(0, mapWidth), random.Next(0, mapHeight), 20, 1, "{}", random.Next(0, 3), 0, 10, 500); Buildings.Add(r); } else { FactoryBuilding f = new FactoryBuilding(random.Next(0, mapWidth), random.Next(0, mapHeight), 15, 1, "[]", random.Next(0, 3), 4); Buildings.Add(f); } } } }
private List <uint> GenerateFactoryBuildings(uint prerequisiteID) { var factoryIDs = new List <uint>(); int numFactories = Math.Max(1, Complexity / 10); for (int i = 0; i < numFactories; i++) { uint identifier = nextIdentifier++; var factory = GenerateFactoryBuilding(identifier); Buildings.Add(identifier, factory); factoryIDs.Add(identifier); // Factories shouldn't always be a linear chain. Bigger trees should branch more. if (Random.Next(10) < numFactories) { AddToSubtree(prerequisiteID, identifier, factory); } else { AddUnlock(prerequisiteID, identifier, factory); } prerequisiteID = identifier; } return(factoryIDs); }
public void UpdateMap(GameData gameData) { if (PositionHasBeenSet) { Characters.Clear(); Buildings.Clear(); for (int i = 0; i < gameData.Sprites.Count(); i++) { if (gameData.Sprites[i].MiniMapTexture != null) { Vector2 miniMapPos = new Vector2(gameData.Sprites[i].Bounds.X, gameData.Sprites[i].Bounds.Y); miniMapPos = miniMapPos * Ratio; //Scale the position down to the minimap size miniMapPos += PositionUpperLeft; //Move the position to the correct location of the screen miniMapPos -= new Vector2((gameData.Sprites[i].MiniMapTexture.Width * gameData.Sprites[i].MiniMapScale) / 2, (gameData.Sprites[i].MiniMapTexture.Height * gameData.Sprites[i].MiniMapScale) / 2); //Move the position to upperleft corner. The SpriteBase holds the position of the center if (gameData.Sprites[i].IsMovable) { Characters.Add(new MinimapObject() { Texture = gameData.Sprites[i].MiniMapTexture, Color = gameData.Sprites[i].Color, Position = miniMapPos, Scale = gameData.Sprites[i].MiniMapScale, Opacity = gameData.Sprites[i].MiniMapOpacity }); } else { Buildings.Add(new MinimapObject() { Texture = gameData.Sprites[i].MiniMapTexture, Color = gameData.Sprites[i].Color, Position = miniMapPos, Scale = gameData.Sprites[i].MiniMapScale, Opacity = gameData.Sprites[i].MiniMapOpacity }); } } } } }
public BuildingsSummary(Map map, int level) { bool[,] tilesChecked = new bool[map.Width + 1, map.Height + 1]; LinkedList <Room> rooms = new LinkedList <Room>(); for (int x = 0; x <= map.Width; x++) { for (int y = 0; y <= map.Height; y++) { Room room = ScanTileForRoom(map, tilesChecked, x, y, level); if (room != null) { rooms.AddLast(room); } } } Rooms = new HashSet <Room>(rooms); while (rooms.Count > 0) { List <Room> roomsInBuilding = new List <Room>(); Room firstRoom = rooms.First.Value; roomsInBuilding.Add(firstRoom); bool addedRoom = true; while (addedRoom) { addedRoom = false; foreach (Room roomToCheck in rooms) { if (roomsInBuilding.Contains(roomToCheck)) { continue; } foreach (Room buildingRoom in roomsInBuilding) { if (buildingRoom.BordersRoom(roomToCheck)) { roomsInBuilding.Add(roomToCheck); addedRoom = true; break; } } } } foreach (Room room in roomsInBuilding) { rooms.Remove(room); } Buildings.Add(new Building(roomsInBuilding)); } }
public void SpawnBuilding(Building a_Building, Vector2UInt a_LLCornerPos) { Vector3 offset = a_Building.Size.ToVector2() * 0.5f; a_Building.transform.position = new Vector3(a_LLCornerPos.X, a_LLCornerPos.Y, -1) + offset; a_Building.transform.parent = m_BuildingsObj.transform; Buildings.Add(a_Building); }
private void AddBuildings() { foreach (KeyValuePair <string, BuildingProgress> kvp in BuildingProgress) { BuildingData buildingData = GenericDataLoader.GetData <BuildingData>(kvp.Value.ID); UnitProgress unitProgressForBuilding = UnitProgress[buildingData.Unit]; Buildings.Add(new Building(kvp.Value, unitProgressForBuilding)); } }
public override async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> suspensionState) { var a = await Persistence.Persistence.getBuildingsWithRequests(); foreach (var item in a) { Buildings.Add(item); } }
public async System.Threading.Tasks.Task OnTaskEnded(PIO.Models.Task Task) { Building building; BuildingViewModel factoryViewModel; await Workers.RefreshWorker(Task.WorkerID); switch (Task.TaskTypeID) { case Models.TaskTypeIDs.MoveTo: break; case Models.TaskTypeIDs.Store: await Buildings.RefreshBuilding(Task.X, Task.Y); break; case Models.TaskTypeIDs.Produce: await Buildings.RefreshBuilding(Task.X, Task.Y); break; case Models.TaskTypeIDs.Harvest: await Buildings.RefreshBuilding(Task.X, Task.Y); break; case Models.TaskTypeIDs.Build: await Buildings.RefreshBuilding(Task.X, Task.Y); break; case Models.TaskTypeIDs.CreateBuilding: try { building = PIOClient.GetBuildingAtPos(1, Task.X, Task.Y); if (building != null) { factoryViewModel = new BuildingViewModel(PIOClient, BotsClient, TranslationModule, ProduceOrders, HarvestOrders); await factoryViewModel.LoadAsync(building); Buildings.Add(factoryViewModel); MapItems.Insert(Cells.Count, factoryViewModel); } } catch (Exception ex) { ErrorMessage = ex.Message; } //await Buildings.RefreshBuilding(Task.X.Value, Task.Y.Value); break; } }
public TestSettlement(World testWorld) : base("Test Settlement", new List <Region> { testWorld.StartingRegion }) { GenerateSettlers(); for (var i = 0; i < 5; i++) { Buildings.Add(new Residence(TierOneBuildings.Hut)); } }
public void RegisterBuildings(Building building) { if (Buildings.Count >= _maximumCapacity) { System.Console.WriteLine("This city is at maximum capacity!"); } else { Buildings.Add(building); } }
public virtual void sortBuildingList() { BIMBuilding[] arrayOfBIMBuilding = (BIMBuilding[])Buildings.ToArray(); Arrays.sort(arrayOfBIMBuilding, new ComparatorAnonymousInnerClass(this)); Buildings.Clear(); foreach (BIMBuilding bIMBuilding in arrayOfBIMBuilding) { bIMBuilding.sortStoreys(); Buildings.Add(bIMBuilding); } }
private uint GenerateResourceBuildings() { int numberOfResources = Complexity <= 15 ? 1 : Complexity < 75 ? 2 : Complexity < 95 ? 3 : 4; var resources = Enum.GetValues(typeof(ResourceType)) .Cast <ResourceType>() .Where(r => r != ResourceType.Supply) .ToList(); resources.Randomize(Random); uint?primaryBuildingID = null; for (int i = 0; i < numberOfResources; i++) { var resource = resources[i]; Resources.Add(resource); var identifier = nextIdentifier++; var building = GenerateResourceBuilding(identifier, resource, !primaryBuildingID.HasValue); Buildings.Add(identifier, building); if (primaryBuildingID.HasValue) { // Resource buildings are currently the only ones in the tree, so it takes a few for this to actually cause branching. // We might also not give it a prerequisite at all. if (Random.Next(3) != 0) { AddToSubtree(primaryBuildingID.Value, identifier, building); } } else { primaryBuildingID = identifier; } } DetermineResourceCostRatios(); if (!primaryBuildingID.HasValue) { throw new InvalidOperationException(); } return(primaryBuildingID.Value); }
public void AddBuilding() { var newBuilding = new Building(Year, CountFloors); _db.Buildings.Add(newBuilding); _db.SaveChanges(); Buildings.Add(newBuilding); Vertices.Add(newBuilding.ToVertex()); ToStartState(); }
static void Initialize() { Computer c1 = new Computer { Id = 1, Model = "PC", Manufactured = DateTime.Now, HardwareAddress = "90-1F-12-22-33-55", LogicAddress = 2, }; Computer c2 = new Computer { Id = 2, Model = "PC2", Manufactured = DateTime.Now.AddDays(-1), HardwareAddress = "90-1F-12-22-33-54", LogicAddress = 22 }; Router r1 = new Router { Id = 1, Model = "R1", Manufactured = DateTime.Now, HardwareAddress = "90-1F-12-22-33-53", LogicAddress = 33, Mask = 4294967040, Computers = new List <Computer> { c1, c2 } }; Room rm1 = new Room { Id = 1, Number = 521, Routers = new List <Router> { r1 }, Computers = new List <Computer> { c1, c2 } }; Building b1 = new Building { Id = 1, Name = "MyBuilding", Rooms = new List <Room> { rm1 } }; c1.Router = r1; c1.RouterId = r1.Id; c1.Room = rm1; c1.RoomId = rm1.Id; c2.Router = r1; c2.RouterId = r1.Id; c2.Room = rm1; c2.RoomId = rm1.Id; r1.Room = rm1; r1.RoomId = rm1.Id; rm1.Building = b1; rm1.BuildingId = b1.Id; Computers.Add(c1); Computers.Add(c2); Routers.Add(r1); Rooms.Add(rm1); Buildings.Add(b1); }
internal override void Plus(XDocument xdoc) { foreach (var element in xdoc.Root.Elements()) { var val = element.Value; int valI; int.TryParse(val, out valI); switch (element.Name.LocalName) { case "id": case "type": break; case "maker": case "maker_entity": case "site": break; case "building_type": if (!Buildings.Contains(val)) { Buildings.Add(val); } BuildingType = Buildings.IndexOf(val); break; case "building_subtype": if (val != "-1") { if (!Buildings.Contains(val)) { Buildings.Add(val); } BuildingSubType = Buildings.IndexOf(val); } break; case "building_custom": if (valI != -1) { BuildingCustom = valI; } break; default: DFXMLParser.UnexpectedXmlElement(xdoc.Root.Name.LocalName + "\t" + Types[Type], element, xdoc.Root.ToString()); break; } } }
public RICOBuilding addBuilding(RICOBuilding buildingDef = null) { _isDirty = true; if (buildingDef == null) { buildingDef = new RICOBuilding(); buildingDef.name = "* unnamed"; buildingDef.parent = this; } Buildings.Add(buildingDef); return(buildingDef); }
public void AddBuilding(BuildingType type, Cell cell) { foreach (var e in Buildings.Where(e => e.IsOccupying(cell))) { e.IsDead = true; } var building = new Building { type = type, Cell = cell }; Buildings.Add(building); SelectedBuilding = building; CalcNeighbourDistances(); TerrainController?.OnTerrainChange(); }
private void Build(AbstractBuildCapability buildCapability, AbstractBuilding building = null) { var newbuilding = buildCapability.Build(building); if (building == null) { AddBuilding(newbuilding); } else { RemoveBuilding(building); Buildings.Add(newbuilding); Buildables[building.Id] = newbuilding; } }
private uint GenerateSupplyBuilding(uint primaryResourceBuilding) { Resources.Add(ResourceType.Supply); var identifier = nextIdentifier++; var building = GenerateResourceBuilding(identifier, ResourceType.Supply, false); Buildings.Add(identifier, building); if (Random.Next(3) == 0) // 1 in 3 chance of this requiring the "root" building { AddUnlock(primaryResourceBuilding, identifier, building); } return(identifier); }
public Recti AddBuilding(Building b, Vec2i pos = null, bool force = false) { if (pos != null) { if (force == false && !IsAreaFree(pos.x, pos.z, b.Width, b.Height)) { return(null); } } else { pos = ChoosePlot(b.Width, b.Height); } //We choose a random allowed position. //Vec2i pos = ChoosePlot(b.Width, b.Height); //If no possible position is found, we return null if (pos == null) { return(null); } if (force) { if (pos.x + b.Width >= TileSize || pos.z + b.Height >= TileSize) { return(null); } } for (int x = 0; x < b.Width; x++) { for (int z = 0; z < b.Height; z++) { Tiles[x + pos.x, z + pos.z] = b.BuildingTiles[x, z]; SettlementObjects[x + pos.x, z + pos.z] = b.BuildingObjects[x, z]; if (SettlementObjects[x + pos.x, z + pos.z] != null) { SettlementObjects[x + pos.x, z + pos.z].SetPosition(new Vec2i(x + pos.x, z + pos.z)); } } } b.SetSettlementCoord(pos); Buildings.Add(b); //PathNodes.Add(b.Entrance); return(new Recti(pos.x, pos.z, b.Width, b.Height)); }
public Province(Label Lb) { ctrl = Lb; ID = Form1.idstore; Form1.idstore++; ProvinceName = "None"; Production.Add("wood", 0); Storage.Add("wood", 0); Production.Add("bricks", 0); Storage.Add("bricks", 0); Production.Add("wheat", 0); Storage.Add("wheat", 0); Production.Add("metals", 0); Storage.Add("metals", 0); Production.Add("tools", 0); Storage.Add("tools", 0); Production.Add("weapons", 0); Storage.Add("weapons", 0); Production.Add("wool", 0); Storage.Add("wool", 0); Production.Add("cloth", 0); Storage.Add("cloth", 0); Production.Add("furs", 0); Storage.Add("furs", 0); Production.Add("ale", 0); Storage.Add("ale", 0); Production.Add("wine", 0); Storage.Add("wine", 0); Production.Add("spices", 0); Storage.Add("spices", 0); Production.Add("meat", 0); Storage.Add("meat", 0); Production.Add("salt", 0); Storage.Add("salt", 0); Production.Add("hemps", 0); Storage.Add("hemps", 0); foreach (string s in Form1.ProductName) { BProduction.Add(s, 0); Shortage.Add(s, 0); Buildings.Add(s, 0); PriceModifier.Add(s, 100); PopulationUsage.Add(s, 0); } WarMode = false; }
public static bool GetBuildingReplacementData(string blockName, int blockIndex, int recordIndex, out BuildingReplacementData buildingData) { if (DaggerfallUnity.Settings.AssetInjection) { BlockRecordId blockRecordId = new BlockRecordId() { blockIndex = blockIndex, recordIndex = recordIndex }; if (Buildings.ContainsKey(blockRecordId)) { buildingData = Buildings[blockRecordId]; return(buildingData.BuildingType != noReplacementBT); } else { string fileName = GetBuildingReplacementFilename(blockName, blockIndex, recordIndex); // Seek from loose files if (File.Exists(Path.Combine(worldDataPath, fileName))) { string buildingReplacementJson = File.ReadAllText(Path.Combine(worldDataPath, fileName)); buildingData = (BuildingReplacementData)SaveLoadManager.Deserialize(typeof(BuildingReplacementData), buildingReplacementJson); #if !UNITY_EDITOR // Cache building replacement data, unless running in editor Buildings.Add(blockRecordId, buildingData); #endif return(true); } // Seek from mods TextAsset buildingReplacementJsonAsset; if (ModManager.Instance != null && ModManager.Instance.TryGetAsset(fileName, false, out buildingReplacementJsonAsset)) { buildingData = (BuildingReplacementData)SaveLoadManager.Deserialize(typeof(BuildingReplacementData), buildingReplacementJsonAsset.text); #if !UNITY_EDITOR // Cache building replacement data, unless running in editor Buildings.Add(blockRecordId, buildingData); #endif return(true); } #if !UNITY_EDITOR // Only look for replacement data once, unless running in editor Buildings.Add(blockRecordId, noReplacementData); #endif } } buildingData = noReplacementData; return(false); }
private void GenerateTechBuildings(IEnumerable <uint> factoryIDs) { foreach (var factoryID in factoryIDs) { var factory = Buildings[factoryID]; uint?prevPrerequisite = null; bool first = true; foreach (var unitID in factory.Builds) { if (!Units.TryGetValue(unitID, out var unit)) { continue; } // TODO: have each unit save the ID of its correponding tech building if (first) {// the first unit type built by a building never has any prerequisites ... doesn't mean it can't have upgrades in its own building or the next one, though. first = false; continue; } // give this unit type a 1 in 3 chance of sharing a prerequisite with its predecessor if (prevPrerequisite.HasValue && Random.Next(3) == 0) { AddUnlock(prevPrerequisite.Value, unitID, unit); continue; } // generate a new tech building to be this unit type's prerequisite uint identifier = nextIdentifier++; BuildingBuilder techBuilding = GenerateTechBuilding(identifier); Buildings.Add(identifier, techBuilding); prevPrerequisite = identifier; AddUnlock(identifier, unitID, unit); // insert that into the tech tree somewhere in the factory's subtree AddToSubtree(factoryID, identifier, techBuilding); } } }
public void Build(Building building, Vector2 worldMousePosition) { var cityBuilding = new CityBuilding { BuildingName = building.Name, Id = Buildings.Max(b => b.Id) + 1, X = worldMousePosition.x, Y = worldMousePosition.y, }; Buildings.Add(cityBuilding); var cashImpact = new CityStatImpact { ParameterName = "Cash" }; ImpactStat(cashImpact); BuildingDisplayController.Instance.Refresh(); }
public void CreateBuilding(Building protoBuilding, Tile tile) { if (tile?.HasBuilding != null && (bool)tile?.HasBuilding || protoBuilding == null) { return; } var tilesToOccupy = new List <Tile>(); for (var i = 0; i < protoBuilding.Size; i++) { for (var j = 0; j < protoBuilding.Size; j++) { var tileToOccupy = Tiles[tile.X + i, tile.Y + j]; if (tileToOccupy == null) { return; } tilesToOccupy.Add(tileToOccupy); } } if (tilesToOccupy.Any(t => !t.CanBuildHere())) { return; } var buildingToCreate = new Building(protoBuilding) { Tile = tile }; Buildings.Add(buildingToCreate); tilesToOccupy.ForEach(t => t.Building = buildingToCreate); tilesToOccupy.ForEach(t => t.Neighbors.Where(n => n.Building?.Conjoined ?? false).ToList().ForEach(n => n?.Building?.OnChange())); tilesToOccupy.ForEach(t => Graph.RecreateEdges(t)); buildingToCreate.OnChange(); OnChange(); }