CardUpView.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using FairyGUI;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UI.Card;
  5. using UI.CommonGame;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. public class CardUpView : BaseWindow
  10. {
  11. private UI_CardUpUI _ui;
  12. private Dictionary<int, int> _scores;
  13. private string _type;
  14. private int _lastNum;
  15. private int _curNum;
  16. public override void Dispose()
  17. {
  18. if (_ui != null)
  19. {
  20. _ui.Dispose();
  21. _ui = null;
  22. }
  23. base.Dispose();
  24. }
  25. protected override void OnInit()
  26. {
  27. base.OnInit();
  28. _ui = UI_CardUpUI.Create();
  29. this.viewCom = _ui.target;
  30. this.viewCom.Center();
  31. this.modal = true;
  32. //MakeFullScreen(_ui);
  33. _ui.m_listProperty.itemRenderer = RenderListPropertyItem;
  34. }
  35. protected override void OnShown()
  36. {
  37. base.OnShown();
  38. _scores = (Dictionary<int, int>)(viewData as object[])[0];
  39. _type = (string)(viewData as object[])[1];
  40. _lastNum = (int)(viewData as object[])[2];
  41. _curNum = (int)(viewData as object[])[3];
  42. _ui.m_listProperty.numItems = _scores.Count;
  43. if (_type == "lv")
  44. {
  45. _ui.m_c1.selectedIndex = 0;
  46. _ui.m_txtLast.text = string.Format("{0}级", _lastNum);
  47. _ui.m_txtNow.text = string.Format("{0}级", _curNum);
  48. }
  49. else
  50. {
  51. _ui.m_c1.selectedIndex = 1;
  52. _ui.m_txtLast.text = string.Format("{0}星", _lastNum);
  53. _ui.m_txtNow.text = string.Format("{0}星", _curNum);
  54. }
  55. Timers.inst.AddUpdate(CheckGuide);
  56. }
  57. private void RenderListPropertyItem(int index, GObject obj)
  58. {
  59. UI_ListScoreItem listItem = UI_ListScoreItem.Proxy(obj);
  60. listItem.m_txtProperty.text = _scores[index + 1].ToString();
  61. listItem.m_loaIcon.url = ResPathUtil.GetCommonGameResPath("kp_sx_" + (index + 1));
  62. UI_ListScoreItem.ProxyEnd();
  63. }
  64. protected override void OnHide()
  65. {
  66. base.OnHide();
  67. Timers.inst.Remove(CheckGuide);
  68. }
  69. private void CheckGuide(object param)
  70. {
  71. if (GuideDataManager.IsGuideFinish(ConstGuideId.UP_CARD_LV) <= 0)
  72. // || GuideDataManager.IsGuideFinish(ConstGuideId.UP_CARD_STAR) <= 0)
  73. {
  74. UpdateToCheckGuide(null);
  75. }
  76. else
  77. {
  78. Timers.inst.Remove(CheckGuide);
  79. }
  80. }
  81. protected override void UpdateToCheckGuide(object param)
  82. {
  83. if (!ViewManager.CheckIsTopView(this.viewCom)) return;
  84. GuideController.TryGuide(null, ConstGuideId.UP_CARD_LV, 6, "升级成功啦", -1, true, 1500);
  85. }
  86. }
  87. }