SUITeachPanel.lua.txt 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. local SUITeachPanel = {}
  2. local function OnClickButtonTeach()
  3. print("SUITeachPanel.OnClickButtonTeach")
  4. local rootPanel = SUITeachPanel.rootPanel
  5. local panelVideo = rootPanel.transform:Find("Panel_Video").gameObject
  6. local panelQuit = SUITeachPanel.rootPanel.transform:Find("Panel_Quit").gameObject
  7. panelQuit:SetActive(false)
  8. panelVideo:SetActive(true)
  9. end
  10. local function OnClickButtonGameType(nSelectGameType)
  11. print("SUITeachPanel.OnClickButtonGameType, nSelectGameType:", nSelectGameType)
  12. local dataRelay = require("Base/DataRelay.lua")
  13. dataRelay:SetCache(dataRelay.KEY_TYPE.GAME_TYPE, nSelectGameType)
  14. local SUIAlignPanel = require("UI/SUIAlignPanel.lua")
  15. SUIAlignPanel.SetRootPanelActive(true)
  16. SUITeachPanel.SetRootPanelActive(false)
  17. -- require("Base/UIHelper.lua"):SwitchUI("UI/SUIAlignPanel.lua", "UI/SUITeachPanel.lua")
  18. end
  19. local function OnClickButtonLearnOk()
  20. print("SUITeachPanel.OnClickButtonLearnOk")
  21. local rootPanel = SUITeachPanel.rootPanel
  22. local panelVideo = rootPanel.transform:Find("Panel_Video").gameObject
  23. local panelQuit = SUITeachPanel.rootPanel.transform:Find("Panel_Quit").gameObject
  24. panelQuit:SetActive(true)
  25. panelVideo:SetActive(false)
  26. end
  27. local function RegisterButtonQuit()
  28. print("SUITeachPanel.RegisterButtonQuit")
  29. local panelQuit = SUITeachPanel.rootPanel.transform:Find("Panel_Quit").gameObject
  30. require("Base/UIHelper.lua"):RegisterButtonQuit(panelQuit, true)
  31. end
  32. local function RegisterTouchEvent()
  33. local uiHelper = require("Base/UIHelper.lua")
  34. local rootPanel = SUITeachPanel.rootPanel
  35. local configLinkGame = require("Config/SConfigManager.lua"):GetConfig("configLinkGame")
  36. uiHelper:AddClickEvent(rootPanel, "Panel_Video/Button_Learn_OK", OnClickButtonLearnOk)
  37. uiHelper:AddClickEvent(rootPanel, "Button_Easy", function ()
  38. OnClickButtonGameType(configLinkGame.gameType.easy)
  39. end)
  40. uiHelper:AddClickEvent(rootPanel, "Button_Normal", function ()
  41. OnClickButtonGameType(configLinkGame.gameType.normal)
  42. end)
  43. uiHelper:AddClickEvent(rootPanel, "Button_Hard", function ()
  44. OnClickButtonGameType(configLinkGame.gameType.hard)
  45. end)
  46. uiHelper:AddClickEvent(rootPanel, "Button_Teach", OnClickButtonTeach)
  47. end
  48. function SUITeachPanel.SetRootPanelActive(bShow)
  49. SUITeachPanel.rootPanel:SetActive(bShow)
  50. end
  51. local function SetPanelForLoadResourceActive()
  52. local panelForLoadResource = SUITeachPanel._rootCanvas.transform:Find("Panel_For_Load_Resource").gameObject
  53. local actionSequence = CS.DG.Tweening.DOTween.Sequence()
  54. actionSequence:AppendInterval(1)
  55. actionSequence:AppendCallback(function ()
  56. panelForLoadResource:SetActive(false)
  57. CS.UnityEngine.GameObject.Destroy(panelForLoadResource)
  58. end)
  59. end
  60. function SUITeachPanel.Awake(luaRoot)
  61. SUITeachPanel.luaRoot = luaRoot
  62. local canvas = CS.UnityEngine.GameObject.Find("Canvas")
  63. SUITeachPanel._rootCanvas = canvas
  64. local prefabPanelTeach = LoadResource("Prefabs/UI/SUITeachPanel.prefab")
  65. local rootPanel = CS.UnityEngine.GameObject.Instantiate(prefabPanelTeach, SUITeachPanel._rootCanvas.transform)
  66. SUITeachPanel.rootPanel = rootPanel
  67. end
  68. function SUITeachPanel.Start(luaRoot)
  69. RegisterTouchEvent()
  70. RegisterButtonQuit()
  71. -- for fix endPanel first load delay
  72. SetPanelForLoadResourceActive()
  73. end
  74. function SUITeachPanel.Update()
  75. end
  76. function SUITeachPanel.OnDestroy()
  77. CS.UnityEngine.GameObject.Destroy(SUITeachPanel.rootPanel)
  78. end
  79. return SUITeachPanel