GuildLobbyMgr.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using UnityEngine;
  2. using System.Collections;
  3. using LuaInterface;
  4. using UnityEngine.SceneManagement;
  5. public class GuildLobbyMgr : Singleton<GuildLobbyMgr>
  6. {
  7. private LuaTable mLuaGuildLobbyMgr = null;
  8. private bool bLoaded = false;
  9. private bool mHasStartLoad = false;
  10. [HideInInspector]
  11. public LuaTable LuaGuildLobbyMgr
  12. {
  13. set { mLuaGuildLobbyMgr = value; }
  14. get { return mLuaGuildLobbyMgr; }
  15. }
  16. public override void Init()
  17. {
  18. base.Init();
  19. RegisterEvents();
  20. }
  21. public override void UnInit()
  22. {
  23. base.UnInit();
  24. UnregisterEvents();
  25. }
  26. public void Clear()
  27. {
  28. mHasStartLoad = false;
  29. bLoaded = false;
  30. }
  31. public void Dispose()
  32. {
  33. Clear();
  34. }
  35. private void RegisterEvents()
  36. {
  37. }
  38. private void UnregisterEvents()
  39. {
  40. }
  41. public void EnterGuildLobby()
  42. {
  43. if (mHasStartLoad) return;
  44. mHasStartLoad = true;
  45. LoadScene();
  46. }
  47. private void LoadScene()
  48. {
  49. EventMgr.AddEventListener<string>(ECoreEventType.EID_Scene_Loaded, OnSceneLoaded);
  50. EventMgr.DispatchEvent<bool>(new CoreEvent<bool>(ECoreEventType.EID_LOAD_BEGIN, true));
  51. SceneMgr.Instance.AsyncLoadMainScene("scene_prontera_02");
  52. }
  53. private void OnSceneLoaded(CoreEvent<string> sceneName)
  54. {
  55. EventMgr.RemoveEventListener<string>(ECoreEventType.EID_Scene_Loaded, OnSceneLoaded);
  56. bLoaded = true;
  57. mHasStartLoad = false;
  58. EventMgr.DispatchEvent<bool>(new CoreEvent<bool>(ECoreEventType.EID_LOAD_COMPLETE, true));
  59. }
  60. }