Beispiel #1
0
 private void InitUI()
 {
     this.needdiamond = GameConfig.GetKeyBuyDiamond();
     object[] args = new object[] { this.KeyCount.ToString() };
     this.Text_Content.text = GameLogic.Hold.Language.GetLanguageByTID("key_buy_content", args);
     object[] objArray2 = new object[] { this.KeyCount };
     this.Text_DiamondCount.text = Utils.FormatString("x{0}", objArray2);
     object[] objArray3 = new object[] { this.KeyCount };
     this.Text_NotFreeCount.text = Utils.FormatString("x{0}", objArray3);
     object[] objArray4 = new object[] { this.adCount };
     this.Text_AdCount.text = Utils.FormatString("x{0}", objArray4);
     this.update_ad_count();
     this.mDiamondCtrl.SetCurrencyType(CurrencyType.Diamond);
     this.mDiamondCtrl.UseTextRed();
     this.mDiamondCtrl.SetValue((int)this.needdiamond);
     this.mNotFreeDiamondCtrl.SetCurrencyType(CurrencyType.Diamond);
     this.mNotFreeDiamondCtrl.UseTextRed();
     this.mNotFreeDiamondCtrl.SetValue((int)this.needdiamond);
     this.Button_Buy.onClick = delegate {
         if (LocalSave.Instance.GetDiamond() < this.needdiamond)
         {
             WindowUI.ShowShopSingle(ShopSingleProxy.SingleType.eDiamond, null);
         }
         else
         {
             SdkManager.send_event_strength("PURCHASE_CLICK", GetSource(), string.Empty, string.Empty, 0);
             CLifeTransPacket packet = new CLifeTransPacket {
                 m_nTransID  = LocalSave.Instance.SaveExtra.GetTransID(),
                 m_nType     = 2,
                 m_nMaterial = (ushort)this.needdiamond
             };
             Debugger.Log("buy key needdiamond = " + this.needdiamond);
             NetManager.SendInternal <CLifeTransPacket>(packet, SendType.eForceOnce, delegate(NetResponse response) {
                 if (response.IsSuccess)
                 {
                     LocalSave.Instance.Modify_Diamond(-this.needdiamond, true);
                     CurrencyFlyCtrl.PlayGet(CurrencyType.Key, (long)this.KeyCount, null, null, true);
                     this.Button_Close.onClick();
                     SdkManager.send_event_strength("FINISH", GetSource(), "SUCCESS", string.Empty, (int)this.needdiamond);
                 }
                 else if (response.error != null)
                 {
                     SdkManager.send_event_strength("FINISH", GetSource(), "FAIL", "DIAMOND_NOT_ENOUGH", 0);
                     CInstance <TipsUIManager> .Instance.ShowCode(response.error.m_nStatusCode, 2);
                 }
                 else
                 {
                     SdkManager.send_event_strength("FINISH", GetSource(), "FAIL", "RESPONSE_ERROR_NULL", 0);
                 }
             });
         }
     };
     this.Button_BuyNotFree.onClick = this.Button_Buy.onClick;
 }
 protected override void OnInit()
 {
     this.Button_Close.onClick  = new Action(this.CloseWindow);
     this.Button_Shadow.onClick = this.Button_Close.onClick;
     this.Button_Buy.onClick    = delegate {
         if ((LocalSave.Instance.GetDiamond() < this.needdiamond) && !this.bFree)
         {
             this.bStart    = false;
             this.second    = 5;
             this.starttime = 5f;
             this.Update();
             PurchaseManager.Instance.SetOpenSource(ShopOpenSource.EREBORN);
             WindowUI.ShowShopSingle(ShopSingleProxy.SingleType.eDiamond, new Action(this.OnDiamondShopClose));
         }
         else
         {
             this.bStart = false;
             CLifeTransPacket packet = new CLifeTransPacket {
                 m_nTransID  = LocalSave.Instance.SaveExtra.GetTransID(),
                 m_nType     = 4,
                 m_nMaterial = (ushort)this.needdiamond
             };
             NetManager.SendInternal <CLifeTransPacket>(packet, SendType.eForceOnce, delegate(NetResponse response) {
                 if (response.IsSuccess)
                 {
                     if (!this.bFree)
                     {
                         LocalSave.Instance.Modify_Diamond(-this.needdiamond, true);
                     }
                     if (LocalSave.Instance.GetRebornCount() > 0)
                     {
                         LocalSave.Instance.Modify_RebornCount(-1);
                     }
                     this.DoReborn();
                 }
                 else
                 {
                     this.bStart = true;
                     if (response.error != null)
                     {
                         CInstance <TipsUIManager> .Instance.ShowCode(response.error.m_nStatusCode, 2);
                     }
                 }
             });
         }
     };
 }