LuckyBoxCardView.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using System.Collections;
  2. using UnityEngine;
  3. using UI.LuckyBox;
  4. using System.Collections.Generic;
  5. namespace GFGGame
  6. {
  7. public class LuckyBoxCardView : BaseWindow
  8. {
  9. private UI_LuckyBoxCardUI _ui;
  10. private List<ItemData> _rewardList;
  11. private int _type = 0;//弹窗类型:0可跳过,1:首次获得物品不可跳过,2首次获得物品不可跳过,不弹获得套装界面
  12. public override void Dispose()
  13. {
  14. base.Dispose();
  15. }
  16. protected override void OnInit()
  17. {
  18. base.OnInit();
  19. packageName = UI_LuckyBoxUI.PACKAGE_NAME;
  20. _ui = UI_LuckyBoxCardUI.Create();
  21. this.viewCom = _ui.target;
  22. isfullScreen = true;
  23. this.modal = true;
  24. _ui.m_bg.onTouchBegin.Add(OnClickBg);
  25. _ui.m_btnPass.onClick.Add(OnClickBtnPass);
  26. }
  27. protected override void OnShown()
  28. {
  29. base.OnShown();
  30. _rewardList = new List<ItemData>(((this.viewData as object[])[0] as List<ItemData>));
  31. _type = (int)(this.viewData as object[])[1];
  32. _ui.m_btnPass.visible = _type == (int)FirstGetCardViewType.JUMP ? true : false;
  33. UpdateView();
  34. }
  35. private void UpdateView()
  36. {
  37. if (_rewardList.Count - 1 < 0) return;
  38. ItemData itemdata = _rewardList[_rewardList.Count - 1];
  39. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemdata.id);
  40. _ui.m_comCard.m_loaType.url = ResPathUtil.GetCommonGameResPath("hd_sxicon_" + itemCfg.rarity);
  41. _ui.m_comCard.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
  42. int mainScore = 0;
  43. int mainScoreValue = 0;
  44. ItemDataManager.GetMainScore(itemdata.id, out mainScore, out mainScoreValue);
  45. _ui.m_comCard.m_loaProperty.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + mainScore);
  46. _ui.m_comCard.m_txtName.text = itemCfg.name;
  47. _ui.m_comCard.m_txtDiscribe.text = itemCfg.desc;
  48. if (LuckyBoxDataManager.Instance.FirstRewardList.ContainsKey(_rewardList.Count - 1) == true)
  49. {
  50. LuckyBoxDataManager.Instance.FirstRewardList.Remove(_rewardList.Count - 1);
  51. }
  52. _rewardList.RemoveAt(_rewardList.Count - 1);
  53. }
  54. private void OnClickBg()
  55. {
  56. if (_rewardList.Count == 0)
  57. {
  58. if (_type == (int)FirstGetCardViewType.JUMP)
  59. {
  60. ViewManager.Show(ViewName.LUCKY_BOX_BONUS_VIEW, new object[] { (this.viewData as object[])[0] as List<ItemData>, _rewardList });
  61. }
  62. else if (_type == (int)FirstGetCardViewType.CANNOT_JUMP)
  63. {
  64. int itemId = GetSuitItemController.TryShow(0);
  65. }
  66. this.Hide();
  67. return;
  68. }
  69. _ui.m_t_close.Play(() =>
  70. {
  71. _ui.m_t_open.Play();
  72. UpdateView();
  73. });
  74. }
  75. private void OnClickBtnPass()
  76. {
  77. ViewManager.Show(ViewName.LUCKY_BOX_BONUS_VIEW, new object[] { (this.viewData as object[])[0], _rewardList });
  78. this.Hide();
  79. }
  80. protected override void OnHide()
  81. {
  82. _ui.m_t_close.Stop(true, false);
  83. _ui.m_t_open.Stop(true, false);
  84. base.OnHide();
  85. }
  86. }
  87. }