2025-04-11 12:49:08 +08:00
|
|
|
local breakSocketHandle, debugXpCall = require("LuaDebugjit")("localhost", 7003)
|
|
|
|
|
local timer = Timer.New(function()
|
|
|
|
|
breakSocketHandle()
|
|
|
|
|
end, 1, -1, false)
|
2025-04-01 10:48:36 +08:00
|
|
|
timer:Start();
|
|
|
|
|
|
|
|
|
|
require "Core.init"
|
|
|
|
|
json = require 'cjson'
|
2025-04-11 12:49:08 +08:00
|
|
|
require 'FairyGUI'
|
|
|
|
|
require 'Game.ControllerManager'
|
|
|
|
|
require 'Game.ViewManager'
|
|
|
|
|
require 'Game.DataManager'
|
2025-04-01 10:48:36 +08:00
|
|
|
require "Game.ExtendManager"
|
|
|
|
|
require "Game.ExtendHotupdate"
|
|
|
|
|
require "TableData"
|
|
|
|
|
|
2025-07-04 00:27:03 +08:00
|
|
|
local EmojiLuaHelper = import("Game.View.Common.EmojiLuaHelper")
|
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
MsgParser = require("MsgParser")
|
|
|
|
|
|
|
|
|
|
Utils = Game.Utils
|
|
|
|
|
PlayerPrefs = UnityEngine.PlayerPrefs
|
|
|
|
|
RuntimePlatform = UnityEngine.RuntimePlatform
|
|
|
|
|
Application = UnityEngine.Application
|
2025-04-11 12:49:08 +08:00
|
|
|
Screen = UnityEngine.Screen
|
2025-04-01 10:48:36 +08:00
|
|
|
ResourcesManager = taurus.unity.ResourcesManager
|
2025-04-11 12:49:08 +08:00
|
|
|
-- require 'tolua.reflection'
|
|
|
|
|
-- tolua.loadassembly('Assembly-CSharp')
|
2025-04-01 10:48:36 +08:00
|
|
|
-- local BindingFlags = require 'System.Reflection.BindingFlags'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local _game_info
|
|
|
|
|
local panel = nil
|
|
|
|
|
|
|
|
|
|
|
2025-04-11 12:49:08 +08:00
|
|
|
oldGameVersion = 2 --1 原始 2 老游戏新加功能
|
2025-04-01 10:48:36 +08:00
|
|
|
|
|
|
|
|
--主入口函数。从这里开始lua逻辑
|
|
|
|
|
function Main()
|
2025-06-27 21:33:42 +08:00
|
|
|
-- EmmyluaDebug
|
|
|
|
|
|
|
|
|
|
if true then
|
|
|
|
|
local suc = pcall(function()
|
2025-06-27 21:35:45 +08:00
|
|
|
local path = Application.streamingAssetsPath .. "/../../.."
|
2025-06-27 21:33:42 +08:00
|
|
|
package.cpath = package.cpath .. ";" .. path .. "/?.dll"
|
|
|
|
|
local dbg = require("emmy_core")
|
|
|
|
|
dbg.tcpConnect('localhost', 9966)
|
|
|
|
|
end)
|
|
|
|
|
if suc then
|
|
|
|
|
print("=============================调试连接成功!===========================")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-07-04 00:27:03 +08:00
|
|
|
EmojiLuaHelper.Init()
|
|
|
|
|
|
2025-06-27 21:33:42 +08:00
|
|
|
|
2025-04-11 12:49:08 +08:00
|
|
|
--PlayerPrefs.DeleteKey('session_id')
|
2025-04-01 10:48:36 +08:00
|
|
|
Application.targetFrameRate = 60
|
2025-04-11 12:49:08 +08:00
|
|
|
FairyGUI.UIConfig.buttonSound = FairyGUI.NAudioClip(ResourcesManager.LoadObject("base/common/sound/click.mp3",
|
|
|
|
|
typeof(UnityEngine.AudioClip)))
|
2025-04-01 10:48:36 +08:00
|
|
|
FairyGUI.UIConfig.defaultFont = "FZDaBiaoSong-B06S"
|
2025-04-11 12:49:08 +08:00
|
|
|
FairyGUI.FontManager.RegisterFont(FairyGUI.DynamicFont.New("SIYUAN", "base/static/fonts/SIYUAN.TTF"), null)
|
2025-07-04 00:27:03 +08:00
|
|
|
FairyGUI.FontManager.RegisterFont(FairyGUI.DynamicFont.New("方正胖娃_GBK", "base/static/fonts/方正胖娃_GBK.ttf"), null)
|
|
|
|
|
FairyGUI.FontManager.RegisterFont(FairyGUI.DynamicFont.New("方正粗圆_GBK", "base/static/fonts/方正粗圆_GBK.ttf"), null)
|
2025-07-02 20:13:34 +08:00
|
|
|
FairyGUI.FontManager.RegisterFont(FairyGUI.DynamicFont.New("FZCuYuan-M03","base/static/fonts/FZCuYuan-M03.TTF"),null)
|
2025-07-04 00:27:03 +08:00
|
|
|
FairyGUI.FontManager.RegisterFont(FairyGUI.DynamicFont.New("AlibabaPuHuiTi-3-65-Medium","base/static/fonts/AlibabaPuHuiTi-3-65-Medium.ttf"),null)
|
2025-04-11 12:49:08 +08:00
|
|
|
--FairyGUI.FontManager.RegisterFont(FairyGUI.DynamicFont.New("HYFangLiJ","base/static/fonts/HYFangLiJ.ttf"),null)
|
|
|
|
|
_game_info = json.decode(GameApplication.Instance.GameInfo)
|
|
|
|
|
--_game_info["login_url"]="http://8.134.59.224:8101/"
|
|
|
|
|
--pt(_game_info)
|
|
|
|
|
debug_print = false --GetGameInfo("debug_print")
|
2025-04-01 10:48:36 +08:00
|
|
|
if Application.platform == RuntimePlatform.WindowsEditor then
|
|
|
|
|
debug_print = true
|
|
|
|
|
end
|
|
|
|
|
local NetManager = taurus.client.NetManager
|
|
|
|
|
NetManager.debug_print = debug_print
|
|
|
|
|
-- 网络延时8秒
|
|
|
|
|
NetManager.TIMEOUT_TIME = 10
|
2025-04-11 12:49:08 +08:00
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
UIPackage.AddPackage("base/common/ui/Common")
|
|
|
|
|
panel = UIPackage.CreateObjectFromURL("ui://Common/UIPanel")
|
|
|
|
|
GRoot.inst:AddChildAt(panel, 0)
|
|
|
|
|
panel:MakeFullScreen()
|
|
|
|
|
panel:AddRelation(GRoot.inst, RelationType.Size)
|
|
|
|
|
--web网络API版本号
|
|
|
|
|
NetManager.VERSION = GetGameInfo("net_version")
|
|
|
|
|
|
2025-04-11 12:49:08 +08:00
|
|
|
TimerManager.New()
|
2025-04-01 10:48:36 +08:00
|
|
|
-- test:DynamicInvoke("222")
|
|
|
|
|
--ExtendManager.Init()
|
|
|
|
|
ControllerManager.Init()
|
|
|
|
|
ViewManager.Init()
|
|
|
|
|
|
|
|
|
|
ControllerManager.ChangeController(LoginController)
|
|
|
|
|
ViewManager.ChangeView(ViewManager.View_Login)
|
|
|
|
|
DataManager.AppVersion = GetGameInfo("app_version")
|
|
|
|
|
|
|
|
|
|
get_gps()
|
|
|
|
|
local timer = 0
|
2025-04-11 12:49:08 +08:00
|
|
|
local DSTweenManager = ds.tween.DSTweenManager
|
2025-04-01 10:48:36 +08:00
|
|
|
UpdateBeat:Add(function()
|
|
|
|
|
local deltaTime = Time.deltaTime
|
|
|
|
|
DSTweenManager.Update(deltaTime)
|
|
|
|
|
timer = timer + deltaTime
|
|
|
|
|
if timer >= 60 then
|
|
|
|
|
timer = 0
|
|
|
|
|
local ctr = ControllerManager.GetCurrenController()
|
|
|
|
|
if DataManager.CurrenRoom and ctr.baseType == GameController then
|
|
|
|
|
ctr:GetGPS()
|
|
|
|
|
else
|
|
|
|
|
get_gps()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function GetGameInfo(key)
|
|
|
|
|
return _game_info[key]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function GetPlatform()
|
|
|
|
|
return ResourcesManager.OS_Dir
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function GetGameInfoPlatform(key)
|
2025-04-11 12:49:08 +08:00
|
|
|
local p_key = GetPlatform()
|
2025-04-01 10:48:36 +08:00
|
|
|
local _platfrom = _game_info[p_key]
|
|
|
|
|
return _platfrom[key]
|
|
|
|
|
end
|
|
|
|
|
|
2025-04-11 12:49:08 +08:00
|
|
|
function BlurView(view, enabled)
|
2025-04-01 10:48:36 +08:00
|
|
|
if enabled then
|
|
|
|
|
local bf = FairyGUI.BlurFilter()
|
|
|
|
|
bf.blurSize = 0.05
|
|
|
|
|
view.filter = bf
|
|
|
|
|
else
|
|
|
|
|
view.filter = null
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ShareScreenShotWithOption(callback, index)
|
|
|
|
|
--分享目标选择,包括分享截图到 微信/支付宝
|
|
|
|
|
local wx_win = BaseWindow.new("ui://Common/Win_WXShareWin", nil)
|
|
|
|
|
wx_win._close_destroy = true
|
|
|
|
|
wx_win._view:GetController("c1").selectedIndex = index or 3
|
|
|
|
|
local cb = function()
|
|
|
|
|
if callback then callback() end
|
|
|
|
|
end
|
|
|
|
|
wx_win._view:GetChild("btn_wx_session").onClick:Add(function()
|
|
|
|
|
wx_win:Destroy()
|
|
|
|
|
ShareScreenShot(1, callback)
|
|
|
|
|
end)
|
|
|
|
|
wx_win:Show()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ShareScreenShot(n, callback)
|
|
|
|
|
local json_data = {}
|
|
|
|
|
json_data["title"] = "湘北联赛"
|
2025-04-11 12:49:08 +08:00
|
|
|
local mediaObject = {}
|
2025-04-01 10:48:36 +08:00
|
|
|
mediaObject["path"] = Application.persistentDataPath
|
|
|
|
|
mediaObject["filename"] = "screenshot"
|
|
|
|
|
mediaObject["type"] = 1
|
|
|
|
|
json_data["mediaObject"] = mediaObject
|
|
|
|
|
json_data["description"] = "一款现实中朋友约局休闲娱乐的场所!速度约朋友一起来玩吧!"
|
|
|
|
|
json_data["scene"] = 0
|
2025-04-11 12:49:08 +08:00
|
|
|
local json_str = json.encode(json_data)
|
2025-04-01 10:48:36 +08:00
|
|
|
TakeScreenShot.Take(function()
|
2025-04-11 12:49:08 +08:00
|
|
|
-- 1微信 2支付宝
|
|
|
|
|
GameApplication.Instance:ShareLink(n or 1, json_str, nil)
|
2025-04-01 10:48:36 +08:00
|
|
|
if callback then
|
|
|
|
|
callback()
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
2025-05-16 16:33:31 +08:00
|
|
|
function shareQRCodePicture(url, secene)
|
|
|
|
|
--print(debug.traceback())
|
|
|
|
|
print(url)
|
|
|
|
|
print(secene)
|
2025-04-01 10:48:36 +08:00
|
|
|
local json_data = {}
|
|
|
|
|
json_data["title"] = "湘北联赛"
|
|
|
|
|
local mediaObject = {}
|
|
|
|
|
local filename = "qrcode" .. DataManager.SelfUser.account_id
|
2025-05-16 16:33:31 +08:00
|
|
|
print(Application.persistentDataPath)
|
2025-04-01 10:48:36 +08:00
|
|
|
mediaObject["path"] = Application.persistentDataPath
|
|
|
|
|
mediaObject["filename"] = filename
|
|
|
|
|
mediaObject["type"] = 1
|
|
|
|
|
json_data["mediaObject"] = mediaObject
|
|
|
|
|
json_data["description"] = "一款现实中朋友约局休闲娱乐的场所!速度约朋友一起来玩吧!"
|
|
|
|
|
json_data["scene"] = secene
|
2025-05-16 16:33:31 +08:00
|
|
|
print("json_data==================")
|
2025-04-01 10:48:36 +08:00
|
|
|
local json_str = json.encode(json_data)
|
2025-05-16 16:33:31 +08:00
|
|
|
pt(json_str)
|
2025-04-01 10:48:36 +08:00
|
|
|
local tex2 = QRCodePicture.GenerateQRcode(url, 250, 250)
|
2025-05-16 16:33:31 +08:00
|
|
|
local tex1 = ResourcesManager.LoadObject("base/lobby/bg/bg.png", typeof(UnityEngine.Texture2D))
|
|
|
|
|
filename = filename .. ".jpg"
|
|
|
|
|
print("text2==========")
|
|
|
|
|
print(tex2)
|
|
|
|
|
print("text1==========")
|
|
|
|
|
print(tex1)
|
|
|
|
|
print("filename==========")
|
|
|
|
|
print(filename)
|
|
|
|
|
QRCodePicture.CombanitePicture(tex1, tex2, 393, 1334 - 802 - 250, filename)
|
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
GameApplication.Instance:ShareLink(1, json_str, nil)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ShareChatRoom(room_id, share_time, round, game_name, group_id, player_list, _root_view, play_name)
|
2025-04-11 12:49:08 +08:00
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
end
|
|
|
|
|
|
2025-04-11 12:49:08 +08:00
|
|
|
function UISetController(root, controller_name, gear_display, selectedIndex)
|
2025-04-01 10:48:36 +08:00
|
|
|
local ctr = root:GetController(controller_name)
|
|
|
|
|
local gear = gear_display:GetGear(0)
|
|
|
|
|
|
|
|
|
|
gear.controller = ctr
|
|
|
|
|
gear.pages = { ctr:GetPageId(selectedIndex) }
|
|
|
|
|
gear_display:HandleControllerChanged(ctr)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local bg_url = nil
|
|
|
|
|
function LoadGameBg(url, main_view)
|
|
|
|
|
local win_mode = main_view:GetChild("win_mode")
|
|
|
|
|
win_mode:RemoveChildren(0, -1, true)
|
2025-05-16 16:33:31 +08:00
|
|
|
local tex_bg = ResourcesManager.LoadObjectByGroup(url .. ".png", typeof(UnityEngine.Texture), url)
|
2025-04-01 10:48:36 +08:00
|
|
|
local bg = GImage()
|
|
|
|
|
bg.texture = FairyGUI.NTexture(tex_bg)
|
|
|
|
|
bg.width = win_mode.width
|
|
|
|
|
bg.height = win_mode.height
|
|
|
|
|
bg:AddRelation(win_mode, RelationType.Size)
|
2025-04-11 12:49:08 +08:00
|
|
|
win_mode:AddChild(bg)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
|
|
|
|
-- 卸载资源
|
|
|
|
|
if url ~= bg_url and bg_url then
|
|
|
|
|
ResourcesManager.UnLoadGroup(bg_url)
|
|
|
|
|
end
|
|
|
|
|
bg_url = url
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function AddPanel(child)
|
|
|
|
|
child:MakeFullScreen()
|
|
|
|
|
child:AddRelation(GRoot.inst, RelationType.Size)
|
|
|
|
|
panel:AddChild(child)
|
|
|
|
|
end
|
|
|
|
|
|
2025-04-11 12:49:08 +08:00
|
|
|
function AddPanelAt(child, index)
|
2025-04-01 10:48:36 +08:00
|
|
|
child:MakeFullScreen()
|
|
|
|
|
child:AddRelation(GRoot.inst, RelationType.Size)
|
|
|
|
|
panel:AddChildAt(child, index)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function AddPanelCenter(child)
|
|
|
|
|
panel:AddChild(child)
|
|
|
|
|
child:Center(true)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--重启游戏
|
|
|
|
|
function RestartGame()
|
|
|
|
|
DSTweenManager.ClearTween()
|
|
|
|
|
panel:Dispose()
|
|
|
|
|
coroutine.stopAll()
|
|
|
|
|
BaseWindow.DestroyAll()
|
|
|
|
|
GameApplication.Instance:RestartGame()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--场景切换通知
|
|
|
|
|
function OnLevelWasLoaded(level)
|
2025-04-11 12:49:08 +08:00
|
|
|
Time.timeSinceLevelLoad = 0
|
2025-04-01 10:48:36 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--程序切到后台
|
|
|
|
|
function OnApplicationPause()
|
|
|
|
|
-- ViewUtil.CloseModalWait()
|
|
|
|
|
ViewManager.OnApplicationPause()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--程序从后台切回
|
|
|
|
|
function OnApplicationActive()
|
|
|
|
|
ViewManager.OnApplicationActive()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function pt(...)
|
2025-04-11 12:49:08 +08:00
|
|
|
if debug_print then
|
|
|
|
|
local arg = { ... }
|
|
|
|
|
local has = false
|
|
|
|
|
for _, v in pairs(arg) do
|
|
|
|
|
if v and type(v) == "table" then
|
|
|
|
|
has = true
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if not has then
|
2025-04-14 10:43:57 +08:00
|
|
|
print(...)
|
2025-04-11 12:49:08 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local content = ""
|
|
|
|
|
for _, v in pairs(arg) do
|
|
|
|
|
if v == "table" then
|
|
|
|
|
content = content .. tostring(v) .. "\n"
|
|
|
|
|
else
|
|
|
|
|
content = content .. "==>[T]:" .. LuaPrint(v, limit), debug.traceback() .. "\n"
|
|
|
|
|
end
|
2025-04-14 10:43:57 +08:00
|
|
|
print(content)
|
2025-04-11 12:49:08 +08:00
|
|
|
end
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
end
|
|
|
|
|
|
2025-04-11 12:49:08 +08:00
|
|
|
function LuaPrint(lua_table, limit, indent, step)
|
|
|
|
|
step = step or 0
|
|
|
|
|
indent = indent or 0
|
|
|
|
|
local content = ""
|
|
|
|
|
if limit ~= nil then
|
|
|
|
|
if step > limit then
|
|
|
|
|
return "..."
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if step > 10 then
|
|
|
|
|
return content .. "..."
|
|
|
|
|
end
|
|
|
|
|
if lua_table == nil then
|
|
|
|
|
return "nil"
|
|
|
|
|
end
|
|
|
|
|
if type(lua_table) == "userdata" or type(lua_table) == "lightuserdata" or type(lua_table) == "thread" then
|
|
|
|
|
return tostring(lua_table)
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
2025-04-11 12:49:08 +08:00
|
|
|
if type(lua_table) == "string" or type(lua_table) == "number" then
|
|
|
|
|
return "[No-Table]:" .. lua_table
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
2025-04-11 12:49:08 +08:00
|
|
|
for k, v in pairs(lua_table) do
|
|
|
|
|
if k ~= "_class_type" then
|
|
|
|
|
local szBuffer = ""
|
|
|
|
|
Typev = type(v)
|
|
|
|
|
if Typev == "table" then
|
|
|
|
|
szBuffer = "{"
|
|
|
|
|
end
|
|
|
|
|
local szPrefix = string.rep(" ", indent)
|
|
|
|
|
if Typev == "table" and v._fields then
|
|
|
|
|
local kk, vv = next(v._fields)
|
|
|
|
|
if type(vv) == "table" then
|
|
|
|
|
content = content .. "\n\t" .. kk.name .. "={" .. LuaPrint(vv._fields, 5, indent + 1, step + 1) ..
|
2025-04-14 10:43:57 +08:00
|
|
|
"}"
|
2025-04-11 12:49:08 +08:00
|
|
|
else
|
|
|
|
|
content = content .. "\n\t" .. kk.name .. "=" .. vv
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if type(k) == "table" then
|
|
|
|
|
if k.name then
|
|
|
|
|
if type(v) ~= "table" then
|
|
|
|
|
content = content .. "\n" .. k.name .. "=" .. v
|
|
|
|
|
else
|
|
|
|
|
content = content .. "\n" .. k.name .. " = list:"
|
|
|
|
|
local tmp = "\n"
|
|
|
|
|
for ka, va in ipairs(v) do
|
|
|
|
|
tmp = tmp .. "#" .. ka .. "_" .. tostring(va)
|
|
|
|
|
end
|
|
|
|
|
content = content .. tmp
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
elseif type(k) == "function" then
|
|
|
|
|
content = content .. "\n fun=function"
|
|
|
|
|
else
|
|
|
|
|
formatting = szPrefix .. tostring(k) .. " = " .. szBuffer
|
|
|
|
|
if Typev == "table" then
|
|
|
|
|
content = content .. "\n" .. formatting
|
|
|
|
|
content = content .. LuaPrint(v, limit, indent + 1, step + 1)
|
|
|
|
|
content = content .. "\n" .. szPrefix .. "},"
|
|
|
|
|
else
|
|
|
|
|
local szValue = ""
|
|
|
|
|
if Typev == "string" then
|
|
|
|
|
szValue = string.format("%q", v)
|
|
|
|
|
else
|
|
|
|
|
szValue = tostring(v)
|
|
|
|
|
end
|
|
|
|
|
content = content .. "\n" .. formatting .. (szValue or "nil") .. ","
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
return content
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
|
|
|
|
function printlog(...)
|
2025-05-16 16:33:31 +08:00
|
|
|
if debug_print then
|
|
|
|
|
print(...)
|
|
|
|
|
end
|
2025-04-11 12:49:08 +08:00
|
|
|
end
|