예제 #1
0
        /// <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();
            }
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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);
            }
        }
예제 #4
0
 /// <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);
 }
예제 #5
0
 private void Set(CollectibleCount collectibleCount)
 {
     Set(collectibleCount, true);
 }
예제 #6
0
 /// <summary>
 /// Removes the count of collectibles from the inventory.
 /// </summary>
 /// <param name="collectibleCount"></param>
 public void Remove(CollectibleCount collectibleCount)
 {
     Remove(collectibleCount, true);
 }
예제 #7
0
 void Remove(CollectibleCount collectibleCount, bool commit)
 {
     Remove(collectibleCount.CollectibleId, collectibleCount.Count, commit);
 }