WfScreenManager.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public abstract class WfScreenManager : MonoBehaviour
  5. {
  6. public virtual void Start()
  7. {
  8. this.SettingChildrenList(this.children_dic_);
  9. GameMain.Instance.MainCamera.FadeOut(0f, false, null, true, default(Color));
  10. }
  11. public virtual void Update()
  12. {
  13. if (!this.init_)
  14. {
  15. bool flag = true;
  16. foreach (KeyValuePair<string, WfScreenChildren> keyValuePair in this.children_dic_)
  17. {
  18. if (!keyValuePair.Value.init_finishied)
  19. {
  20. flag = false;
  21. break;
  22. }
  23. }
  24. if (flag)
  25. {
  26. this.init_ = true;
  27. if (!string.IsNullOrEmpty(this.next_screen_))
  28. {
  29. string screen_name = this.next_screen_;
  30. this.next_screen_ = string.Empty;
  31. this.RunScreen(screen_name);
  32. }
  33. }
  34. }
  35. else if (!string.IsNullOrEmpty(this.next_screen_) && this.cur_call_screen_mgr.fade_status == WfScreenChildren.FadeStatus.FadeEnd)
  36. {
  37. this.cur_call_screen_mgr.Reset();
  38. string screen_name2 = this.next_screen_;
  39. this.next_screen_ = string.Empty;
  40. this.RunScreen(screen_name2);
  41. }
  42. }
  43. public virtual void CallScreen(string call_screen_name)
  44. {
  45. if (this.cur_call_screen_mgr == null)
  46. {
  47. this.next_screen_ = string.Empty;
  48. if (this.init_)
  49. {
  50. this.RunScreen(call_screen_name);
  51. }
  52. else
  53. {
  54. this.next_screen_ = call_screen_name;
  55. }
  56. }
  57. else if (this.cur_call_screen_mgr.fade_status == WfScreenChildren.FadeStatus.FadeEnd || this.cur_call_screen_mgr.fade_status == WfScreenChildren.FadeStatus.Null)
  58. {
  59. this.next_screen_ = call_screen_name;
  60. }
  61. else if (this.cur_call_screen_mgr.Finish())
  62. {
  63. this.next_screen_ = call_screen_name;
  64. }
  65. }
  66. private void RunScreen(string screen_name)
  67. {
  68. this.OnPrevRunScreen(screen_name);
  69. foreach (KeyValuePair<string, WfScreenChildren> keyValuePair in this.children_dic_)
  70. {
  71. keyValuePair.Value.root_obj.SetActive(false);
  72. }
  73. if (this.children_dic_[screen_name].Call())
  74. {
  75. this.call_screen_ = screen_name;
  76. }
  77. }
  78. protected virtual void OnPrevRunScreen(string screen_name)
  79. {
  80. }
  81. protected abstract void SettingChildrenList(Dictionary<string, WfScreenChildren> children_dic);
  82. public string cur_call_screen_name
  83. {
  84. get
  85. {
  86. return this.call_screen_;
  87. }
  88. }
  89. public WfScreenChildren cur_call_screen_mgr
  90. {
  91. get
  92. {
  93. if (this.call_screen_ == string.Empty)
  94. {
  95. return null;
  96. }
  97. return this.children_dic_[this.call_screen_];
  98. }
  99. }
  100. public Dictionary<string, WfScreenChildren> children_dic
  101. {
  102. get
  103. {
  104. return this.children_dic_;
  105. }
  106. }
  107. private Dictionary<string, WfScreenChildren> children_dic_ = new Dictionary<string, WfScreenChildren>();
  108. private bool init_;
  109. private string call_screen_ = string.Empty;
  110. private string next_screen_ = string.Empty;
  111. }