ItemView.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. using FairyGUI;
  2. namespace GFGGame
  3. {
  4. public class ItemView
  5. {
  6. private GComponent _obj;
  7. private GLoader _loaIcon;
  8. private GLoader _loaRarity;
  9. private GTextField _txtName;
  10. private GTextField _txtCount;
  11. private GTextField _txtHasCount;
  12. // private GImage _imgGot;
  13. private GGroup _grpGot;
  14. private GImage _imgNotHas;
  15. private GImage _imgHas;
  16. private GImage _imgShouTong;
  17. // private GGroup _grpCount;
  18. private bool _showTips = true;
  19. private ItemData _itemData;
  20. public ItemView(GComponent obj)
  21. {
  22. _obj = obj;
  23. _loaIcon = obj.GetChild("loaIcon") as GLoader;
  24. _loaRarity = obj.GetChild("loaRarity") as GLoader;
  25. _txtName = obj.GetChild("txtName") as GTextField;
  26. _txtCount = obj.GetChild("txtCount") as GTextField;
  27. _txtHasCount = obj.GetChild("txtHasCount") as GTextField;
  28. // _imgGot = obj.GetChild("imgGot") as GImage;
  29. _grpGot = obj.GetChild("grpGot") as GGroup;
  30. _imgNotHas = obj.GetChild("imgNotHas") as GImage;
  31. _imgHas = obj.GetChild("imgHas") as GImage;
  32. _imgShouTong = obj.GetChild("imgShowTong") as GImage;
  33. // _grpCount = obj.GetChild("grpCount") as GGroup;
  34. // AddClickListener();
  35. _obj.onClick.Remove(AddClickListener);
  36. _obj.onClick.Add(AddClickListener);
  37. }
  38. public void Dispose()
  39. {
  40. _obj.onClick.Remove(AddClickListener);
  41. _obj.Dispose();
  42. }
  43. private void AddClickListener()
  44. {
  45. if (!ShowTips) return;
  46. GoodsItemTipsController.ShowItemTips(_itemData.id);
  47. }
  48. public void SetData(ItemData itemData)
  49. {
  50. _itemData = itemData;
  51. UpdateView();
  52. }
  53. private void UpdateView()
  54. {
  55. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemData.id);
  56. _loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  57. RarityIconController.UpdateRarityIcon(_loaRarity, _itemData.id, false);
  58. // _imgGot.visible = false;
  59. _grpGot.visible = false;
  60. _imgNotHas.visible = false;
  61. _imgHas.visible = false;
  62. _imgShouTong.visible = false;
  63. // _grpCount.visible = true;
  64. _showTips = true;
  65. _txtName.text = itemCfg.name;
  66. _txtCount.SetVar("count", _itemData.num.ToString()).FlushVars();
  67. _txtHasCount.SetVar("count", "" + ItemDataManager.GetItemNum(_itemData.id)).FlushVars();
  68. }
  69. public ItemData ItemData
  70. {
  71. get
  72. {
  73. return _itemData;
  74. }
  75. }
  76. /// <summary>
  77. /// “已领取”显示状态
  78. /// </summary>
  79. /// <value></value>
  80. public bool GrpGotVisible
  81. {
  82. get
  83. {
  84. return _grpGot.visible;
  85. }
  86. set
  87. {
  88. _grpGot.visible = value;
  89. }
  90. }
  91. /// “已获得”显示状态
  92. /// </summary>
  93. /// <value></value>
  94. public bool ImgHasVisible
  95. {
  96. get
  97. {
  98. return _imgHas.visible;
  99. }
  100. set
  101. {
  102. _imgHas.visible = value;
  103. }
  104. }
  105. /// <summary>
  106. /// “未获得”显示状态
  107. /// </summary>
  108. /// <value></value>
  109. public bool ImgNotGotVisible
  110. {
  111. get
  112. {
  113. return _imgNotHas.visible;
  114. }
  115. set
  116. {
  117. _imgNotHas.visible = value;
  118. }
  119. }
  120. /// <summary>
  121. /// <summary>
  122. /// "首通奖励"显示状态
  123. /// </summary>
  124. /// <value></value>
  125. public bool ImgShouTongVisable
  126. {
  127. get
  128. {
  129. return _imgShouTong.visible;
  130. }
  131. set
  132. {
  133. _imgShouTong.visible = value;
  134. }
  135. }
  136. /// <summary>
  137. /// 显示拥有数量
  138. /// </summary>
  139. /// <value></value>
  140. public bool ShowHasCount
  141. {
  142. get
  143. {
  144. return _txtHasCount.visible;
  145. }
  146. set
  147. {
  148. _txtHasCount.visible = value;
  149. }
  150. }
  151. /// <summary>
  152. /// 显示名字
  153. /// </summary>
  154. /// <value></value>
  155. public bool ShowName
  156. {
  157. set
  158. {
  159. _txtName.visible = value;
  160. }
  161. }
  162. /// <summary>
  163. /// 显示稀有度
  164. /// </summary>
  165. /// <value></value>
  166. public bool ShowRarity
  167. {
  168. set
  169. {
  170. _loaRarity.visible = value;
  171. }
  172. }
  173. // /// <summary>
  174. // /// 显示数量
  175. // /// </summary>
  176. // /// <value></value>
  177. // public bool ShowCount
  178. // {
  179. // set
  180. // {
  181. // _grpCount.visible = value;
  182. // }
  183. // }
  184. /// <summary>
  185. /// 展示详情tips
  186. /// </summary>
  187. /// <value></value>
  188. public bool ShowTips
  189. {
  190. get
  191. {
  192. return _showTips;
  193. }
  194. set
  195. {
  196. _showTips = value;
  197. }
  198. }
  199. }
  200. }