ArenaFightResultView.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. using FairyGUI;
  2. using UnityEngine;
  3. using UI.Main;
  4. using System.Collections;
  5. using System.Collections.Generic;
  6. using ET;
  7. namespace GFGGame
  8. {
  9. public class ArenaFightResultView : BaseView
  10. {
  11. private UI_ArenaFightResultUI _ui;
  12. // private StoryLevelCfg _levelCfg;
  13. // private StoryFightResultData _resultData;
  14. private List<FightRoleData> roleDatas;
  15. private List<ArenaTargetData> targetDatas;
  16. public override void Dispose()
  17. {
  18. if (_ui != null)
  19. {
  20. _ui.Dispose();
  21. }
  22. _ui = null;
  23. base.Dispose();
  24. }
  25. protected override void Init()
  26. {
  27. base.Init();
  28. _ui = UI_ArenaFightResultUI.Create();
  29. viewCom = _ui.target;
  30. isfullScreen = true;
  31. }
  32. protected override void OnInit()
  33. {
  34. base.OnInit();
  35. _ui.m_btnClose.onClick.Add(OnClickBtnClose);
  36. _ui.m_loaBg.url = ResPathUtil.GetFightBgImgPath("fightBg");
  37. }
  38. protected override void OnShown()
  39. {
  40. base.OnShown();
  41. Debug.Log("CurFightIndex:" + ArenaDataManager.Instance.CurFightIndex);
  42. Debug.Log("Count:" + ArenaDataManager.Instance.myScore.Count);
  43. long myScore = ArenaDataManager.Instance.myScore[ArenaDataManager.Instance.CurFightIndex];
  44. long targetScore = ArenaDataManager.Instance.targetFightScore[ArenaDataManager.Instance.CurFightIndex];
  45. bool isWin = myScore > targetScore;
  46. NTexture nTexture = new NTexture(ArenaDataManager.Instance.TextureDic[ArenaDataManager.Instance.CurFightIndex]);
  47. _ui.m_comRoleResult.m_c1.selectedIndex = isWin ? 3 : 0;
  48. _ui.m_comRoleResult.m_comRole.m_imgRole.SetSize(GRoot.inst.width, GRoot.inst.height);
  49. _ui.m_comRoleResult.m_comRole.m_imgRole.texture = nTexture;
  50. _ui.m_comRoleResult.m_comRole.m_imgRole.alpha = 1;
  51. _ui.m_comResult.m_c1.selectedIndex = isWin ? 3 : 0;
  52. _ui.m_comResult.m_txtScore.text = myScore.ToString();
  53. _ui.m_comResult.m_grpStar.visible = false;
  54. _ui.m_t0.Play();//播放重置动画
  55. _ui.m_comRoleResult.m_t0.Play();//播放重置动画
  56. _ui.m_comRoleResult.m_comRole.m_t0.Play(() =>
  57. {
  58. if (isWin)
  59. {
  60. _ui.m_comRoleResult.m_t3.Play(ShowResultView);
  61. }
  62. else
  63. {
  64. _ui.m_comRoleResult.m_t0.Play(ShowResultView);
  65. }
  66. });
  67. }
  68. private void ShowResultView()
  69. {
  70. ArenaDataManager.Instance.CurFightIndex++;
  71. _ui.m_t1.Play(() =>
  72. {
  73. ViewManager.Show<ArenaRoundResultView>();
  74. _ui.m_btnClose.enabled = true;
  75. });
  76. }
  77. protected override void OnHide()
  78. {
  79. base.OnHide();
  80. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
  81. _ui.m_comResult.target.height = 0;
  82. _ui.m_t1.Stop(true, false);
  83. _ui.m_t0.Stop(true, false);
  84. _ui.m_comRoleResult.m_t3.Stop(true, false);
  85. _ui.m_comRoleResult.m_t0.Stop(true, false);
  86. if (ArenaDataManager.Instance.CurFightIndex > 2)
  87. {
  88. object[] goBackDatas = ViewManager.GetGoBackDatas(typeof(ArenaView).FullName);
  89. ViewManager.Show<ArenaView>(null, goBackDatas, true);
  90. }
  91. }
  92. private void OnClickBtnClose(object param)
  93. {
  94. this.Hide();
  95. }
  96. }
  97. }