CardStarRewardView.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using FairyGUI;
  2. using System.Collections;
  3. using UI.Card;
  4. using UnityEngine;
  5. namespace GFGGame
  6. {
  7. public class CardStarRewardView : BaseWindow
  8. {
  9. private UI_CardStarRewardUI _ui;
  10. private CardData _viewData;
  11. public override void Dispose()
  12. {
  13. if (_ui != null)
  14. {
  15. _ui.Dispose();
  16. _ui = null;
  17. }
  18. base.Dispose();
  19. }
  20. protected override void OnInit()
  21. {
  22. base.OnInit();
  23. packageName = UI_CardStarRewardUI.PACKAGE_NAME;
  24. _ui = UI_CardStarRewardUI.Create();
  25. this.viewCom = _ui.target;
  26. this.viewCom.Center();
  27. this.modal = true;
  28. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  29. _ui.m_listReward.itemRenderer = RenderListStarRewardItem;
  30. }
  31. protected override void OnShown()
  32. {
  33. base.OnShown();
  34. _viewData = this.viewData as CardData;
  35. _ui.m_listReward.numItems = CardStarCfgArray.Instance.GetCfgsBycardId(_viewData.itemCfg.id).Count;
  36. }
  37. private void RenderListStarRewardItem(int index, GObject obj)
  38. {
  39. UI_ListCardStarRewardItem item = UI_ListCardStarRewardItem.Proxy(obj);
  40. CardStarCfg cardStoryCfg = CardStarCfgArray.Instance.GetCfgsBycardId(_viewData.itemCfg.id)[index];
  41. if (index == 0)
  42. {
  43. item.m_txtTitle.text = "激活词牌";
  44. }
  45. else
  46. {
  47. item.m_txtTitle.text = string.Format("词牌星级达到{0}星", NumberUtil.GetChiniseNumberText(index + 1));
  48. }
  49. RedDotController.Instance.SetComRedDot(item.m_btnGet, true);
  50. if (item.m_btnGet.data == null)
  51. {
  52. item.m_btnGet.onClick.Add(OnClickBtnGet);
  53. }
  54. item.m_btnGet.data = index;
  55. ItemData reward = ItemUtil.createItemData(cardStoryCfg.rewardsArr[0]);
  56. if (item.m_comItem.data == null)
  57. {
  58. item.m_comItem.data = new ItemView(item.m_comItem);
  59. }
  60. (item.m_comItem.data as ItemView).SetData(reward);
  61. UI_ListCardStarRewardItem.ProxyEnd();
  62. }
  63. private void OnClickBtnGet(EventContext context)
  64. {
  65. GObject obj = context.sender as GObject;
  66. int index = (int)obj.data;
  67. }
  68. protected override void OnHide()
  69. {
  70. base.OnHide();
  71. }
  72. }
  73. }