SUIPreparePanel.lua.txt 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. local SUIPreparePanel = {}
  2. local CountDownFunc
  3. -- 手部跟随
  4. local function LoadJoinFollow()
  5. print("----> SUIAlignPanel.LoadJoinFollow")
  6. local jointFollow = SUIPreparePanel._rootCanvas.transform:Find("ZWNJointFollowHand")
  7. if jointFollow then
  8. return
  9. end
  10. local prefabJointFollowHand = LoadResource("Prefabs/ZWN/ZWNJointFollowHand.prefab")
  11. local jointFollowHand = CS.UnityEngine.GameObject.Instantiate(prefabJointFollowHand, SUIPreparePanel._rootCanvas.transform)
  12. jointFollowHand.name = "ZWNJointFollowHand"
  13. local jointFollow = jointFollowHand:GetComponent("JointFollow")
  14. jointFollow:init_follow()
  15. end
  16. local function StartCountDown()
  17. print("----> SUIPreparePanel.StartCountDown")
  18. CountDownFunc = require("Base/CoroutineHelper.lua"):Start(function ()
  19. local configLinkGame = require("Config/SConfigManager.lua"):GetConfig("configLinkGame")
  20. local nGamePrepareTime = configLinkGame.gamePrepareTime
  21. for nIndex = 1, nGamePrepareTime, 1 do
  22. require("Base/CoroutineHelper.lua"):Wait(1)
  23. local uiHelper = require("Base/UIHelper.lua")
  24. local sMusicManager = require("Base/SMusicManager.lua")
  25. local rootPanel = SUIPreparePanel.rootPanel
  26. local panelTips = rootPanel.transform:Find("Panel_Tips").gameObject
  27. local textCDTime = rootPanel.transform:Find("Text_CD_Time").gameObject
  28. local nRemainTime = nGamePrepareTime - nIndex
  29. local nMinCountDownTime = 3
  30. if nRemainTime <= nMinCountDownTime and nRemainTime ~= 0 then
  31. if nRemainTime == nMinCountDownTime then
  32. panelTips:SetActive(false)
  33. textCDTime:SetActive(true)
  34. sMusicManager:PlaySound("Audios/Prepare/startGame.mp3")
  35. end
  36. uiHelper:SetTextInfo(rootPanel, "Text_CD_Time", nRemainTime)
  37. end
  38. if nRemainTime == 0 then
  39. uiHelper:SetTextInfo(rootPanel, "Text_CD_Time", "开始")
  40. require("Base/CoroutineHelper.lua"):Wait(1)
  41. local SUIGamingPanel = require("UI/SUIGamingPanel.lua")
  42. SUIGamingPanel.SetRootPanelActive(true)
  43. SUIPreparePanel.SetRootPanelActive(false)
  44. -- require("Base/UIHelper.lua"):SwitchUI("UI/SUIGamingPanel.lua", "UI/SUIPreparePanel.lua")
  45. end
  46. end
  47. end)
  48. end
  49. local function PlayTipsSound()
  50. print("SUIPreparePanel.PlayTipsSound")
  51. local sGameTipsSoundPath = "Audios/Prepare/gameTips.mp3"
  52. require("Base/SMusicManager.lua"):PlaySound(sGameTipsSoundPath)
  53. end
  54. local function RefreshUI()
  55. LoadJoinFollow()
  56. StartCountDown()
  57. PlayTipsSound()
  58. end
  59. local function RegisterTouchEvent()
  60. local uiHelper = require("Base/UIHelper.lua")
  61. local rootPanel = SUIPreparePanel.rootPanel
  62. local buttonQuit = rootPanel.transform:Find("Panel_Quit").gameObject
  63. uiHelper:RegisterButtonQuit(buttonQuit, false, "UI/SUITeachPanel.lua", "UI/SUIPreparePanel.lua")
  64. end
  65. local function StopCountDownFun()
  66. if CountDownFunc then
  67. require("Base/CoroutineHelper.lua"):Stop(CountDownFunc)
  68. end
  69. end
  70. local function UnInitUI()
  71. local rootPanel = SUIPreparePanel.rootPanel
  72. local panelTips = rootPanel.transform:Find("Panel_Tips").gameObject
  73. local textCDTime = rootPanel.transform:Find("Text_CD_Time").gameObject
  74. panelTips:SetActive(true)
  75. textCDTime:SetActive(false)
  76. end
  77. local function InitAllData()
  78. RefreshUI()
  79. end
  80. local function UnInitAllData()
  81. require("Base/SMusicManager.lua"):StopSound("Audios/Prepare/gameTips.mp3")
  82. require("Base/SMusicManager.lua"):StopSound("Audios/Prepare/startGame.mp3")
  83. StopCountDownFun()
  84. UnInitUI()
  85. end
  86. function SUIPreparePanel.SetRootPanelActive(bShow)
  87. SUIPreparePanel.rootPanel:SetActive(bShow)
  88. if bShow then
  89. InitAllData()
  90. return
  91. end
  92. UnInitAllData()
  93. end
  94. function SUIPreparePanel.Awake(luaRoot)
  95. SUIPreparePanel.luaRoot = luaRoot
  96. local canvas = CS.UnityEngine.GameObject.Find("Canvas")
  97. SUIPreparePanel._rootCanvas = canvas
  98. local prefabPanelPrepare = LoadResource("Prefabs/UI/SUIPreparePanel.prefab")
  99. local rootPanel = CS.UnityEngine.GameObject.Instantiate(prefabPanelPrepare, SUIPreparePanel._rootCanvas.transform)
  100. SUIPreparePanel.rootPanel = rootPanel
  101. end
  102. function SUIPreparePanel.Start()
  103. print("SUIPreparePanel.Start")
  104. RegisterTouchEvent()
  105. end
  106. function SUIPreparePanel.OnDestroy()
  107. CS.UnityEngine.GameObject.Destroy(SUIPreparePanel.rootPanel)
  108. print("SUIPreparePanel.OnDestroy")
  109. end
  110. return SUIPreparePanel