/ConstructionRequirementBtn.cs

https://bitbucket.org/MyongJu/decompile · C# · 166 lines · 147 code · 14 blank · 5 comment · 33 complexity · 72a6d7d9d863372ed1a7c3532c3e1d3a MD5 · raw file

  1. // Decompiled with JetBrains decompiler
  2. // Type: ConstructionRequirementBtn
  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 UnityEngine;
  7. public class ConstructionRequirementBtn : MonoBehaviour
  8. {
  9. public UITexture mIcon;
  10. public UILabel mRequirementLabel;
  11. public UILabel mName;
  12. public GameObject mGoodIcon;
  13. public GameObject mBadIcon;
  14. public GameObject mGetMoreBtn;
  15. public UILabel mLabel;
  16. public UITexture mBackIcon;
  17. public UILabel getMoreLabel;
  18. private ItemStaticInfo item;
  19. private ShopStaticInfo shopInfo;
  20. private double m_Amount;
  21. private double m_Needed;
  22. private string iconName;
  23. public void SetDetails(string iconName, string reqDetails, string reqName, bool bGood, bool bGetMore)
  24. {
  25. if (iconName != null && iconName != this.iconName)
  26. {
  27. for (int index = 0; index < this.mIcon.transform.childCount; ++index)
  28. {
  29. Transform child = this.mIcon.transform.GetChild(index);
  30. child.parent = (Transform) null;
  31. UnityEngine.Object.Destroy((UnityEngine.Object) child.gameObject);
  32. }
  33. this.mIcon.mainTexture = (Texture) null;
  34. if (iconName.Contains("Prefab/UI/BuildingPrefab/ui_"))
  35. {
  36. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(AssetManager.Instance.HandyLoad(iconName, (System.Type) null) as GameObject);
  37. gameObject.transform.parent = this.mIcon.transform;
  38. gameObject.transform.localPosition = Vector3.zero;
  39. int width = gameObject.GetComponent<UIWidget>().width;
  40. int height = gameObject.GetComponent<UIWidget>().height;
  41. float num = width < height ? 150f / (float) height : 150f / (float) width;
  42. gameObject.transform.localScale = new Vector3(num, num, 1f);
  43. }
  44. else
  45. BuilderFactory.Instance.HandyBuild((UIWidget) this.mIcon, iconName, (System.Action<bool>) null, true, false, string.Empty);
  46. this.iconName = iconName;
  47. }
  48. this.mRequirementLabel.text = reqDetails;
  49. if (reqName != null && (UnityEngine.Object) this.mName != (UnityEngine.Object) null)
  50. {
  51. this.mName.text = reqName;
  52. if (!bGood)
  53. {
  54. this.mRequirementLabel.color = new Color(0.9058824f, 0.07058824f, 0.0f);
  55. this.mName.color = new Color(0.9058824f, 0.07058824f, 0.0f);
  56. }
  57. else
  58. {
  59. this.mRequirementLabel.color = new Color(0.7686275f, 0.7686275f, 0.7686275f);
  60. this.mName.color = new Color(0.7686275f, 0.7686275f, 0.7686275f);
  61. }
  62. }
  63. this.mGoodIcon.SetActive(bGood);
  64. this.mBadIcon.SetActive(!bGood);
  65. this.SetGetMoreActive(false);
  66. if (!bGood && bGetMore)
  67. this.SetGetMoreActive(true);
  68. if (!bGetMore || !((UnityEngine.Object) null != (UnityEngine.Object) this.mLabel))
  69. return;
  70. this.mLabel.text = Utils.XLAT("construction_requirements_get_more");
  71. }
  72. public void SetDetails2(string iconName, string reqDetails, string reqName, bool showGood, bool showBad, bool showGetMore, string getMoreBtnContent)
  73. {
  74. if (iconName != null && iconName != this.iconName)
  75. {
  76. for (int index = 0; index < this.mIcon.transform.childCount; ++index)
  77. {
  78. Transform child = this.mIcon.transform.GetChild(index);
  79. child.parent = (Transform) null;
  80. UnityEngine.Object.Destroy((UnityEngine.Object) child.gameObject);
  81. }
  82. this.mIcon.mainTexture = (Texture) null;
  83. if (iconName.Contains("Prefab/UI/BuildingPrefab/ui_"))
  84. {
  85. GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(AssetManager.Instance.HandyLoad(iconName, (System.Type) null) as GameObject);
  86. gameObject.transform.parent = this.mIcon.transform;
  87. gameObject.transform.localPosition = Vector3.zero;
  88. int width = gameObject.GetComponent<UIWidget>().width;
  89. int height = gameObject.GetComponent<UIWidget>().height;
  90. float num = width < height ? 150f / (float) height : 150f / (float) width;
  91. gameObject.transform.localScale = new Vector3(num, num, 1f);
  92. }
  93. else
  94. BuilderFactory.Instance.HandyBuild((UIWidget) this.mIcon, iconName, (System.Action<bool>) null, true, false, string.Empty);
  95. this.iconName = iconName;
  96. }
  97. this.mRequirementLabel.text = reqDetails;
  98. if (reqName != null && (UnityEngine.Object) this.mName != (UnityEngine.Object) null)
  99. this.mName.text = reqName;
  100. this.mGoodIcon.SetActive(showGood);
  101. this.mBadIcon.SetActive(showBad);
  102. this.SetGetMoreActive(showGetMore);
  103. if (!showGetMore || !((UnityEngine.Object) this.mLabel != (UnityEngine.Object) null))
  104. return;
  105. this.mLabel.text = getMoreBtnContent;
  106. }
  107. public void SetGetMoreActive(bool bActive)
  108. {
  109. if (!((UnityEngine.Object) this.mGetMoreBtn != (UnityEngine.Object) null))
  110. return;
  111. this.mGetMoreBtn.SetActive(bActive);
  112. }
  113. public void SetShopInfo(ShopStaticInfo shopInfo)
  114. {
  115. this.shopInfo = shopInfo;
  116. }
  117. public void SetItemInfo(ItemStaticInfo itemInfo)
  118. {
  119. this.item = itemInfo;
  120. }
  121. public ShopStaticInfo GetShopInfo()
  122. {
  123. return this.shopInfo;
  124. }
  125. public ItemStaticInfo GetItemInfo()
  126. {
  127. return this.item;
  128. }
  129. public void SetRequirement(double amount, double needed)
  130. {
  131. this.m_Amount = amount;
  132. this.m_Needed = needed;
  133. }
  134. public double GetAmount()
  135. {
  136. return this.m_Amount;
  137. }
  138. public double GetNeeded()
  139. {
  140. return this.m_Needed;
  141. }
  142. public void SetLabel(string text)
  143. {
  144. this.mLabel.text = text;
  145. }
  146. public void SetBackImage(string path)
  147. {
  148. if (!((UnityEngine.Object) this.mBackIcon != (UnityEngine.Object) null))
  149. return;
  150. BuilderFactory.Instance.HandyBuild((UIWidget) this.mBackIcon, path, (System.Action<bool>) null, true, false, string.Empty);
  151. }
  152. }