local SUIPreparePanel = {} local CountDownFunc -- 手部跟随 local function LoadJoinFollow() print("----> SUIAlignPanel.LoadJoinFollow") local jointFollow = SUIPreparePanel._rootCanvas.transform:Find("ZWNJointFollowHand") if jointFollow then return end local prefabJointFollowHand = LoadResource("Prefabs/ZWN/ZWNJointFollowHand.prefab") local jointFollowHand = CS.UnityEngine.GameObject.Instantiate(prefabJointFollowHand, SUIPreparePanel._rootCanvas.transform) jointFollowHand.name = "ZWNJointFollowHand" local jointFollow = jointFollowHand:GetComponent("JointFollow") jointFollow:init_follow() end local function StartCountDown() print("----> SUIPreparePanel.StartCountDown") CountDownFunc = require("Base/CoroutineHelper.lua"):Start(function () local configLinkGame = require("Config/SConfigManager.lua"):GetConfig("configLinkGame") local nGamePrepareTime = configLinkGame.gamePrepareTime for nIndex = 1, nGamePrepareTime, 1 do require("Base/CoroutineHelper.lua"):Wait(1) local uiHelper = require("Base/UIHelper.lua") local sMusicManager = require("Base/SMusicManager.lua") local rootPanel = SUIPreparePanel.rootPanel local panelTips = rootPanel.transform:Find("Panel_Tips").gameObject local textCDTime = rootPanel.transform:Find("Text_CD_Time").gameObject local nRemainTime = nGamePrepareTime - nIndex local nMinCountDownTime = 3 if nRemainTime <= nMinCountDownTime and nRemainTime ~= 0 then if nRemainTime == nMinCountDownTime then panelTips:SetActive(false) textCDTime:SetActive(true) sMusicManager:PlaySound("Audios/Prepare/startGame.mp3") end uiHelper:SetTextInfo(rootPanel, "Text_CD_Time", nRemainTime) end if nRemainTime == 0 then uiHelper:SetTextInfo(rootPanel, "Text_CD_Time", "开始") require("Base/CoroutineHelper.lua"):Wait(1) local SUIGamingPanel = require("UI/SUIGamingPanel.lua") SUIGamingPanel.SetRootPanelActive(true) SUIPreparePanel.SetRootPanelActive(false) -- require("Base/UIHelper.lua"):SwitchUI("UI/SUIGamingPanel.lua", "UI/SUIPreparePanel.lua") end end end) end local function PlayTipsSound() print("SUIPreparePanel.PlayTipsSound") local sGameTipsSoundPath = "Audios/Prepare/gameTips.mp3" require("Base/SMusicManager.lua"):PlaySound(sGameTipsSoundPath) end local function RefreshUI() LoadJoinFollow() StartCountDown() PlayTipsSound() end local function RegisterTouchEvent() local uiHelper = require("Base/UIHelper.lua") local rootPanel = SUIPreparePanel.rootPanel local buttonQuit = rootPanel.transform:Find("Panel_Quit").gameObject uiHelper:RegisterButtonQuit(buttonQuit, false, "UI/SUITeachPanel.lua", "UI/SUIPreparePanel.lua") end local function StopCountDownFun() if CountDownFunc then require("Base/CoroutineHelper.lua"):Stop(CountDownFunc) end end local function UnInitUI() local rootPanel = SUIPreparePanel.rootPanel local panelTips = rootPanel.transform:Find("Panel_Tips").gameObject local textCDTime = rootPanel.transform:Find("Text_CD_Time").gameObject panelTips:SetActive(true) textCDTime:SetActive(false) end local function InitAllData() RefreshUI() end local function UnInitAllData() require("Base/SMusicManager.lua"):StopSound("Audios/Prepare/gameTips.mp3") require("Base/SMusicManager.lua"):StopSound("Audios/Prepare/startGame.mp3") StopCountDownFun() UnInitUI() end function SUIPreparePanel.SetRootPanelActive(bShow) SUIPreparePanel.rootPanel:SetActive(bShow) if bShow then InitAllData() return end UnInitAllData() end function SUIPreparePanel.Awake(luaRoot) SUIPreparePanel.luaRoot = luaRoot local canvas = CS.UnityEngine.GameObject.Find("Canvas") SUIPreparePanel._rootCanvas = canvas local prefabPanelPrepare = LoadResource("Prefabs/UI/SUIPreparePanel.prefab") local rootPanel = CS.UnityEngine.GameObject.Instantiate(prefabPanelPrepare, SUIPreparePanel._rootCanvas.transform) SUIPreparePanel.rootPanel = rootPanel end function SUIPreparePanel.Start() print("SUIPreparePanel.Start") RegisterTouchEvent() end function SUIPreparePanel.OnDestroy() CS.UnityEngine.GameObject.Destroy(SUIPreparePanel.rootPanel) print("SUIPreparePanel.OnDestroy") end return SUIPreparePanel