public void RequestBuildState(ConstructionObject constructionObject, int buildingID) { GameStateBuild buildState = new GameStateBuild(constructionObject, mainCamera); buildState.HasPlaced += BuildingPlaced; gameEventStateMachine.ChangeState(buildState); }
public ActionResult <ConstructionObject> Get(int id) // GET: api/Construction/1 { try { Dictionary <int, ConstructionObject> objectsOfBuilding = DataLoader.GetDataOfConstructionObjectsDirectory(); ConstructionObject objectOfBuilding = new ConstructionObject(); if (objectsOfBuilding.TryGetValue(id, out objectOfBuilding)) { return(objectOfBuilding); } else { // Кидаем 404-ю, так как запрашиваемый объект не найден return(this.StatusCode(404)); // TODO: Запись в логи } } catch (Exception ex) { // Кидаем 500-ю ошибку, так как поймали исключение во время чтения данных return(this.StatusCode(500)); // TODO: Запись в логи } }
public BuildTask(ConstructionObject constructionObject, string taskName, Vector2Int mainTaskLocation) : base(taskName, mainTaskLocation) { this.constructionObject = constructionObject; this.materialsNeeded = new List <ResourceAndAmount>(); constructionMaterialsBox = new VoidInventory(mainTaskLocation); }
/// <summary> /// Метод содержит конструкции, по созданию всех возможных вариаций запросов к сервису справочников (DirectoryService) /// </summary> public static async Task TestDirectoryServiceApiAsync(UrlSettings urlSettings) { using (var client = new HttpClient()) { HttpResponseMessage response; // Запросим и десериализуем метаданные по справочникам: // Для справочника "Объекты Строительства" response = await client.GetAsync($"{urlSettings.ConstructionObjectUrl}GetMetadata"); DirectoryMetadata MetadataDirectoryOfConstructionObjects = await response.Content.ReadAsAsync <DirectoryMetadata>(); // Для справочника "Версии Данных" response = await client.GetAsync($"{urlSettings.DataVersionUrl}GetMetadata"); DirectoryMetadata MetadataDirectoryOfDataVersions = await response.Content.ReadAsAsync <DirectoryMetadata>(); // TODO: Полученные метаданные можно сравнивать с метаданными объектов этого сервиса // и в случае несовпадения, как-то уведомлять разработчиков о необх. поправки структуры классов. // Запрашиваем весь справочник "Объекты Строительства" response = await client.GetAsync($"{urlSettings.ConstructionObjectUrl}GetAllDirectory"); IEnumerable <ConstructionObject> сonstructionObjects = await response.Content.ReadAsAsync <IEnumerable <ConstructionObject> >(); // Запрашиваем весь справочник "Версии Данных" response = await client.GetAsync($"{urlSettings.DataVersionUrl}GetAllDirectory"); IEnumerable <DataVersion> dataVersions = await response.Content.ReadAsAsync <IEnumerable <DataVersion> >(); // Запросим Объект Строительства с идом = 2: int indexOfConstructionObject = 2; response = await client.GetAsync($"{urlSettings.ConstructionObjectUrl}Elements/{indexOfConstructionObject}"); ConstructionObject сonstructionObject = await response.Content.ReadAsAsync <ConstructionObject>(); // Запросим Версию Данных с идом = 3: int indexOfDataVersion = 3; response = await client.GetAsync($"{urlSettings.DataVersionUrl}Elements/{indexOfConstructionObject}"); DataVersion dataVersion = await response.Content.ReadAsAsync <DataVersion>(); // Попробуем запросить Версию Данных с идом = 88: indexOfDataVersion = 88; response = await client.GetAsync($"{urlSettings.DataVersionUrl}Elements/{indexOfDataVersion}"); // dataVersionEmpty будет = null. DataVersion dataVersionEmpty = await response.Content.ReadAsAsync <DataVersion>(); } }
// Combobox eventhandler, handles category changes private void ChangeValue(object sender, SelectionChangedEventArgs e) { switch (this.window.productCategories.SelectedIndex) { case 1: ElectronicObject eo = new ElectronicObject(); GenerateInputFields(eo); this.window.AddTabChildStack.Background = Brushes.LightBlue; break; case 2: ConstructionObject co = new ConstructionObject(); GenerateInputFields(co); this.window.AddTabChildStack.Background = Brushes.LightCyan; break; case 3: GardenObject go = new GardenObject(); GenerateInputFields(go); this.window.AddTabChildStack.Background = Brushes.LightGreen; break; case 4: SanitaryObject so = new SanitaryObject(); GenerateInputFields(so); this.window.AddTabChildStack.Background = Brushes.LightCoral; break; case 5: ToolObject to = new ToolObject(); GenerateInputFields(to); this.window.AddTabChildStack.Background = Brushes.LightGoldenrodYellow; break; case 6: MachineryObject mo = new MachineryObject(); GenerateInputFields(mo); this.window.AddTabChildStack.Background = Brushes.LightSalmon; break; case 7: AutoPartObject ao = new AutoPartObject(); GenerateInputFields(ao); this.window.AddTabChildStack.Background = Brushes.LightGray; break; default: this.window.AddTabChildStack.Children.RemoveRange(1, this.window.AddTabChildStack.Children.Count - 1); this.window.AddTabChildStack.Background = Brushes.Transparent; this.window.AddButton.IsEnabled = false; break; } }
public BuildTask(ConstructionObject constructionObject, string taskName, Tuple <int, int> mainTaskLocation) : base(taskName, mainTaskLocation) { this.constructionObject = constructionObject; materialsNeeded = new List <ResourceAndAmount>(); for (int i = 0; i < constructionObject.constructionMaterials.Length; ++i) { materialsNeeded.Add(constructionObject.constructionMaterials[i]); } //POPULATE PREREQ TASKS BASED ON MATERIALS NEEDED AT SITE foreach (ResourceAndAmount materials in materialsNeeded) { taskPrqQueue.Enqueue(new FetchMaterialTask("FETCH.. ", materials, mainTaskLocation)); } //ADD FINAL TASK - THE BUILDING ITSELF AFTER ALL PREREQ taskPrqQueue.Enqueue(new TimedTask(constructionObject.constructionTimeCost, mainTaskLocation, "Build " + constructionObject.buildingName)); //Debug.Log("build task created"); }
public ITask GetTask(AIBrain brain) { for (int i = 0; i < ConstructionBuildings.Count; i++) { ConstructionObject constructionObject = ConstructionBuildings[i]; TargetPosition emptyPosition = ConstructionBuildings[i].GetEmptyPosition(); if (emptyPosition != null) { return(new ConstructionTask(brain, constructionObject)); } } for (int i = 0; i < MarkedVegetation.Count; i++) { VegetationObject vegetationObject = MarkedVegetation[i]; if (vegetationObject.Targetable()) { return(new WoodcuttingTask(brain, vegetationObject)); } } return(null); }
public ConstructAction(TargetPosition targetPosition, ConstructionObject constructionObject) { _constructionObject = constructionObject; _targetPosition = targetPosition; }
public ConstructionTask(AIBrain brain, ConstructionObject constructionTarget) : base(brain) { _constructionTarget = constructionTarget; }
public GameStateBuild(ConstructionObject constructionObject, Camera camera) : base(constructionObject.buildingSprite, camera) { this.constructionObject = constructionObject; }