--开始游戏 local csSelf = nil local transform = nil local gameObject = nil local user local selectedServer local panelIndex = 0 -- 放在后面加载的页面 local lateLoadPanels = { "PanelMsg", "PanelMine" } local isLogined = false local CLLPStart = {} function CLLPStart.init(go) csSelf = go transform = csSelf.transform gameObject = csSelf.gameObject -- 加载一些必要的lua local succee, msg = pcall(CLLPStart.setLuasAtBegainning) if not succee then printe(msg) end end -- 加载一些必要的lua function CLLPStart.setLuasAtBegainning() require("public.CLLInclude") require "db.DBRoot" -- require "net.NetProto" -- 取得数据配置 require("cfg.DBCfg") require "toolkit.MyUtl" -- 资源释放时间 if CLAssetsManager.self then CLAssetsManager.self.timeOutSec4Realse = 10 end -- 日志监听 if ReporterMessageReceiver.self and ReporterMessageReceiver.self.gameObject then -- if KKWhiteList.isWhiteName() then ReporterMessageReceiver.self.gameObject:SetActive(false) -- else -- ReporterMessageReceiver.self.gameObject:SetActive(false) -- end end MyUtl.init(csSelf) CLPanelManager.self.mainPanelName = "PanelMain" -- 初始化百度定位 -- MyLocation.self:checkUserPermission() MyLocation.self:init(MyLocation.CoorType.BD09ll) -- 设置键盘模式 -- //SOFT_INPUT_ADJUST_NOTHING -- //SOFT_INPUT_ADJUST_PAN -- //SOFT_INPUT_ADJUST_RESIZE CLUIFormUtl.setSoftInputMode("SOFT_INPUT_ADJUST_PAN") Screen.sleepTimeout = CS.UnityEngine.SleepTimeout.SystemSetting -- 添加屏蔽字 --MyMain.self:invoke4Lua(CLLPStart.addShieldWords, 1) --//TODO:other lua scripts -- require("public.IDLCameraMgr") -- IDLCameraMgr.init() -- 释放ui资源的时间(秒) -- UIAtlas.releaseSpriteTime = 30 -- 设置是否可以成多点触控 -- CLCfgBase.self.uiCamera:GetComponent("UICamera").allowMultiTouch = false -- if (SystemInfo.systemMemorySize < 2048) then -- CLCfgBase.self.isFullEffect = false -- end end function CLLPStart.setData(pars) user = pars[1] selectedServer = pars[2] end function CLLPStart.show() --CLLPStart.createPanel() end -- 刷新页面 function CLLPStart.refresh() if not isLogined then CLLPStart.createPanel() end end -- 关闭页面 function CLLPStart.hide() csSelf:cancelInvoke4Lua() end -- 创建ui function CLLPStart.createPanel() panelIndex = 0 local count = #(lateLoadPanels) if (count > 0) then for i = 1, count do local name = lateLoadPanels[i] CLPanelManager.getPanelAsy(name, CLLPStart.onLoadPanelAfter) end else isLogined = true CLLPStart.connectServer() end end function CLLPStart.onLoadPanelAfter(p) -- p:init() panelIndex = panelIndex + 1 local count = #(lateLoadPanels) if (panelIndex >= count) then --已经加载完 isLogined = true CLLPStart.connectServer() end end -- 添加屏蔽字 function CLLPStart.addShieldWords() local onGetShieldWords = function(path, content, originals) if (content ~= nil) then BlockWordsTrie.getInstanse():init(content) end end local path = joinStr(CLPathCfg.self.basePath, "/", CLPathCfg.upgradeRes, "/priority/txt/shieldWords") CLVerManager.self:getNewestRes(path, CLAssetType.text, onGetShieldWords, true, nil) end -- 连接服务器相关处理 function CLLPStart.connectServer() -- showHotWheel() -- Net.self:connect(selectedServer.host, bio2number(selectedServer.port)) isLogined = true NetProto.init( function(success) if success then CLLPStart.showGuid() else CLUIUtl.showConfirm( "与服务器失去联系", false, "重试", CLLPStart.connectServer, "退出", function() Application.Quit() end ) end end ) end -- 处理网络接口 function CLLPStart.procNetwork(cmd, succ, msg, pars) if (succ == NetSuccess) then -- 接口处理成功 end end -- 点击返回键关闭自己(页面) function CLLPStart.hideSelfOnKeyBack() return false end function CLLPStart.doEnterGame() if isNilOrEmpty(Prefs.getUserName()) or isNilOrEmpty(Prefs.getUserPsd()) then -- 说明没有取得用户信息 getPanelAsy("PanelLogin", onLoadedPanel) CLLPStart.hideSplash() else NetProto.login( { phone = Prefs.getUserName(), password = Prefs.getUserPsd() }, function(content, orgs) if content.success then local currGroup = Prefs.getCurrGroup(Prefs.getUserName()) if isNilOrEmpty(currGroup) then if #(content.result) == 1 then Prefs.setCurrGroup(Prefs.getUserName(), json.encode(content.result[1])) MyUtl.setIsHidePhone(content.result[1].cover_phoneNo_flag) getPanelAsy("PanelConnect", onLoadedPanel) else ---@type _ParamTRPSelectGroup local d = {} d.isHideCloseBtn = true d.companyList = content.result getPanelAsy("PanelSelectCompany", onLoadedPanel, d) end CLLPStart.hideSplash() else local useOldCurrGroup = false currGroup = json.decode(currGroup) for i, v in ipairs(content.result) do if v.company_id == currGroup.company_id then Prefs.setCurrGroup(Prefs.getUserName(), json.encode(v)) currGroup = v useOldCurrGroup = true break end end if useOldCurrGroup then MyUtl.setIsHidePhone(currGroup.cover_phoneNo_flag) getPanelAsy("PanelConnect", onLoadedPanel) else if #(content.result) == 1 then Prefs.setCurrGroup(Prefs.getUserName(), json.encode(content.result[1])) MyUtl.setIsHidePhone(content.result[1].cover_phoneNo_flag) getPanelAsy("PanelConnect", onLoadedPanel) else ---@type _ParamTRPSelectGroup local d = {} d.isHideCloseBtn = true d.companyList = content.result getPanelAsy("PanelSelectCompany", onLoadedPanel, d) end end CLLPStart.hideSplash() end else getPanelAsy("PanelLogin", onLoadedPanel) CLLPStart.hideSplash() end end, function() getPanelAsy("PanelLogin", onLoadedPanel) CLLPStart.hideSplash() end ) end end CLLPStart.showGuid = function() if Prefs.getShowGuid() then getPanelAsy("PanelGuid", onLoadedPanelTT, CLLPStart.doEnterGame) else CLLPStart.doEnterGame() end end CLLPStart.hideSplash = function() local p2 = CLPanelManager.getPanel("PanelSplash") if (p2 ~= nil) then CLPanelManager.hidePanel(p2) end end ---------------------------------------------- return CLLPStart