Exemple #1
0
        protected virtual void HandleResponseCashPackageInfo(LiteNetLibMessageHandler messageHandler)
        {
            TransportHandler transportHandler      = messageHandler.transportHandler;
            ResponseCashPackageInfoMessage message = messageHandler.ReadMessage <ResponseCashPackageInfoMessage>();

            transportHandler.TriggerAck(message.ackId, message.responseCode, message);
        }
Exemple #2
0
        protected virtual void HandleRequestCashPackageInfo(LiteNetLibMessageHandler messageHandler)
        {
            long           connectionId = messageHandler.connectionId;
            BaseAckMessage message      = messageHandler.ReadMessage <BaseAckMessage>();
            ResponseCashPackageInfoMessage responseMessage = new ResponseCashPackageInfoMessage();

            responseMessage.ackId        = message.ackId;
            responseMessage.responseCode = AckResponseCode.Error;
            responseMessage.error        = ResponseCashPackageInfoMessage.Error.NotAvailable;
            ServerSendPacket(connectionId, DeliveryMethod.ReliableOrdered, MsgTypes.CashPackageInfo, responseMessage);
        }
        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;
            }
        }