コード例 #1
0
ファイル: Helper.cs プロジェクト: tomassimonavicius/SDO
        public static ClientData SdoDeserializeClientData(byte[] data)
        {
            ClientData clientData = new ClientData();

            int dataLength = data.Length;
            int position = 0;
            int markCount = IsMarkByte(data[position]);

            while (markCount < 0 || dataLength < position || data[position] == 0)
            {
                position++;
                markCount = IsMarkByte(data[position]);
            }

            position++;

            for (int i = 0; i < markCount; i++)
            {
                while (data[position] != i + 1 || dataLength < position || data[position] == 0)
                {
                    position++;
                }

                if (dataLength < position || data[position] == 0)
                    return clientData;

                position++;

                switch (i + 1)
                {
                    case 1:
                        clientData.Id = SdoDeserializeString(data, ref position);
                        break;
                    case 2:
                        clientData.Text = SdoDeserializeString(data, ref position);
                        break;
                    case 3:
                        clientData.Key = SdoDeserializeString(data, ref position);
                        break;
                    case 4:
                        clientData.Iv = SdoDeserializeString(data, ref position);
                        break;
                    case 5:
                        clientData.Algorithm = SdoDeserializeString(data, ref position);
                        break;
                    case 6:
                        clientData.Action = SdoDeserializeString(data, ref position);
                        break;
                }
            }

            return clientData;
        }
コード例 #2
0
ファイル: Helper.cs プロジェクト: tomassimonavicius/SDO
 public static string ProcessClientData(ClientData clientData)
 {
     switch (clientData.Action)
     {
         case "Encrypt":
             return EncryptDecrypt.Encrypt(clientData.Text, clientData.Algorithm, clientData.Key, clientData.Iv);
         case "Decrypt":
             return EncryptDecrypt.Decrypt(clientData.Text, clientData.Algorithm, clientData.Key, clientData.Iv);
         default:
             throw new Exception("Not supported client action.");
     }
 }
コード例 #3
0
ファイル: Client.cs プロジェクト: tomassimonavicius/SDO
        private ClientData ReadClientData()
        {
            ClientData clientData = new ClientData();

            XmlReaderSettings settings = new XmlReaderSettings {IgnoreWhitespace = true, IgnoreComments = true};
            using (XmlReader reader = XmlReader.Create("clientdata.xml", settings))
            {
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.LocalName == "id")
                    {
                        clientData.Id = reader.ReadElementContentAsString();
                        clientData.Text = reader.ReadElementContentAsString();
                        clientData.Key = reader.ReadElementContentAsString();
                        clientData.Iv = reader.ReadElementContentAsString();
                        clientData.Algorithm = reader.ReadElementContentAsString();
                        clientData.Action = reader.ReadElementContentAsString();
                    }
                }
            }

            return clientData;
        }
コード例 #4
0
ファイル: Helper.cs プロジェクト: tomassimonavicius/SDO
        public static byte[] SdoSerializeClientData(ClientData clientData)
        {
            byte[][] data = new byte[6][];

            data[0] = SdoSerializeString(clientData.Id);
            data[1] = SdoSerializeString(clientData.Text);
            data[2] = SdoSerializeString(clientData.Key);
            data[3] = SdoSerializeString(clientData.Iv);
            data[4] = SdoSerializeString(clientData.Algorithm);
            data[5] = SdoSerializeString(clientData.Action);

            byte[] bytes = new byte[data[0].Length + data[1].Length + data[2].Length + data[3].Length + data[4].Length + data[5].Length + 7];
            bytes[0] = 0xFE;

            int index = 1;
            for (int i = 1; i < 7; i++)
            {
                byte[] d = data[i - 1];

                bytes[index] = (byte)i;
                index++;
                d.CopyTo(bytes, index);
                index += d.Length;
            }

            return bytes;
        }
