Exemplo n.º 1
0
        private void OnBuyButtonClick()
        {
            if (IsAdUpgrade)
            {
                string parameterName = m_dynamicParameter.ParameterType.ToFriendlyName();

                BuyService buyService = new AdBuyService(string.Format(StringConstants.Formats.AdUpgradeParameterFormat, parameterName));
                buyService.TryToBuy(0, () =>
                {
                    m_upgradesCount = 0;
                    DisplayInfo(ServiceLocator.Instance.Get <IUserProfileModel>().GetCurrency(m_currencyType).Value);
                    EventUpgraded?.Invoke();
                });
            }
            else
            {
                BuyService buyService;

                if (m_currencyType == CurrencyType.Dollar)
                {
                    buyService = new DollarsBuyService();
                }
                else
                {
                    buyService = new RespectBuyService();
                }

                buyService.TryToBuy(m_dynamicParameter.Price, () =>
                {
                    m_upgradesCount++;
                    DisplayInfo(ServiceLocator.Instance.Get <IUserProfileModel>().GetCurrency(m_currencyType).Value);
                    EventUpgraded?.Invoke();
                });
            }
        }
Exemplo n.º 2
0
        private void UpgradeButtonClick()
        {
            if (m_dynamicParameter.IsMaxLevel)
            {
                return;
            }

            if (IsAdUpgrade)
            {
                string parameterName = m_dynamicParameter.ParameterType.ToFriendlyName();

                BuyService buyService = new AdBuyService(string.Format(StringConstants.Formats.AdUpgradeParameterFormat, parameterName));
                buyService.TryToBuy(0, () =>
                {
                    m_upgradesCount = 0;
                    m_dynamicParameter.Upgrade();
                });
            }
            else
            {
                BuyService buyService = new RespectBuyService();
                buyService.TryToBuy((int)m_dynamicParameter.Price, () =>
                {
                    m_upgradesCount++;
                    m_dynamicParameter.Upgrade();
                });
            }

            AudioClipData audioClipData = ConfigManager.Instance.Get <AudioConfig>().UpgradeParameterAudioClipData;

            AudioManager.Instance.PlaySoundFx(audioClipData);
        }