Exemple #1
0
 protected void OnSelectCashShopItem(UICashShopItem ui)
 {
     if (uiCashShopItemDialog != null && ui.Data != null)
     {
         uiCashShopItemDialog.selectionManager = SelectionManager;
         uiCashShopItemDialog.Data             = ui.Data;
         uiCashShopItemDialog.Show();
     }
 }
        private void ResponseCashShopInfo(AckResponseCode responseCode, BaseAckMessage message)
        {
            ResponseCashShopInfoMessage castedMessage = (ResponseCashShopInfoMessage)message;

            switch (responseCode)
            {
            case AckResponseCode.Error:
                UISceneGlobal.Singleton.ShowMessageDialog(LanguageManager.GetText(UILocaleKeys.UI_LABEL_ERROR.ToString()), LanguageManager.GetText(UILocaleKeys.UI_ERROR_CANNOT_GET_CASH_SHOP_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 <CashShopItem> cashShopItems = new List <CashShopItem>();
                foreach (int cashShopItemId in castedMessage.cashShopItemIds)
                {
                    CashShopItem cashShopItem;
                    if (GameInstance.CashShopItems.TryGetValue(cashShopItemId, out cashShopItem))
                    {
                        cashShopItems.Add(cashShopItem);
                    }
                }

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

                CacheCashShopSelectionManager.DeselectSelectedUI();
                CacheCashShopSelectionManager.Clear();

                CacheCashShopList.Generate(cashShopItems, (index, cashShopItem, ui) =>
                {
                    UICashShopItem uiCashShopItem = ui.GetComponent <UICashShopItem>();
                    uiCashShopItem.uiCashShop     = this;
                    uiCashShopItem.Data           = cashShopItem;
                    uiCashShopItem.Show();
                    CacheCashShopSelectionManager.Add(uiCashShopItem);
                    if (selectedIdx == index)
                    {
                        uiCashShopItem.OnClickSelect();
                    }
                });
                break;
            }
        }