2020-07-04 14:41:25 +08:00
|
|
|
|
--开始游戏
|
|
|
|
|
|
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
|
2020-07-26 13:02:00 +08:00
|
|
|
|
ReporterMessageReceiver.self.gameObject:SetActive(false)
|
2020-07-04 14:41:25 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2020-07-28 21:51:28 +08:00
|
|
|
|
DBUser.isWhiteUser(
|
|
|
|
|
|
Prefs.getUserName(),
|
|
|
|
|
|
function(iswhite)
|
|
|
|
|
|
if iswhite then
|
|
|
|
|
|
if ReporterMessageReceiver.self and ReporterMessageReceiver.self.gameObject then
|
|
|
|
|
|
ReporterMessageReceiver.self.gameObject:SetActive(true)
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2020-07-04 14:41:25 +08:00
|
|
|
|
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
|
|
|
|
|
|
--已经加载完
|
2020-07-10 13:22:24 +08:00
|
|
|
|
isLogined = true
|
2020-07-04 14:41:25 +08:00
|
|
|
|
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))
|
|
|
|
|
|
|
2020-07-10 13:22:24 +08:00
|
|
|
|
isLogined = true
|
2020-07-28 21:02:59 +08:00
|
|
|
|
CLLPStart.selectServer(
|
|
|
|
|
|
function()
|
|
|
|
|
|
NetProto.init(
|
|
|
|
|
|
function(success)
|
|
|
|
|
|
if success then
|
|
|
|
|
|
CLLPStart.showGuid()
|
|
|
|
|
|
else
|
|
|
|
|
|
CLUIUtl.showConfirm(
|
|
|
|
|
|
"与服务器失去联系",
|
|
|
|
|
|
false,
|
|
|
|
|
|
"重试",
|
|
|
|
|
|
CLLPStart.connectServer,
|
|
|
|
|
|
"退出",
|
|
|
|
|
|
function()
|
|
|
|
|
|
Application.Quit()
|
|
|
|
|
|
end
|
|
|
|
|
|
)
|
2020-07-04 14:41:25 +08:00
|
|
|
|
end
|
2020-07-28 21:02:59 +08:00
|
|
|
|
end
|
|
|
|
|
|
)
|
2020-07-04 14:41:25 +08:00
|
|
|
|
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(),
|
2020-07-28 21:51:28 +08:00
|
|
|
|
password = Prefs.getUserPsd()
|
2020-07-04 14:41:25 +08:00
|
|
|
|
},
|
|
|
|
|
|
function(content, orgs)
|
|
|
|
|
|
if content.success then
|
|
|
|
|
|
local currGroup = Prefs.getCurrGroup(Prefs.getUserName())
|
|
|
|
|
|
if isNilOrEmpty(currGroup) then
|
2020-07-14 22:04:03 +08:00
|
|
|
|
if #(content.result) == 1 then
|
|
|
|
|
|
Prefs.setCurrGroup(Prefs.getUserName(), json.encode(content.result[1]))
|
2020-07-15 20:53:37 +08:00
|
|
|
|
MyUtl.setIsHidePhone(content.result[1].cover_phoneNo_flag)
|
2020-07-14 22:04:03 +08:00
|
|
|
|
getPanelAsy("PanelConnect", onLoadedPanel)
|
|
|
|
|
|
else
|
|
|
|
|
|
---@type _ParamTRPSelectGroup
|
|
|
|
|
|
local d = {}
|
|
|
|
|
|
d.isHideCloseBtn = true
|
|
|
|
|
|
d.companyList = content.result
|
|
|
|
|
|
getPanelAsy("PanelSelectCompany", onLoadedPanel, d)
|
|
|
|
|
|
end
|
2020-07-04 14:41:25 +08:00
|
|
|
|
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
|
2020-07-15 20:53:37 +08:00
|
|
|
|
MyUtl.setIsHidePhone(currGroup.cover_phoneNo_flag)
|
2020-07-11 17:07:30 +08:00
|
|
|
|
getPanelAsy("PanelConnect", onLoadedPanel)
|
2020-07-04 14:41:25 +08:00
|
|
|
|
else
|
2020-07-14 22:04:03 +08:00
|
|
|
|
if #(content.result) == 1 then
|
|
|
|
|
|
Prefs.setCurrGroup(Prefs.getUserName(), json.encode(content.result[1]))
|
2020-07-15 20:53:37 +08:00
|
|
|
|
MyUtl.setIsHidePhone(content.result[1].cover_phoneNo_flag)
|
2020-07-14 22:04:03 +08:00
|
|
|
|
getPanelAsy("PanelConnect", onLoadedPanel)
|
|
|
|
|
|
else
|
|
|
|
|
|
---@type _ParamTRPSelectGroup
|
|
|
|
|
|
local d = {}
|
|
|
|
|
|
d.isHideCloseBtn = true
|
|
|
|
|
|
d.companyList = content.result
|
|
|
|
|
|
getPanelAsy("PanelSelectCompany", onLoadedPanel, d)
|
|
|
|
|
|
end
|
2020-07-04 14:41:25 +08:00
|
|
|
|
end
|
|
|
|
|
|
CLLPStart.hideSplash()
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
getPanelAsy("PanelLogin", onLoadedPanel)
|
|
|
|
|
|
CLLPStart.hideSplash()
|
|
|
|
|
|
end
|
|
|
|
|
|
end,
|
|
|
|
|
|
function()
|
|
|
|
|
|
getPanelAsy("PanelLogin", onLoadedPanel)
|
|
|
|
|
|
CLLPStart.hideSplash()
|
|
|
|
|
|
end
|
|
|
|
|
|
)
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2020-07-10 13:22:24 +08:00
|
|
|
|
CLLPStart.showGuid = function()
|
|
|
|
|
|
if Prefs.getShowGuid() then
|
|
|
|
|
|
getPanelAsy("PanelGuid", onLoadedPanelTT, CLLPStart.doEnterGame)
|
|
|
|
|
|
else
|
|
|
|
|
|
CLLPStart.doEnterGame()
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2020-07-28 21:02:59 +08:00
|
|
|
|
CLLPStart.selectServer = function(callback)
|
|
|
|
|
|
local userName = Prefs.getUserName()
|
|
|
|
|
|
if isNilOrEmpty(userName) then
|
|
|
|
|
|
Utl.doCallback(callback)
|
|
|
|
|
|
return
|
|
|
|
|
|
end
|
2020-07-28 21:51:28 +08:00
|
|
|
|
|
|
|
|
|
|
DBUser.isWhiteUser(
|
|
|
|
|
|
userName,
|
|
|
|
|
|
function(iswhite)
|
|
|
|
|
|
if iswhite then
|
2020-07-28 21:02:59 +08:00
|
|
|
|
getPanelAsy("PanelSelectServer", onLoadedPanelTT, {callback = callback})
|
|
|
|
|
|
else
|
|
|
|
|
|
Utl.doCallback(callback)
|
|
|
|
|
|
end
|
2020-07-28 21:51:28 +08:00
|
|
|
|
end
|
2020-07-28 21:02:59 +08:00
|
|
|
|
)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2020-07-04 14:41:25 +08:00
|
|
|
|
CLLPStart.hideSplash = function()
|
|
|
|
|
|
local p2 = CLPanelManager.getPanel("PanelSplash")
|
|
|
|
|
|
if (p2 ~= nil) then
|
|
|
|
|
|
CLPanelManager.hidePanel(p2)
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
----------------------------------------------
|
|
|
|
|
|
return CLLPStart
|