Example #1
0
        private void OnModifierUsed(ModifierType.Type type)
        {
            if (!_playerState.IsModifierAvailable(type))
            {
                return;
            }

            var level = SettingHelper.GetModifierLevel(type)
                        .GetOrDefault(0);

            if (level == 0)
            {
                return;
            }

            var modifier = ModifierFactory.GetModifier(type, level);

            _modifiersList.Add(modifier);

            List <Modifier> modifiers;

            try
            {
                modifiers = _modifiersMap[modifier.Target];
            }
            catch (Exception e)
            {
                modifiers = new List <Modifier>();
                _modifiersMap[modifier.Target] = modifiers;
            }

            modifiers.Add(modifier);

            _playerState.DecreaseModifierUnit(type);
        }
        private void UpdateUI()
        {
            var unlockedLevel = SettingHelper.GetModifierLevel(type)
                                .GetOrDefault(0);

            _level = unlockedLevel + 1;
            Debug.Log($"level {_level}");

            if (_level == 3)
            {
                buyButton.interactable = false;
                buyButton.GetComponentInChildren <Text>()
                .text = "Already unlocked";

                buyPrice.text    = "";
                description.text = "";

                return;
            }

            ResourcesHelper.SetFeaturesFromTextFile(
                string.Format(TowerFeatureFile, type, _level),
                SetFeature
                );

            Debug.Log($"price: {_unlockPrice}");

            _availableFounds = SettingHelper.GetAvailableFounds();

            buyPrice.text          = _unlockPrice.ToString();
            description.text       = _modifierDescription;
            buyButton.interactable = _availableFounds >= _unlockPrice;
            buyButton.GetComponentInChildren <Text>()
            .text = $"<b>{_modifierName}</b>\n<i>Level {_level}</i>";
        }
Example #3
0
 public bool IsModifierAvailable(ModifierType.Type type)
 {
     return(SettingHelper.GetModifierLevel(type)
            .GetOrDefault(0) > 0 &&
            GetModifierUnit(type) > 0);
 }