ArenaFightRecordView.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. this.viewCom.Center();
  26. this.modal = true;
  27. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  28. // _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("gzs_bjbj");
  29. _ui.m_list.itemRenderer = RenderListItem;
  30. }
  31. protected override void AddEventListener()
  32. {
  33. base.AddEventListener();
  34. }
  35. protected override void OnShown()
  36. {
  37. base.OnShown();
  38. _ui.m_list.numItems = ArenaDataManager.Instance.HistoryDatas.Count;
  39. }
  40. protected override void OnHide()
  41. {
  42. base.OnHide();
  43. }
  44. protected override void RemoveEventListener()
  45. {
  46. base.RemoveEventListener();
  47. }
  48. private void RenderListItem(int index, GObject obj)
  49. {
  50. ArenaHistoryData historyData = ArenaDataManager.Instance.HistoryDatas[index];
  51. UI_ListFightRecordItem item = UI_ListFightRecordItem.Proxy(obj);
  52. item.m_c1.selectedIndex = 0;
  53. item.m_ctrResult.selectedIndex = historyData.isWin ? 1 : 0;
  54. item.m_ctrDan.selectedIndex = historyData.GradeChangeType;
  55. item.m_txtTargetName.text = historyData.targetData.RoleInfo.roleName;
  56. item.m_txtRank.text = historyData.targetData.RankInGrade.ToString();
  57. item.m_txtTargetFightScore.text = string.Format("竞技场战力:{0}", ArenaDataManager.Instance.GetAllFightScore(historyData.targetData.FightScores));
  58. ArenaViewManager.Instance.UpdateDanIcon(item.m_loaDanIcon, historyData.targetData.Grade);
  59. TimeUtil.FormattingTime(historyData.FightTime, TimeHelper.ServerNow(), out int num, out string str);
  60. str = str == "秒" ? "刚刚" : num + str + "前";
  61. item.m_txtTime.text = string.Format("{0} {1}", str, historyData.IsChallenge ? "发起挑战" : "接收挑战");
  62. item.m_btnShow.data = historyData;
  63. if (item.m_btnLook.data == null)
  64. {
  65. item.m_btnLook.onClick.Add(OnBtnLookClick);
  66. }
  67. item.m_btnLook.data = historyData;
  68. if (item.m_listResult.data == null)
  69. {
  70. item.m_listResult.itemRenderer = RenderListResultItem;
  71. }
  72. item.m_listResult.data = historyData;
  73. item.m_listResult.numItems = 3;
  74. ArenaViewManager.Instance.UpdateAllScore(item.m_comResult.target, historyData.MyScores, historyData.TargetScores);
  75. UI_ListFightRecordItem.ProxyEnd();
  76. }
  77. private void RenderListResultItem(int index, GObject obj)
  78. {
  79. ArenaHistoryData historyData = obj.parent.data as ArenaHistoryData;
  80. ArenaViewManager.Instance.UpdateFightRoundResult(obj, index, historyData.MyScores, historyData.TargetScores, historyData.targetData, out bool isWin);
  81. }
  82. private void OnBtnLookClick(EventContext context)
  83. {
  84. ArenaHistoryData historyData = (context.sender as GObject).data as ArenaHistoryData;
  85. ArenaTargetData targetData = historyData.targetData;
  86. if (targetData.Type == FightTargetType.ROBOT)
  87. {
  88. PromptController.Instance.ShowFloatTextPrompt("玩家不在线");
  89. return;
  90. }
  91. ViewManager.Show<ArenaDressInfoView>(new object[] { FightRoleType.TAEGET, 0, targetData.FightDatas }, new object[] { typeof(ArenaFightRecordView).FullName, null }, true);
  92. }
  93. }
  94. }