/// <summary> /// Sets the collectible count to the given value. /// </summary> /// <param name="collectibleCount"></param> /// <param name="commit">If true, commit the results to storage.</param> private void Set(CollectibleCount collectibleCount, bool commit) { var item = new InventoryItemState { CollectibleId = collectibleCount.CollectibleId, Count = collectibleCount.Count, CollectTime = ClockManager.Instance.Now }; if (item.Limit.HasValue) { item.Count = Math.Min(item.Count, item.Limit.Value); } m_inventoryItems[collectibleCount.CollectibleId] = item; if (Updated != null) { Updated(this, EventArgs.Empty); } if (commit) { Save(); } }
protected virtual void AddRewardCollectible(Table table, CollectibleCount cc) { var collectible = cc.Collectible; if (collectible == null) { return; } var prefab = GetRewardCollectiblePrefab(collectible); var aiObj = table.AddItem(prefab); if (aiObj.ItemName) { aiObj.ItemName.text = collectible.Title; } aiObj.Count.text = string.Format("{0}", cc.Count); aiObj.Id = cc.CollectibleId; if (collectible.ImageUrl != null) { ImageLoader.LoadImageOnThread(collectible.ImageUrl, aiObj.Image); } }
protected virtual void AddGiveCollectible(Table table, CollectibleCount cc) { var collectible = cc.Collectible; if (collectible == null) { return; } var prefab = GetGiveCollectiblePrefab(collectible); var aiObj = table.AddItem(prefab); aiObj.Id = cc.CollectibleId; var invCount = Inventory.Instance.GetCount(cc.CollectibleId); if (aiObj.ItemName) { aiObj.ItemName.text = collectible.Title; } var satisfied = invCount >= cc.Count; aiObj.Count.text = StringFormatter.GetGiveCountString(invCount, cc.Count, NeedsMoreTextColor); if (collectible.ImageUrl != null) { ImageLoader.LoadImageOnThread(collectible.ImageUrl, aiObj.Image); } if (aiObj.SatisfiedObject) { aiObj.SatisfiedObject.SetActive(satisfied); } }
/// <summary> /// Adds the count of the specified collectible to the inventory. /// </summary> /// </summary> /// <param name="collectibleCount"></param> public void Add(CollectibleCount collectibleCount) { Add(collectibleCount.CollectibleId, collectibleCount.Count, true); }
private void Set(CollectibleCount collectibleCount) { Set(collectibleCount, true); }
/// <summary> /// Removes the count of collectibles from the inventory. /// </summary> /// <param name="collectibleCount"></param> public void Remove(CollectibleCount collectibleCount) { Remove(collectibleCount, true); }
void Remove(CollectibleCount collectibleCount, bool commit) { Remove(collectibleCount.CollectibleId, collectibleCount.Count, commit); }