public void TestForCrafting() { foreach (Vector2 key in tm.pickups.Keys.ToList()) { if (ResourcePickup.IsAtPosition(key)) { ResourcePickup resourceToTest = tm.pickups [key] as ResourcePickup; Vector3 spawnPos; Craftable craftableInfo = GetCraftableForResource(resourceToTest, out spawnPos); if (craftableInfo is BuildingInfo) { BuildingInfo buildingInfo = craftableInfo as BuildingInfo; if (!blueprints.ContainsKey(resourceToTest)) { Building newBuilding = tm.SpawnBuilding(spawnPos, buildingInfo.prefab, buildingInfo, resourceToTest.island); blueprints.Add(resourceToTest, newBuilding); } } else if (craftableInfo is WeaponInfo) { WeaponInfo weaponInfo = craftableInfo as WeaponInfo; tm.SpawnWeapon(spawnPos, weaponInfo, resourceToTest.island); } else if (craftableInfo is AugmentInfo) { AugmentInfo augmentInfo = craftableInfo as AugmentInfo; tm.SpawnAugment(spawnPos, augmentInfo, resourceToTest.island); } } } }
InventoryItem CreateInventoryItem(Craftable linkedItem, bool setPreview = false) { GameObject newItem = Instantiate(inventoryItem); newItem.GetComponent <InventoryItem>().LinkItem(linkedItem, allAspects, this, setPreview); return(newItem.GetComponent <InventoryItem>()); }
public int GetColorNumber(Craftable item) { int colorNumber = -1; switch (item.GetRarity()) { case Craftable.itemRarity.Common: colorNumber = 0; break; case Craftable.itemRarity.UnCommon: colorNumber = 1; break; case Craftable.itemRarity.Rare: colorNumber = 2; break; case Craftable.itemRarity.Epic: colorNumber = 3; break; case Craftable.itemRarity.Legendary: colorNumber = 4; break; default: break; } return(colorNumber); }
public void UpdateCraftable(Craftable craftable) { var item = _list.FirstOrDefault(c => c.Id == craftable.Id); _list.Remove(item); _list.Add(craftable); }
public StartingCraftableData(string name, int cost, Craftable matter, float quantity = 1f) { this.Name = name; this.PerUnitCost = cost; this.Craftable = matter; this.Quantity = quantity; }
private async Task UpdateDb() { try { var items = await _itemService.GetAll(); if (items != null) { foreach (var item in items) { if (await _itemRepository.GetCraftable(item.Id) != null) { continue; } var newItem = new Craftable { Name = item.Name, Requirement = item.Requirement, Materials = item.Materials, Effect = item.Effect, Form = item.Form }; _itemRepository.InsertCraftable(newItem); await _itemRepository.Save(); } } } catch (BrokenCircuitException) { HandleBrokenCircuit(); } }
public void OnEnable() { if (craftable) { craftingRecipe = GetComponent <Craftable>(); } }
public int Sell(Craftable c, int amo) { int amoOfCraftables; if (craftables.TryGetValue(c, out amoOfCraftables)) { if (amo > amoOfCraftables) { amo = amoOfCraftables; } craftables[c] = amoOfCraftables - amo; money += c.GetPrice() * amo; if (OnMoneyChange != null) { OnMoneyChange(money); } if (OnCraftableSold != null) { OnCraftableSold(c, amo); } return(amo); } return(0); }
public void UpdateCraftable(Craftable craftable) { var tgt = _items.Find(s => s.Id == craftable.Id); _items.Remove(tgt); _items.Add(craftable); }
public void Load(SaveData s) { money = s.money; if (OnMoneyChange != null) { OnMoneyChange(money); } craftables = new Dictionary <Craftable, int>(); for (int i = 0; i < s.craftableAmo.Count; i++) { Craftable c = s.craftables[i]; int amo = s.craftableAmo[i]; craftables[c] = amo; } //craftables = s.craftables ?? new SerializableDictionary<Craftable, int>(); for (int i = 0; i < UpgradeTypeAmount; i++) { var data = s.upgradeData[i]; var upgrade = GetUpgrade((UpgradeType)i); upgrade.data = data; var upgradeDelegate = GetUpgradeDelegate((UpgradeType)i); if (upgradeDelegate != null) { upgradeDelegate(upgrade.data.value); } } }
public void Load(float money, UpgradeData[] upgradeData, Dictionary <string, int> craftableAmo) { this.money = money; if (OnMoneyChange != null) { OnMoneyChange(money); } speedUpgrade.data = upgradeData[0]; if (OnCollectSpeedChange != null) { OnCollectSpeedChange(upgradeData[0].value); } radiusUpgrade.data = upgradeData[1]; if (OnCollectRadiusChange != null) { OnCollectRadiusChange(upgradeData[1].value); } efficiencyUpgrade.data = upgradeData[2]; if (OnCollectEfficiencyChange != null) { OnCollectEfficiencyChange(upgradeData[2].value); } weightUpgrade.data = upgradeData[3]; if (OnCollectWeightChange != null) { OnCollectWeightChange(upgradeData[3].value); } accelerationUpgrade.data = upgradeData[4]; if (OnParticleSpeedChange != null) { OnParticleSpeedChange(upgradeData[4].value); } stabilityUpgrade.data = upgradeData[5]; if (OnParticleStabilityChange != null) { OnParticleStabilityChange(upgradeData[5].value); } timeUpgrade.data = upgradeData[6]; if (OnTimeDilationChange != null) { OnTimeDilationChange(upgradeData[6].value); } var craftEnum = craftableAmo.GetEnumerator(); while (craftEnum.MoveNext()) { var craft = craftEnum.Current; Craftable c = Game.Instance.gameData.FindCraftable(craft.Key); craftables[c] = craft.Value; } }
private void OnAtomDiscover(Atom a, float amo) { if (undiscoveredOptions.Count == 0) { Game.Instance.gameData.OnAtomDiscover -= OnAtomDiscover; return; } for (int i = 0; i < undiscoveredOptions.Count; i++) { Craftable c = undiscoveredOptions[i]; bool canCraft = true; var atomsForCraft = c.GetAtomsForProduction(); for (int y = 0; y < atomsForCraft.Length; y++) { var atomAmo = atomsForCraft[y]; if (!Game.Instance.gameData.FindAtomData(atomAmo.atom.GetAtomicNumber()).IsDiscovered()) { canCraft = false; break; } } if (canCraft) { AddCraftable(craftableChoices[c]); undiscoveredOptions.RemoveAt(i); i--; } } }
public void RemoveCraftable() { ChoiceOption choiceOption; if (currCraftable != null && craftableChoices.TryGetValue(currCraftable, out choiceOption)) { var craftable = currCraftable; choiceOption.SetButtonEvent(() => { SetCraftable(craftable); AudioManager.Instance.PlaySound(choiceClickSound); }); choiceOption.SetColors(ChoiceOption.defaultNormalColor, ChoiceOption.defaultHoverColor, ChoiceOption.defaultPressedColor); choiceOption.SetFocus(false); } craftableImage.sprite = Game.Instance.gameData.GetUknownInfo().GetImage(); craftableNameText.text = "???"; craftableInfoText.text = "Price: \nCurr Amo: "; atomsRequiredText.text = ""; atomAmountText.text = ""; currAtomAmountText.text = ""; craftBtn.interactable = false; craftBtnx10.interactable = false; craftBtnx100.interactable = false; sellBtn.interactable = false; sellBtnx10.interactable = false; sellBtnx100.interactable = false; currCraftable = null; }
public void TestForBlueprints() { List <ResourcePickup> blueprintKeysToRemove = blueprints.Keys.ToList(); foreach (Vector2 key in tm.pickups.Keys.ToList()) { if (ResourcePickup.IsAtPosition(key)) { ResourcePickup resourceToTest = tm.pickups [key] as ResourcePickup; Vector3 spawnPos; Craftable craftableInfo = GetCraftableForResource(resourceToTest, out spawnPos); if (craftableInfo is BuildingInfo) { blueprintKeysToRemove.Remove(resourceToTest); } } } foreach (ResourcePickup key in blueprintKeysToRemove) { Destroy(blueprints[key].gameObject); blueprints.Remove(key); } }
public void LinkItem(Craftable setCraftable, Aspect[] setAspects, Crafter setCrafter, bool setPreview = false) { //store crafter vars craftable = setCraftable; allAspects = setAspects; crafter = setCrafter; slotPositions = new Vector2[allAspects.Length]; itemPositions = new Vector2[allAspects.Length]; for (int i = 0; i < allAspects.Length; i++) { slotPositions[i] = crafter.transform.TransformPoint(allAspects[i].slotPosition); itemPositions[i] = crafter.transform.TransformPoint(allAspects[i].itemPosition); } if (setPreview) { isPreview = true; } crafter.colorShift.AddRenderer(ringRenderer); crafter.colorShift.AddRenderer(frameRenderer); InitializeVisuals(); SnapVisuals(); }
public void CraftClick() { Craftable itemToCraft = FindObjectOfType <EventSystem>().currentSelectedGameObject.GetComponent <CraftSlot>().itemToCraft; GameManager.inventory.CraftItem(itemToCraft); RefreshUI(); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Form,Requirement,Effect,Materials")] Craftable craftable) { if (id != craftable.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _itemRepository.UpdateCraftable(craftable); await _itemRepository.Save(); } catch (DbUpdateConcurrencyException) { if (!await CraftableExists(craftable.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(craftable)); }
public async Task UpdateCraftableObjTest() { // Arrange var client = SetupMock_Craftable(); var config = new Mock <IConfiguration>(); client.BaseAddress = new Uri("https://localhost:1111"); config.SetupGet(s => s["ItemsURL"]).Returns("https://localhost:1111/"); var service = new CraftableService(null, config.Object, new NullLogger <CraftableService>()) { Client = client }; // Act var updItem = new Craftable { Id = 2, Name = "Updated Name", Requirement = "Updated", Materials = "Updated", Effect = "Updated", Form = "Updated" }; var result = await service.UpdateCraftable(updItem); // Assert Assert.IsNotNull(result); Assert.AreEqual(updItem.Id, result.Id); Assert.AreEqual(updItem.Name, result.Name); Assert.AreEqual(updItem.Requirement, result.Requirement); Assert.AreEqual(updItem.Form, result.Form); Assert.AreEqual(updItem.Effect, result.Effect); Assert.AreEqual(updItem.Materials, result.Materials); }
public void BuildItem(Craftable item) { if (Gold >= item.Price && CheckStockComps(item)) { Gold -= item.Price; for (int i = 0; i < item.comps.Length; i++) { compInventory[item.comps[i].type] -= item.comps[i].amount; } if (!inventorySlots.ContainsKey(item)) { inventorySlots.Add(item, 1); } else { inventorySlots[item]++; } InventoryDrawer.inventoryDrawer.DisplayItems(); CompDrawer.compDrawer.DisplayComps(); } }
public void Combine(Craftable other) { GameObject.Destroy(this.GetComponent <Throwable>()); GameObject.Destroy(this); GameObject.Destroy(body); this.transform.parent = other.transform; }
void UpdatePreview() { if (CheckIfFull()) { currentCraft = craftCatalog.allCraftables[RealLocation(craftCatalog.template.KeyToLocation(occupiedKey))]; if (previewInitialized) { previewItem.craftable = currentCraft; previewItem.InitializeVisuals(); } else { previewInitialized = true; previewItem = CreateInventoryItem(currentCraft, true); } outputSlot.GetComponent <Renderer>().material.mainTexture = outputReady; } else { if (previewInitialized) { previewInitialized = false; Destroy(previewItem.gameObject); outputSlot.GetComponent <Renderer>().material.mainTexture = outputWaiting; } } }
public async Task PostCraftableTest() { // Arrange var repo = new FakeCraftableRepository(TestData.Items()); var controller = new CraftablesController(repo); var item = new Craftable { Id = 10, Effect = "NEWEFFECT", Form = "NEWFORM", Materials = "NEWMATERIALS", Name = "NEWNAME", Requirement = "NEWREQUIREMENT" }; // Act var result = await controller.PostCraftable(item); // Assert Assert.IsNotNull(result); var objResult = result.Result as CreatedAtActionResult; Assert.IsNotNull(objResult); var valResult = objResult.Value as Craftable; Assert.IsNotNull(valResult); Assert.AreEqual(item, valResult); }
public void FillSlot(int slotAspect, Craftable droppedCraftable) { if (!slotsInitialized) { slotsInitialized = true; currentSlots = new Craftable[allAspects.Length]; occupiedSlots = new bool[allAspects.Length]; occupiedKey = new int[allAspects.Length]; } if (occupiedSlots[slotAspect]) { ClearSlot(slotAspect); } occupiedSlots[slotAspect] = true; currentSlots[slotAspect] = droppedCraftable; currentSlots[slotAspect].isSlotted = true; currentSlots[slotAspect].slottedInAspect = slotAspect; occupiedKey[slotAspect] = currentSlots[slotAspect].aspectKey[slotAspect]; allAspects[slotAspect].slotInterface.GetComponent <Renderer>().material.mainTexture = allAspects[slotAspect].sigils[occupiedKey[slotAspect]].fullArt; UpdatePreview(); }
public void SelectCraftableToBuild() { Craftable whatToBuild = (Craftable)Enum.Parse(typeof(Craftable), UnityEngine.EventSystems.EventSystem.current.currentSelectedGameObject.name); List <IResourceEntry> prereqs = Crafting.CraftData[whatToBuild].Requirements; if (currentWorkshop == null) { UnityEngine.Debug.LogWarning("Tried to craft something but no workshop"); } else if (currentWorkshop.FlexData.CurrentCraftable == Craftable.Unspecified) { bool cheat = false; #if UNITY_EDITOR cheat = Input.GetKey(KeyCode.C); #endif if (cheat) { SelectThing(CraftableFields, null, PlayerInput.Instance.PlanCraftable); } else if (Warehouse.GlobalResourceList.CanConsume(prereqs)) { Warehouse.GlobalResourceList.Consume(prereqs); SelectThing(CraftableFields, null, PlayerInput.Instance.PlanCraftable); } else { GuiBridge.Instance.ShowNews(NewsSource.CraftingInsufficientResources); } } else { SelectThing(CraftableFields, null, PlayerInput.Instance.PlanCraftable); } }
//"Instantiate" a new craftable of the correct type using a passed in key Craftable CreateFromKey(int[] key) { bool found = false; int realLocation = RealLocation(craftCatalog.template.KeyToLocation(key)); Craftable newCraftable = new Craftable(); if (craftCatalog.allCraftables[realLocation].aspectKey[0] == 0) { newCraftable = new Familiar(craftCatalog.allCraftables[realLocation]); found = true; } if (craftCatalog.allCraftables[realLocation].aspectKey[0] == 1 && !found) { newCraftable = new Spell(craftCatalog.allCraftables[realLocation]); found = true; } if (craftCatalog.allCraftables[realLocation].aspectKey[0] == 2 && !found) { newCraftable = new Talisman(craftCatalog.allCraftables[realLocation]); found = true; } if (!found) { Debug.LogError("Create New Craftable failed to find with provided key."); } return(newCraftable); }
public async Task <IActionResult> PutCraftable(int id, Craftable craftable) { if (id != craftable.Id) { return(BadRequest()); } _craftRepository.UpdateCraftable(craftable); try { await _craftRepository.Save(); } catch (DbUpdateConcurrencyException) { if (!await CraftableExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public void AddCraftNode(Craftable item, string parentTabId) { if (!knownItems.Contains(item.ClassID)) { fcTechFabricator.AddCraftNode(item, parentTabId); knownItems.Add(item.ClassID); } }
public void UpdateDetailCraftableProgressView(Craftable craftable, float?progress) { string progressPercentageString = String.Format("{0:0.#}%", progress.Value * 100f); int completionHours = Crafting.CraftData[craftable].BuildTimeHours; int currentHours = Mathf.FloorToInt(progress.Value * completionHours); CraftableFields.Progress.text = String.Format("<b>{0}</b>\n{1}/{2} Hrs", progressPercentageString, currentHours, completionHours); }
public void AddCraftable(Craftable c) { craftables.Add(c); if (OnCraftableDiscover != null) { OnCraftableDiscover(c, 0); } }
Craftable[] AddToCraftableList(Craftable newCraftable, Craftable[] list) { Craftable[] newCraftableList = new Craftable[list.Length + 1]; newCraftableList[0] = newCraftable; for (int i = 1; i < newCraftableList.Length; i++) { newCraftableList[i] = list[i - 1]; } return(newCraftableList); }