コード例 #5
0
        private void ShowGift()
        {
            ClientData.LoadItemDescData(null);
            ClientData.LoadSpecialItemDescData(null);

            var npcId  = GlobalData.PlayerModel.PlayerVo.NpcId;
            var npcImg = transform.GetRawImage("window/RoleImage" + npcId);

            npcImg.texture = ResourceManager.Load <Texture>("Background/PersonIcon/Npc" + npcId, null, true);
            npcImg.gameObject.Show();



            _triggerGiftVo = _list[_currentIndex];

            _titleText.text = _triggerGiftVo.Rule.MallName;
            _desc.text      = _triggerGiftVo.Rule.MallDesc;

            List <RewardVo> rewardList = _triggerGiftVo.GetRewardList();

            for (int i = 0; i < _content.childCount; i++)
            {
                Transform child = _content.GetChild(i);
                if (i < rewardList.Count)
                {
                    child.GetRawImage("Image").texture = ResourceManager.Load <Texture>(rewardList[i].IconPath, null, true);
                    child.GetText("NumText").text      = rewardList[i].Num.ToString();
                }

                if (i < rewardList.Count)
                {
                    RewardVo vo = rewardList[i];
                    PointerClickListener.Get(child.gameObject).onClick = go =>
                    {
                        FlowText.ShowMessage(ClientData.GetItemDescById(vo.Id, vo.Resource).ItemDesc);
                    };
                }
                child.gameObject.SetActive(i < rewardList.Count);
            }

            // RectTransform rect = _buyBtnText.transform.GetRectTransform();

            if (_triggerGiftVo.IsFree)
            {
                _buyBtnText.gameObject.Hide();
                _freeBtnText.gameObject.Show();
                _freeBtnText.text = I18NManager.Get("RandowEventWindow_Free");


                _originalPriceText.gameObject.Hide();
                // rect.sizeDelta = new Vector2(920, rect.sizeDelta.y);
            }
            else
            {
                ProductVo product = GlobalData.PayModel.GetProduct(_triggerGiftVo.MallId);
                _buyBtnText.text = product.AreaPrice;//product.Curreny + " " +

                _buyBtnText.gameObject.Show();
                _freeBtnText.gameObject.Hide();
                _originalPriceText.gameObject.Show();

                if (AppConfig.Instance.isChinese == "true" || product?.Curreny == Constants.CHINACURRENCY)
                {
                    _originalPriceText.text = I18NManager.Get("RandowEventWindow_OriginalPrice") +
                                              _triggerGiftVo.Rule.OriginalPrice + "元";
                }
                else
                {
                    _originalPriceText.text = I18NManager.Get("RandowEventWindow_OriginalPrice") + product.Curreny + " " +
                                              product.GetOriginalPrice(_triggerGiftVo.Rule.OriginalPrice);
                }


                // rect.sizeDelta = new Vector2(920-100, rect.sizeDelta.y);
            }

            ClientTimer.Instance.RemoveCountDown(_countName);

            _timeText.text = I18NManager.Get("RandowEventWindow_Time",
                                             DateUtil.GetTimeFormat4(_triggerGiftVo.MaturityTime -
                                                                     ClientTimer.Instance.GetCurrentTimeStamp()))
                             + I18NManager.Get("RandowEventWindow_Later");

            ClientTimer.Instance.AddCountDown(_countName, long.MaxValue, 1, tick =>
            {
                if (_triggerGiftVo.MaturityTime - ClientTimer.Instance.GetCurrentTimeStamp() <= 0)
                {
                    Close();
                    GlobalData.RandomEventModel.Delete(new RepeatedField <long>()
                    {
                        _triggerGiftVo.Id
                    });
                    RandomEventManager.ShowGiftWindow(_currentIndex);
                    return;
                }

                _timeText.text =
                    I18NManager.Get("RandowEventWindow_Time",
                                    DateUtil.GetTimeFormat4(
                                        _triggerGiftVo.MaturityTime - ClientTimer.Instance.GetCurrentTimeStamp())) +
                    I18NManager.Get("RandowEventWindow_Later");
            }, null);

            _leftBtn.gameObject.SetActive(_list.Count > 1);
            _rightBtn.gameObject.SetActive(_list.Count > 1);
        }