ArenaFightResultView.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. int myScore = (int)(this.viewData as object[])[0];
  42. int targetScore = (int)(this.viewData as object[])[0];
  43. ArenaDataManager.Instance.myScore.Add(myScore);
  44. ArenaDataManager.Instance.targetFightScore.Add(targetScore);
  45. _ui.m_btnClose.enabled = false;
  46. bool isWin = myScore > targetScore;
  47. NTexture nTexture = new NTexture(FightDataManager.Instance.RoleTextuex);
  48. _ui.m_comRoleResult.m_c1.selectedIndex = isWin ? 3 : 0;
  49. _ui.m_comRoleResult.m_comRole.m_imgRole.SetSize(GRoot.inst.width, GRoot.inst.height);
  50. _ui.m_comRoleResult.m_comRole.m_imgRole.texture = nTexture;
  51. _ui.m_comRoleResult.m_comRole.m_imgRole.alpha = 1;
  52. _ui.m_comResult.m_c1.selectedIndex = isWin ? 3 : 0;
  53. _ui.m_comResult.m_txtScore.text = myScore.ToString();
  54. _ui.m_comResult.m_grpStar.visible = false;
  55. _ui.m_t0.Play();//播放重置动画
  56. _ui.m_comRoleResult.m_t0.Play();//播放重置动画
  57. _ui.m_comRoleResult.m_comRole.m_t0.Play(() =>
  58. {
  59. if (isWin)
  60. {
  61. _ui.m_comRoleResult.m_t3.Play(ShowResultView);
  62. }
  63. else
  64. {
  65. _ui.m_comRoleResult.m_t0.Play(ShowResultView);
  66. }
  67. });
  68. }
  69. private void ShowResultView()
  70. {
  71. ViewManager.Show<ArenaResultView>();
  72. _ui.m_btnClose.enabled = true;
  73. }
  74. protected override void OnHide()
  75. {
  76. base.OnHide();
  77. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
  78. _ui.m_comResult.target.height = 0;
  79. _ui.m_t1.Stop(true, false);
  80. if (ArenaDataManager.Instance.CurFightIndex == 2)
  81. {
  82. object[] goBackDatas = ViewManager.GetGoBackDatas(typeof(ArenaView).FullName);
  83. ViewManager.Show<ArenaView>(null, goBackDatas, true);
  84. }
  85. }
  86. private void OnClickBtnClose(object param)
  87. {
  88. this.Hide();
  89. }
  90. }
  91. }