FunctionOpenView.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using UnityEngine;
  2. using FairyGUI;
  3. using UI.CommonGame;
  4. using System.Collections.Generic;
  5. using cfg.GfgCfg;
  6. namespace GFGGame
  7. {
  8. public class FunctionOpenView : BaseWindow
  9. {
  10. private UI_FunctionOpenUI _ui;
  11. List<string> _funList = new List<string>();
  12. private EffectUI _effectUI1;
  13. public override void Dispose()
  14. {
  15. EffectUIPool.Recycle(_effectUI1);
  16. _effectUI1 = null;
  17. if (_ui != null)
  18. {
  19. _ui.Dispose();
  20. _ui = null;
  21. }
  22. base.Dispose();
  23. }
  24. protected override void OnInit()
  25. {
  26. base.OnInit();
  27. packageName = UI_FunctionOpenUI.PACKAGE_NAME;
  28. _ui = UI_FunctionOpenUI.Create();
  29. this.viewCom = _ui.target;
  30. isfullScreen = true;
  31. this.viewCom.Center();
  32. this.modal = true;
  33. this.clickBlankToClose = false;
  34. }
  35. protected override void OnShown()
  36. {
  37. base.OnShown();
  38. List<string> funList = (viewData as object) as List<string>;
  39. AddFunDatas(funList);
  40. UpdateFunIcon();
  41. }
  42. private void AddFunDatas(List<string> itemList)
  43. {
  44. for (int i = 0; i < itemList.Count; i++)
  45. {
  46. if (_funList.IndexOf(itemList[i]) < 0)
  47. {
  48. _funList.Add(itemList[i]);
  49. }
  50. }
  51. }
  52. private void UpdateFunIcon()
  53. {
  54. if (_funList.Count == 0)
  55. {
  56. this.Hide();
  57. return;
  58. }
  59. EffectUIPool.CreateEffectUI(_ui.m_holder, "ui_xjs", "ui_xjs",
  60. onComplete: (effect) =>
  61. {
  62. if (effect != null)
  63. {
  64. _effectUI1 = effect;
  65. }
  66. });
  67. FunctionOpenCfg cfg = CommonDataManager.Tables.TblFunctionOpenCfg.GetOrDefault(_funList[0]);
  68. _ui.m_ComFunctionOpen.m_txtName.text = cfg.Name;
  69. _ui.m_ComFunctionOpen.m_logIcon.url = ResPathUtil.GetCommonGameResPath(cfg.Res);
  70. _funList.RemoveAt(0);
  71. _ui.m_t0.Play(UpdateFunIcon);
  72. }
  73. protected override void OnHide()
  74. {
  75. base.OnHide();
  76. }
  77. }
  78. }