示例#1
0
        // Add an item of this type
        public static void AddItem(ItemType itemType, int quantity)
        {
            _saveFile.PlayerItems[itemType] += quantity;

            switch (itemType)
            {
            case ItemType.Anima:
                _saveFile.TotalAnimaHarvested += quantity;
                PlayerProgress.CheckNexusAbilityUnlocks(_saveFile.TotalAnimaHarvested);
                OnAnimaChangedAction?.Invoke(_saveFile.PlayerItems[ItemType.Anima], quantity);
                break;

            case ItemType.Star:
                OnStarGainedAction?.Invoke(_saveFile.PlayerItems[ItemType.Star]);
                break;
            }
        }
示例#2
0
        // Consume multiple items of this type
        public static void SpendItem(ItemType itemType, int quantity)
        {
            if (quantity <= _saveFile.PlayerItems[itemType])
            {
                _saveFile.PlayerItems[itemType] -= quantity;

                switch (itemType)
                {
                // keep track of when an Anima Shard is harvested
                case ItemType.AnimaShard:
                    _saveFile.TotalAnimaShardsHarvested += quantity;
                    break;

                case ItemType.Anima:
                    OnAnimaChangedAction?.Invoke(_saveFile.PlayerItems[ItemType.Anima], quantity);
                    break;
                }
            }

            else
            {
                Debug.Log("Player Progress: Tried to spend " + quantity + " " + itemType + " with only " + _saveFile.PlayerItems[itemType] + " in inventory");
            }
        }