Example #1
0
 protected void OnDeselectCashPackage(UICashPackage ui)
 {
     if (uiCashPackageDialog != null)
     {
         uiCashPackageDialog.Hide();
     }
 }
 protected void OnDeselectCashPackage(UICashPackage ui)
 {
     if (uiCashPackageDialog != null)
     {
         uiCashPackageDialog.onHide.RemoveListener(OnCashPackageDialogHide);
         uiCashPackageDialog.Hide();
         uiCashPackageDialog.onHide.AddListener(OnCashPackageDialogHide);
     }
 }
 protected void OnSelectCashPackage(UICashPackage ui)
 {
     if (uiCashPackageDialog != null && ui.Data != null)
     {
         uiCashPackageDialog.selectionManager = CacheCashPackageSelectionManager;
         uiCashPackageDialog.Data             = ui.Data;
         uiCashPackageDialog.Show();
     }
 }
        private void ResponseCashPackageInfo(AckResponseCode responseCode, BaseAckMessage message)
        {
            ResponseCashPackageInfoMessage castedMessage = (ResponseCashPackageInfoMessage)message;

            switch (responseCode)
            {
            case AckResponseCode.Error:
                UISceneGlobal.Singleton.ShowMessageDialog(LanguageManager.GetText(UILocaleKeys.UI_LABEL_ERROR.ToString()), LanguageManager.GetText(UILocaleKeys.UI_ERROR_CANNOT_GET_CASH_PACKAGE_INFO.ToString()));
                break;

            case AckResponseCode.Timeout:
                UISceneGlobal.Singleton.ShowMessageDialog(LanguageManager.GetText(UILocaleKeys.UI_LABEL_ERROR.ToString()), LanguageManager.GetText(UILocaleKeys.UI_ERROR_CONNECTION_TIMEOUT.ToString()));
                break;

            default:
                if (uiTextCash != null)
                {
                    uiTextCash.text = string.Format(
                        LanguageManager.GetText(formatKeyCash),
                        castedMessage.cash.ToString("N0"));
                }

                List <CashPackage> cashPackages = new List <CashPackage>();
                foreach (int cashPackageId in castedMessage.cashPackageIds)
                {
                    CashPackage cashPackage;
                    if (GameInstance.CashPackages.TryGetValue(cashPackageId, out cashPackage))
                    {
                        cashPackages.Add(cashPackage);
                    }
                }

                int selectedIdx = CacheCashPackageSelectionManager.SelectedUI != null?CacheCashPackageSelectionManager.IndexOf(CacheCashPackageSelectionManager.SelectedUI) : -1;

                CacheCashPackageSelectionManager.DeselectSelectedUI();
                CacheCashPackageSelectionManager.Clear();

                CacheCashPackageList.Generate(cashPackages, (index, cashShopItem, ui) =>
                {
                    UICashPackage uiCashPackage  = ui.GetComponent <UICashPackage>();
                    uiCashPackage.uiCashPackages = this;
                    uiCashPackage.Data           = cashShopItem;
                    uiCashPackage.Show();
                    CacheCashPackageSelectionManager.Add(uiCashPackage);
                    if (selectedIdx == index)
                    {
                        uiCashPackage.OnClickSelect();
                    }
                });
                break;
            }
        }