public void Load(UXMLElement element) { string curid = element.GetString("id", string.Empty); InventoryItemType type = element.GetEnum <InventoryItemType>("type"); count = element.GetInt("count", 0); //Debug.Log($"loaded item {curid}-{type}-{count}".Colored(ColorType.green)); if (string.IsNullOrEmpty(curid)) { InitSave(); } else { data = resourceService.GetInventoryItemData(type, curid); if (data == null) { //Debug.Log($"item data is null {curid}-{type}".Colored(ColorType.fuchsia)); InitSave(); } else { //Debug.Log($"item data not null {curid}-{type}".Colored(ColorType.grey)); } } }
public async Task <IActionResult> RemoveInventory(Guid itemId, InventoryItemType selectedItemType) { var partitionKey = new ServicePartitionKey((int)selectedItemType); var partitionClient = new ServicePartitionClient <HttpCommunicationClient>(_clientFactory, _serviceUri, partitionKey); var item = await partitionClient.InvokeWithRetryAsync(async (client) => { var response = await client.HttpClient.GetAsync(new Uri($"{client.BaseUri}/api/inventory/{itemId}")); if (!response.IsSuccessStatusCode) { throw new InvalidOperationException($"Error - {response.StatusCode}: {response.ReasonPhrase}"); } var responseContent = await response.Content.ReadAsStringAsync(); return(JsonConvert.DeserializeObject <InventoryItem>(responseContent)); }, CancellationToken.None); var viewModel = new InventoryQuantityViewModel { ItemId = item.ItemId, ItemType = item.ItemType, Display = $"{item.Name} ({item.ItemType})", IsAdd = false, Quantity = 1 }; return(View("UpdateInventoryQuantity", viewModel)); }
public void GetHit(InventoryItemType weapon) { int healthLoss = 0; if (weapon == InventoryItemType.Dagger) { healthLoss = rng.Range(1, 3); } else if (weapon == InventoryItemType.ShortSword) { healthLoss = rng.Range(2, 5); } else if (weapon == InventoryItemType.Scimitar) { healthLoss = rng.Range(5, 8); } else if (weapon == InventoryItemType.Bow) { healthLoss = 1; } health -= healthLoss; if (health < 1) { StartDying(weapon); } if (!isDead) { MoveToRandomDirection(); } }
public void AddToInventory(InventoryItemType itemType, int count) { if (itemType == InventoryItemType.Arrows) { AddToInventory(new InventoryItem(itemType, count, arrowSprite)); } }
private void OnInventoryChanged(InventoryItemType type, string id, int count) { if (data != null && data.type == type && data.id == id) { Setup(data); } }
public void GetHit(InventoryItemType weapon) { int healthLoss = 0; if (weapon == InventoryItemType.Dagger) { healthLoss = rng.Range(1, 3); } else if (weapon == InventoryItemType.ShortSword) { healthLoss = rng.Range(2, 5); } else if (weapon == InventoryItemType.Scimitar) { healthLoss = rng.Range(5, 8); } else if (weapon == InventoryItemType.Bow) { healthLoss = rng.Range(1, 3); } int newHealth = UIManager.main.AddToEnemyHealth(-healthLoss); if (newHealth < 1) { Die(); } else { MoveAway(); } }
public void NewPopupMerchant(Character character, AlignmentMerchant alignment, InventoryItemType type, bool isBuying, System.Func <List <InventoryItem>, object> resultAction, List <InventoryItem> itemsForSale) { var tmpPopupObject = Resources.Load <GameObject>("Prefabs/PopupMerchant"); var tmpPopupInstance = Instantiate(tmpPopupObject, tmpPopupObject.transform.position, tmpPopupObject.transform.rotation); Constants.IncreaseInputLayer(tmpPopupInstance.name); tmpPopupInstance.GetComponent <PopupMerchantBhv>().SetPrivates(character, alignment, type, isBuying, resultAction, itemsForSale); }
public InventoryItemViewModel(int id, string name, int level, InventoryItemType itemType) { this.Id = id; this.Name = name; this.Level = level; ItemType = itemType; }
public IActionResult AddNewInventoryItem(InventoryItemType itemType) { var newItem = new InventoryItem { ItemType = itemType }; return(View(newItem)); }
private void OnInventoryChanged(InventoryItemType type, string itemId, int count) { if (IsSetupCompleted) { if (itemData.type == type && itemData.id == itemId) { Resetup(); } } }
private void OnInventoryChanged(InventoryItemType type, string itemId, int count) { if (data != null) { if (type == data.type && itemId == data.id) { Setup(data); } } }
public InventoryItem(InventoryItemType itemType, int itemId, string itemName, int itemPrice, int itemMaxStackSize, Bitmap icon, bool isQuestItem = false) { _type = itemType; _id = itemId; _name = itemName; _price = itemPrice; _maxStackSize = itemMaxStackSize; _icon = icon; _quest = isQuestItem; }
public List <InventoryItem> GetItems(InventoryItemType type) { Dictionary <string, InventoryItem> filtered = null; if (items.TryGetValue(type, out filtered)) { return(new List <InventoryItem>(filtered.Values)); } return(new List <InventoryItem>()); }
public void ShowMessage(AnimalType animal, InventoryItemType weapon, int projectileCount) { ShowMessage(string.Format( "You killed a <color=#{0}><b>{1}</b></color> with your <color=#{2}><b>{3}</b></color>!", GetColorAsString(animal), animal, GetColorAsString(weapon), weapon )); }
public InventoryItemType SetItem(InventoryItemType item) { InventoryItemType oldItem = inventory.GetItemInGrid(x, y); inventory.SetItemInGrid(x, y, item); UpdateCell(); return(oldItem); }
private void OnInventoryChanged(InventoryItemType type, string itemId, int count) { if (type == InventoryItemType.StoryCharger || type == InventoryItemType.StoryCollectable || type == InventoryItemType.StoryCollection) { if (cachedData != null) { Setup(cachedData); Debug.Log("OnInventoryAdded resetup StoryCollectionChargerView"); } } }
private void OnItemAdded(InventoryItemType type, string id, int count) { if (type == InventoryItemType.StoryCollectable || type == InventoryItemType.StoryCollection || type == InventoryItemType.Collectable || type == InventoryItemType.Collection) { int completedQuestCount = TryCompleteQuests(); Debug.Log($"{completedQuestCount} completed when inventory item added..."); } }
/// <summary> /// Checks if the player has a key /// </summary> /// <returns></returns> public bool HasItem(InventoryItemType itemType) { foreach (InventoryItem item in (Inventory.Items)) { if (item.type == itemType) { return(true); } } return(false); }
private void OnInventoryChanged(InventoryItemType itemType, string itemId, int count) { if (itemData != null && message != null && sender != null) { if (itemData.type == itemType && itemData.id == itemId) { UpdateIconImage(sender, itemData); UpdateGiftButtonState(sender, itemData); } } }
public List <Item> GetInventoryItemsByCategory(InventoryItemType inventoryItemType) { logger.LogDebug("Getting all Cables and trays"); List <IParameter> parameters = new List <IParameter>(); parameters.Add(new Parameter() { ColumnName = "Category", DataType = "System.Int", Operator = DBProviderBase.Enums.ParamOperator.Equals, Value = inventoryItemType.ToString() }); return(dataService.GetObjectData <Item>(parameters)); }
public void SetItemInGrid(int x, int y, InventoryItemType item) { int index = ROW_WIDTH * y + x; if (index >= items.Length) { throw new ArgumentOutOfRangeException("Out of bounds [" + x + "," + y + "]"); } items[index] = item; }
public Color GetInventoryItemColor(InventoryItemType inventoryItem) { foreach (InventoryItemColor itemColor in itemColors) { if (itemColor.Item == inventoryItem) { return(itemColor.Color); } } return(Color.white); }
public void ShowMessage(InventoryItemType weapon, MessageType messageType) { if (messageType == MessageType.NoAmmo) { ShowMessage(string.Format( "You have ran out of ammo for your <color=#{0}><b>{1}</b></color>", GetColorAsString(weapon), weapon )); } }
public void AddToCount(InventoryItemType itemType, int addition) { foreach (InventoryItem ownedItem in ownedItems) { if (ownedItem.InventoryItemType == itemType) { ownedItem.Count += addition; FindUIOwnedItem(ownedItem).UpdateItemCount(ownedItem.Count, addition > 0); break; } } }
public void ShowMessage(MessageType messageType, InventoryItemType inventoryItemType, int value) { if (messageType == MessageType.ItemCountUpdate) { /*ShowMessage(string.Format( * "You now have {0} <color=#{1}><b>{2}</b></color>!", * value, * GetColorAsString(inventoryItemType), * inventoryItemType * ));*/ } }
public DropItem(UXMLElement element) { this.type = element.GetEnum <DropType>("type"); this.count = element.GetInt("count"); if (this.type == DropType.item) { string itemId = element.GetString("item_id"); InventoryItemType itemType = element.GetEnum <InventoryItemType>("item_type"); this.itemData = resourceService.GetInventoryItemData(itemType, itemId); } }
private void OnInventoryChanged(InventoryItemType type, string id, int count) { if (type == InventoryItemType.Collectable || type == InventoryItemType.Charger || type == InventoryItemType.Collection) { if (collectionData != null) { Setup(collectionData); } } }
public bool AddItemInEmptySlot(InventoryItemType item) { for (int i = 0; i < items.Length; i++) { if (items[i] == InventoryItemType.Empty) { items[i] = item; return(true); } } return(false); }
void StartDying(InventoryItemType weapon) { animator.enabled = true; UIManager.main.ShowMessage(animalType, weapon, numProjectiles); SoundManager.main.PlaySound(SoundType.AnimalDie); isDead = true; polygonCollider2D.isTrigger = true; rb2D.isKinematic = true; rb2D.velocity = Vector2.zero; moving = false; }
public int GetItemCount(InventoryItemType inventoryItemType) { int count = -1; foreach (InventoryItem ownedItem in ownedItems) { if (ownedItem.InventoryItemType == inventoryItemType) { return(ownedItem.Count); } } return(count); }
public static bool CanRun(InventoryItemType from, InventoryItemType to, bool excludeLegendaryUpgradeRares = false, bool checkStash = false) { if (!ZetaDia.IsInGame || !ZetaDia.IsInTown) return false; if (!Inventory.MaterialConversionTypes.Contains(to) || !Inventory.MaterialConversionTypes.Contains(from)) { Logger.LogVerbose(LogCategory.Behavior, "[ConvertMaterials] Unable to convert from {0} to {1}", from, to); return false; } if (!GetSacraficialItems(to, excludeLegendaryUpgradeRares).Any()) { Logger.LogVerbose(LogCategory.Behavior, "[ConvertMaterials] You dont enough valid weapon/armor/jewellery in backpack", from, to); return false; } Inventory.Materials.Update(); Inventory.Materials.LogCounts(); if (checkStash) { if (Inventory.Materials[InventoryItemType.DeathsBreath].TotalStackQuantity >= 1 && Inventory.Materials[from].TotalStackQuantity > 100) { Logger.LogVerbose(LogCategory.Behavior, "[ConvertMaterials] Enough materials to convert from {0} ({1}) to {2}", from, Inventory.Materials[from].TotalStackQuantity, to); return true; } } if (Inventory.Materials[from].BackpackStackQuantity > 100) { Logger.LogVerbose(LogCategory.Behavior, "[ConvertMaterials] We have enough Backpack materials to convert from {0} ({1}) to {2}", from, Inventory.Materials[from].BackpackStackQuantity, to); return true; } Logger.LogVerbose(LogCategory.Behavior, "[ConvertMaterials] Not Enough Backpack materials to convert from {0} ({1}) to {2}, Deaths={3}", from, Inventory.Materials[from].BackpackStackQuantity, to, Inventory.Materials[InventoryItemType.DeathsBreath].BackpackStackQuantity); return false; }
public static List<ACDItem> OfType(InventoryItemType type) { return AllStashItems.Where(i => i.ActorSNO == (int)type).ToList(); }
private void Update(InventoryItemType it) { switch (it) { case InventoryItemType.weapon: _equipment = MenuState.Party.Inventory.GetWeaponsOfType(MenuState.Party.Selected.Weapon.Wielder); break; case InventoryItemType.armor: _equipment = MenuState.Party.Inventory.GetArmor(MenuState.Party.Selected.Sex); break; case InventoryItemType.accessory: _equipment = MenuState.Party.Inventory.GetAccessories(); break; default: break; } }
public bool HasStackQuantityOfType(InventoryItemType type, InventorySlot location, int quantity) { return Source[type].StackQuantityByInventorySlot(location) > quantity; }
public IInventoryItem GetInventoryItem(string id, InventoryItemType type) { IInventoryItem item = null; switch (type) { case InventoryItemType.item: item = GetItem(id); break; case InventoryItemType.weapon: item = GetWeapon(id); break; case InventoryItemType.armor: item = GetArmor(id); break; case InventoryItemType.accessory: item = GetAccessory(id); break; } return item; }
public MaterialRecord this[InventoryItemType i] { get { return Source[i]; } set { Source[i] = value; } }
//TODO : Make shopsterify user contain apiContext and shopifyAuth objects, then code that takes both a ApiContext and ShopifyStoreAuth can just take a shopsterifyUser private bool CreateProductAndMap(ApiContext apiContext, ShopifyStoreAuth shopifyAuth, InventoryItemType shopsterItem, ShopifyMetafieldMap shopifyMapping) { //Steps are: Upload Item to Shopify, Create metafield, Update map according to new productId //Upload to shopify List<InventoryCategoryType> categories = (shopsterItem.Categories == null || shopsterItem.Categories.Count < 1) ? new List<InventoryCategoryType>(1) : new List<InventoryCategoryType>(shopsterItem.Categories.Count); if (shopsterItem.Categories != null) categories.AddRange(shopsterItem.Categories.Select(categoryId => _shopsterComm.GetCategory(apiContext, categoryId))); //get the categories for this item ShopifyResponse<ShopifyProduct> response = _shopifyComm.CreateProduct(shopifyAuth, ShopsterifyConverter.convertItem( shopsterItem, categories)); if (response.State == ResponseState.OK) { _metaFieldShopsterProductId.Value = shopsterItem.ItemId; if (response.ResponseObject.Id != null) { if (response.ResponseObject.Created != null) { ShopifyMetafieldMapping newMap = ShopifyMetafieldMapping.CreateMetafieldMapping((int) response.ResponseObject.Id, (DateTime) response.ResponseObject.Created, _metaFieldShopsterProductId); //Update map (add mapping will create/update the ShopifyMetafield on shopify) if (shopifyMapping.AddMapping(newMap)) { #if DEBUG logger.DebugFormat( "ConnectsterController::CreateProductAndMap(): CreatedProduct({0}) and mapping on Shopify.", response.ResponseObject.Id); #endif return true; } } } } #if DEBUG logger.DebugFormat( "ConnectsterController::CreateProductAndMap(): attempted to create mapping and failed. ShopsterToken({0}), ShopifySubdomain({1}, shopsterItemId({2})", apiContext.AccessToken, shopifyAuth.StoreSubDomain, shopsterItem.ItemId); #endif return false; }
/// <summary> /// Converts crafting materials into other types of crafting materials /// </summary> /// <param name="from">the type of material you will consume</param> /// <param name="to">the type of material you will get more of</param> public static async Task<bool> Execute(InventoryItemType from, InventoryItemType to) { Logger.Log("[ConvertMaterials] Wooo! Lets convert some {0} to {1}", from, to); if (!ZetaDia.IsInGame || !ZetaDia.IsInTown) return true; if (!Inventory.MaterialConversionTypes.Contains(to) || !Inventory.MaterialConversionTypes.Contains(from)) { Logger.Log("[Cube] Unable to convert from {0} to {1}", from, to); return true; } var backpackDeathsBreathAmount = Inventory.Backpack.DeathsBreath.Select(i => i.ItemStackQuantity).Sum(); var backpackFromMaterialAmount = Inventory.Backpack.OfType(from).Select(i => i.ItemStackQuantity).Sum(); var backpackToMaterialAmount = Inventory.Backpack.OfType(to).Select(i => i.ItemStackQuantity).Sum(); Inventory.Materials.Update(); var sacraficialItems = GetSacraficialItems(to); Logger.LogVerbose("[ConvertMaterials] Starting Material Counts DeathsBreath={0} {1}={2} {3}={4} SacraficialItems={5}", backpackDeathsBreathAmount, from, backpackFromMaterialAmount, to, backpackToMaterialAmount, sacraficialItems.Count); while (CanRun(from, to)) { Inventory.Materials.Update(); sacraficialItems = GetSacraficialItems(to); var item = sacraficialItems.First(); var transmuteGroup = new List<ACDItem> { Inventory.Backpack.DeathsBreath.First(), item }; sacraficialItems.Remove(item); // Make sure we include enough materials by adding multiple stacks if nessesary. var materialStacks = Inventory.GetStacksUpToQuantity(Inventory.Backpack.OfType(from), 50).ToList(); if (materialStacks.Any(m => !m.IsValid || m.IsDisposed) || !item.IsValid || item.IsDisposed) { Logger.LogError("[ConvertMaterials] something is terribly wrong our items are not valid"); return true; } transmuteGroup.AddRange(materialStacks); await Transmute.Execute(transmuteGroup); await Coroutine.Sleep(1500); await Coroutine.Yield(); var newToAmount = Inventory.Backpack.OfType(to).Select(i => i.ItemStackQuantity).Sum(); if(newToAmount > backpackToMaterialAmount) { Logger.Log("[ConvertMaterials] Converted materials '{0}' ---> '{1}'", from, to); backpackToMaterialAmount = newToAmount; backpackFromMaterialAmount = Inventory.Backpack.OfType(from).Select(i => i.ItemStackQuantity).Sum(); backpackDeathsBreathAmount = Inventory.Backpack.DeathsBreath.Select(i => i.ItemStackQuantity).Sum(); ConsecutiveFailures = 0; } else { ConsecutiveFailures++; if (ConsecutiveFailures > 3) { Inventory.InvalidItemDynamicIds.Add(item.ACDGuid); } Logger.LogError("[ConvertMaterials] Failed to convert materials"); return true; } await Coroutine.Sleep(100); await Coroutine.Yield(); } Logger.LogVerbose("[ConvertMaterials] Finishing Material Counts DeathsBreath={0} {1}={2} {3}={4} SacraficialItems={5}", backpackDeathsBreathAmount, from, backpackFromMaterialAmount, to, backpackToMaterialAmount, sacraficialItems.Count); return true; }
public static List<ACDItem> GetSacraficialItems(InventoryItemType to, bool excludeLegendaryUpgradeRares = false) { List<ACDItem> sacraficialItems = new List<ACDItem>(); switch (to) { case InventoryItemType.ReusableParts: sacraficialItems = GetBackpackItemsOfQuality(new List<ItemQuality> { ItemQuality.Inferior, ItemQuality.Normal, ItemQuality.Superior }); break; case InventoryItemType.ArcaneDust: sacraficialItems = GetBackpackItemsOfQuality(new List<ItemQuality> { ItemQuality.Magic1, ItemQuality.Magic2, ItemQuality.Magic3 }); break; case InventoryItemType.VeiledCrystal: sacraficialItems = GetBackpackItemsOfQuality(new List<ItemQuality> { ItemQuality.Rare4, ItemQuality.Rare5, ItemQuality.Rare6 }); break; } if (excludeLegendaryUpgradeRares) { var upgradeRares = CubeRaresToLegendary.GetBackPackRares(); sacraficialItems.RemoveAll(i => upgradeRares.Contains(i)); } sacraficialItems.RemoveAll(i => Inventory.InvalidItemDynamicIds.Contains(i.ACDGuid)); return sacraficialItems; }
// todo refactor this to use the timestamp in the shopsterItem public bool UpdateShopsterProductTimeStamp(InventoryItemType shopsterItem, DateTime timestamp) { if (shopsterItem == null) { throw new ArgumentException("Neither arguments can be null"); } string query = String.Format( @" UPDATE ShopsterProduct SET versiondate = '{0:yyyy-MM-dd HH:mm:ss}' where ShopsterId = {1} LIMIT 1;", timestamp, shopsterItem.ItemId); var sqlCommand = new MySqlCommand(query, _dbConn); try { if (sqlCommand.ExecuteNonQuery() == 1) { return true; } Logger.ErrorFormat( "UpdateShopsterProductTimeStamp(): Attempted to update timestamp but product({0}) wasnt found", shopsterItem.ItemId); return false; } catch (Exception dbEx) { Logger.ErrorFormat( "UpdateShopsterProductTimeStamp(): Database exception while attempting to update shopsterProduct({0}) with timestamp ({1}). " + dbEx.Message, shopsterItem.ItemId, timestamp); return false; } }
public bool InsertProductForUser(ConnectsterUser user, InventoryItemType shopsterProduct, ShopifyProduct shopifyProduct) { //TODO: have this take a bool to decide if shopster is master, for now true //Todo: have actual dates from Shopster API, when available. return InsertProductForUser(user, Convert.ToInt32(shopsterProduct.ItemId), (DateTime.Now.ToUniversalTime()), (int) shopifyProduct.Id, ((DateTime) shopifyProduct.Variants[0].UpdatedAt).ToUniversalTime()); }