ArenaFightRecordView.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using ET;
  2. using FairyGUI;
  3. using UI.Arena;
  4. using UnityEngine;
  5. namespace GFGGame
  6. {
  7. public class ArenaFightRecordView : BaseWindow
  8. {
  9. private UI_ArenaFightRecordUI _ui;
  10. public override void Dispose()
  11. {
  12. if (_ui != null)
  13. {
  14. _ui.Dispose();
  15. _ui = null;
  16. }
  17. base.Dispose();
  18. }
  19. protected override void OnInit()
  20. {
  21. base.OnInit();
  22. packageName = UI_ArenaUI.PACKAGE_NAME;
  23. _ui = UI_ArenaFightRecordUI.Create();
  24. this.viewCom = _ui.target;
  25. isfullScreen = true;
  26. // _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");
  27. _ui.m_list.itemRenderer = RenderListItem;
  28. }
  29. protected override void AddEventListener()
  30. {
  31. base.AddEventListener();
  32. }
  33. protected override void OnShown()
  34. {
  35. base.OnShown();
  36. _ui.m_list.numItems = ArenaDataManager.Instance.HistoryDatas.Count;
  37. }
  38. protected override void OnHide()
  39. {
  40. base.OnHide();
  41. if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0);
  42. }
  43. protected override void RemoveEventListener()
  44. {
  45. base.RemoveEventListener();
  46. }
  47. private void RenderListItem(int index, GObject obj)
  48. {
  49. ArenaHistoryData historyData = ArenaDataManager.Instance.HistoryDatas[index];
  50. UI_ListFightRecordItem item = UI_ListFightRecordItem.Proxy(obj);
  51. item.m_c1.selectedIndex = 0;
  52. item.m_ctrResult.selectedIndex = historyData.isWin ? 1 : 0;
  53. item.m_ctrDan.selectedIndex = historyData.GradeChangeType;
  54. item.m_txtRank.text = historyData.targetData.RankInGrade.ToString();
  55. item.m_txtTargetFightScore.text = string.Format("竞技场战力:{0}", ArenaDataManager.Instance.GetAllFightScore(historyData.targetData.Type, historyData.targetData.RoleDressupList, historyData.targetData.RobotDressupList));
  56. ArenaViewManager.Instance.UpdateDanIcon(item.m_loaDanIcon, historyData.targetData.Grade);
  57. TimeUtil.FormattingTime(historyData.FightTime, TimeHelper.ServerNow(), out int num, out string str);
  58. str = num < 60 ? "刚刚" : str + "前";
  59. item.m_txtTime.text = string.Format("{0} {1}", str, historyData.IsChallenge ? "发起挑战" : "接收挑战");
  60. item.m_btnShow.data = historyData;
  61. if (item.m_btnLook.data == null)
  62. {
  63. item.m_btnLook.onClick.Add(OnBtnLookClick);
  64. }
  65. item.m_btnLook.data = historyData;
  66. if (item.m_listResult.data == null)
  67. {
  68. item.m_listResult.itemRenderer = RenderListResultItem;
  69. }
  70. item.m_listResult.data = historyData;
  71. item.m_listResult.numItems = 3;
  72. ArenaViewManager.Instance.UpdateAllScore(item.m_comResult.target, historyData.MyScores, historyData.TargetScores);
  73. UI_ListFightRecordItem.ProxyEnd();
  74. }
  75. private void RenderListResultItem(int index, GObject obj)
  76. {
  77. ArenaHistoryData historyData = obj.parent.data as ArenaHistoryData;
  78. ArenaViewManager.Instance.UpdateFightRoundResult(obj, index, historyData.MyScores, historyData.TargetScores, historyData.targetData, out bool isWin);
  79. }
  80. private void OnBtnLookClick(EventContext context)
  81. {
  82. ArenaHistoryData historyData = (context.sender as GObject).data as ArenaHistoryData;
  83. }
  84. }
  85. }