/WonderGiftDlg.cs

https://bitbucket.org/MyongJu/decompile · C# · 128 lines · 110 code · 13 blank · 5 comment · 8 complexity · 609a741cf84a93d7dfdaf4ca838e8f1e MD5 · raw file

  1. // Decompiled with JetBrains decompiler
  2. // Type: WonderGiftDlg
  3. // Assembly: Assembly-CSharp, Version=4.12.6598.34475, Culture=neutral, PublicKeyToken=null
  4. // MVID: 117C5EA5-1942-44C4-A271-22ED43202EF1
  5. // Assembly location: D:\Work\apk_reversing\assets\bin\Data\Managed\Assembly-CSharp.dll
  6. using DB;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using UI;
  10. using UnityEngine;
  11. public class WonderGiftDlg : UI.Dialog
  12. {
  13. protected List<WonderGiftItem> m_allWonderGiftItem = new List<WonderGiftItem>();
  14. [SerializeField]
  15. protected WonderGiftItem m_template;
  16. [SerializeField]
  17. protected UIGrid m_container;
  18. [SerializeField]
  19. protected UIScrollView m_scrollView;
  20. protected Hashtable m_sendCounter;
  21. protected long m_receiverId;
  22. protected int getSendGiftCount(int giftInternalId)
  23. {
  24. if (this.m_sendCounter == null)
  25. return 0;
  26. int outData = 0;
  27. DatabaseTools.UpdateData(this.m_sendCounter, giftInternalId.ToString(), ref outData);
  28. return outData;
  29. }
  30. protected int GetPackageMultiFactor()
  31. {
  32. if (this.m_sendCounter == null)
  33. return 1;
  34. int outData = 1;
  35. DatabaseTools.UpdateData(this.m_sendCounter, "multiplier", ref outData);
  36. return outData;
  37. }
  38. public override void OnShow(UIControler.UIParameter orgParam)
  39. {
  40. base.OnShow(orgParam);
  41. WonderGiftDlg.Parameter parameter = orgParam as WonderGiftDlg.Parameter;
  42. this.m_receiverId = parameter != null ? parameter.receiverId : 0L;
  43. this.m_template.gameObject.SetActive(false);
  44. Hashtable postData = new Hashtable()
  45. {
  46. {
  47. (object) "world_id",
  48. (object) PlayerData.inst.userData.world_id
  49. }
  50. };
  51. RequestManager.inst.SendRequest("wonder:getKingGiftSentAmount", postData, new System.Action<bool, object>(this.onRequestCallBack), true);
  52. }
  53. protected void onRequestCallBack(bool result, object data)
  54. {
  55. this.m_sendCounter = data as Hashtable;
  56. this.UpdateUI();
  57. }
  58. public override void OnHide(UIControler.UIParameter orgParam)
  59. {
  60. base.OnHide(orgParam);
  61. }
  62. protected void UpdateUI()
  63. {
  64. this.UpdateGiftItemList();
  65. }
  66. protected void UpdateGiftItemList()
  67. {
  68. this.DestroyAllHistoryItem();
  69. using (List<WonderPackageInfo>.Enumerator enumerator = ConfigManager.inst.DB_WonderPackage.GetAllWonderPackageInfo().GetEnumerator())
  70. {
  71. while (enumerator.MoveNext())
  72. {
  73. WonderPackageInfo current = enumerator.Current;
  74. this.AddGiftItem().setData(current, this.getSendGiftCount(current.internalId), this.m_receiverId, this.GetPackageMultiFactor());
  75. }
  76. }
  77. this.m_container.repositionNow = true;
  78. this.m_container.Reposition();
  79. this.m_scrollView.movement = UIScrollView.Movement.Unrestricted;
  80. this.m_scrollView.ResetPosition();
  81. this.m_scrollView.currentMomentum = Vector3.zero;
  82. this.m_scrollView.movement = UIScrollView.Movement.Horizontal;
  83. }
  84. protected void DestroyAllHistoryItem()
  85. {
  86. using (List<WonderGiftItem>.Enumerator enumerator = this.m_allWonderGiftItem.GetEnumerator())
  87. {
  88. while (enumerator.MoveNext())
  89. {
  90. WonderGiftItem current = enumerator.Current;
  91. if ((bool) ((UnityEngine.Object) current))
  92. UnityEngine.Object.Destroy((UnityEngine.Object) current.gameObject);
  93. }
  94. }
  95. this.m_allWonderGiftItem.Clear();
  96. }
  97. protected WonderGiftItem AddGiftItem()
  98. {
  99. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_template.gameObject);
  100. gameObject.transform.SetParent(this.m_container.transform);
  101. gameObject.transform.localScale = Vector3.one;
  102. gameObject.SetActive(true);
  103. WonderGiftItem component = gameObject.GetComponent<WonderGiftItem>();
  104. this.m_allWonderGiftItem.Add(component);
  105. return component;
  106. }
  107. public void OnButtonGiftLogClicked()
  108. {
  109. UIManager.inst.OpenPopup("Wonder/WonderGiftHistoryPopup", (Popup.PopupParameter) null);
  110. }
  111. public class Parameter : UI.Dialog.DialogParameter
  112. {
  113. public long receiverId;
  114. }
  115. }