jx_client_neibu/lua_probject/base_project/Game/View/MainView.lua

1522 lines
51 KiB
Lua
Raw Normal View History

2025-04-01 10:48:36 +08:00
local MainRightPanelView = import('.MainRightPanelView')
local PlayerInfoView = import('.PlayerInfoView')
2025-04-01 10:48:36 +08:00
local ChatView = import('.ChatView')
local DismissRoomWindow = import('.DismissRoomWindow')
local SettingView = import('.SettingView')
local PlayerDistanceView = import('.PlayerDistanceView')
local FGAssistView = import('.FGAssistView')
2025-07-17 15:02:14 +08:00
local MissileSender = import(".MissileSender")
2025-04-01 10:48:36 +08:00
2025-07-20 06:21:43 +08:00
local function GetSeat(self, uId)
for _, player in pairs(self._room.player_list) do
2025-07-16 15:07:29 +08:00
if player.self_user.account_id == uId then
2025-07-11 21:37:35 +08:00
return player.seat
end
end
end
2025-07-18 16:02:20 +08:00
local function RefalshBtnClose(self)
local btn_close = self._view:GetChild("btn_closeRoom")
local btn_close_cSytle = btn_close:GetController("cStyle")
local roomOwner = self._room.player_list[1].self_user.account_id
if roomOwner == DataManager.SelfUser.account_id then
btn_close_cSytle.selectedIndex = 0
else
btn_close_cSytle.selectedIndex = 1
end
end
2025-07-19 16:32:03 +08:00
local function GetPlayer(self, playerId)
for _, p in pairs(self._room.player_list) do
if playerId == p.self_user.account_id then
return p
end
end
return nil
end
2025-07-31 16:54:29 +08:00
local function LoadClickData()
local json_data = Utils.LoadLocalFile("clickMode")
2025-08-13 23:07:05 +08:00
if json_data == nil or json_data == "null" then
2025-07-31 16:54:29 +08:00
return "double"
end
return json.decode(json_data)
end
2025-07-18 16:02:20 +08:00
--lingmeng新全局标记
2025-04-17 18:26:14 +08:00
lingmengxin = false
2025-04-01 10:48:36 +08:00
-- MainView
MainView = {}
-- 继承 BaseView
2025-04-02 19:03:26 +08:00
setmetatable(MainView, { __index = BaseView })
2025-04-01 10:48:36 +08:00
local M = MainView
-- 语音是否禁止
local record_baned = 0
function M:init()
2025-04-02 19:03:26 +08:00
TimerManager.Clear()
2025-04-01 10:48:36 +08:00
self._gamectr = ControllerManager.GetController(GameController)
self._room = DataManager.CurrenRoom
self._allow_dissmiss = true -- 游戏开始后显示解散房间按钮
2025-04-02 19:03:26 +08:00
self._multilingual = false -- 游戏支持多语言切换
self._language = 0 -- 语言默认0,1可以设为需要的方言
self._style = 1 -- 游戏风格
self._hide_assist = false -- 是否隐藏牌友圈助手
2025-04-01 10:48:36 +08:00
self._gps_style = 1
self.dismiss_cd = 0
UIPackage.AddPackage('base/chat/ui/Chat')
self.Fix_Msg_Chat = ViewUtil.Fix_Msg_Chat -- 自动回复消息列表
2025-04-02 19:03:26 +08:00
self.Fix_Msg_Chat2 = nil -- 自动回复列表2
self._scale = true
self._full_offset = false
2025-07-16 15:07:29 +08:00
self.class = "MainView"
2025-04-01 10:48:36 +08:00
self:InitView()
2025-04-02 19:03:26 +08:00
self:SetTuoGuanState()
2025-04-01 10:48:36 +08:00
end
function M:SetTuoGuanState()
2025-04-02 19:03:26 +08:00
--printlog("初始化设置托管状态")
if ControllerManager.enterPlayerData and #ControllerManager.enterPlayerData > 0 then
--pt(ControllerManager.enterPlayerData)
for i = 1, #ControllerManager.enterPlayerData do
local p = self._player_info[self:GetPos(ControllerManager.enterPlayerData[i].seat)]
--p.seat=ControllerManager.enterPlayerData[i].seat
local t = ControllerManager.enterPlayerData[i].entrust_time
--local isShow=ControllerManager.enterPlayerData[i].entrust
--if isShow==nil then return end
if t and t > 0 then
p:IsShowTGTips(true, t)
else
end
end
ControllerManager.enterPlayerData = nil
end
2025-04-01 10:48:36 +08:00
end
function M:InitView(url, isHideIpAdds)
2025-04-11 12:49:08 +08:00
---- print("url===>>>")
---- print(url)
---- print(debug.traceback())
2025-04-01 10:48:36 +08:00
BaseView.InitView(self, url)
2025-07-31 16:54:29 +08:00
self.clickMode = LoadClickData()
2025-04-01 10:48:36 +08:00
--
--[[ 多语言切换(适用于设置界面使用Main_Majiang中SettingView2的游戏)
EXMainView
1. MainView.InitView()self._multilingual = true
2.(M:NewSettingView())
2.1NewSettingView,SettingViewtrue,SettingView.new(self._root_view, true)
2.2 settingView.onChangeLanguageCallback:Add(function(languauge) self._language = languauge end)
3.EXMainView使self._languagePlaySoundPlayChatSound
]]
if self._multilingual then
self:SetLanguage(PlayerPrefs.GetInt('Languauge' .. DataManager.CurrenRoom.game_id))
end
self._gcm_chat = self._view:GetChild('gcm_chat')
if self._gcm_chat then
2025-04-02 19:03:26 +08:00
if self._room.ban_chat2 then
2025-04-01 10:48:36 +08:00
self._gcm_chat:GetController('sdk').selectedIndex = 1
self._gcm_chat.visible = false
end
if self._room.room_config and self._room.room_config.isHidden and self._room.room_config.isHidden == 1 then
self._gcm_chat.visible = false
end
end
local _view = self._view
local _room = self._room
self._state = _view:GetController('state')
2025-04-02 19:03:26 +08:00
self._ctr_action = _view:GetController("action")
2025-04-01 10:48:36 +08:00
self:InitPlayerInfoView(isHideIpAdds)
-- 风格1是屏幕上方左右两个组件显示信息
if self._style == 1 then
-- 风格2屏幕上方一个组件显示信息所有按钮放在一个单独的下拉菜单中
local rightpanel = self._view:GetChild('right_panel')
if rightpanel then
self._rightPanelView = MainRightPanelView.new(self, rightpanel)
if self._rightPanelView then
self._rightPanelView:_ShowTime()
end
end
local roominfo_panel = _view:GetChild('roominfo_panel')
self:FillRoomConfig(roominfo_panel, _room)
local roominfo_panel1 = _view:GetChild('roominfo_panel1')
self:FillRoomConfig(roominfo_panel1, _room)
-- 显示玩家距离
2025-08-06 18:34:58 +08:00
--[[
2025-04-16 17:32:15 +08:00
-- self.btn_distance = self._view:GetChild('btn_distance')
2025-04-02 19:03:26 +08:00
--self.btn_distance.displayObject.gameObject:SetActive(false)
2025-04-01 10:48:36 +08:00
if self.btn_distance then
self.btn_distance.onClick:Add(function()
if self._room.self_player.seat == 0 then
return
end
2025-04-16 17:32:15 +08:00
-- ------lingmeng-----暂时去除gps位置判定
-- self.distance_view = PlayerDistanceView.new(false, self._gps_style, function(v)
-- self:continue_game(v)
-- end)
-- self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and
-- self._state.selectedIndex < 3 and 1 or 0
-- self.distance_view:Show()
2025-04-01 10:48:36 +08:00
end)
end
2025-08-06 18:34:58 +08:00
]]
2025-04-01 10:48:36 +08:00
local btn_rule = self._view:GetChild('btn_rule')
if btn_rule ~= nil then
btn_rule.onClick:Set(function()
if self.RuleView == nil or self.RuleView._is_destroy then
self.RuleView = RoomInfoView.new(self._room)
end
self.RuleView:Show()
end)
end
if _view:GetChild('tex_version') ~= nil then
_view:GetChild('tex_version').text = 'v' .. ExtendManager.GetGameData(_room.game_id).version
end
elseif self._style == 2 then
local com_roominfo = self._view:GetChild('com_roominfo')
com_roominfo:GetChild('tex_roomid').text = _room.room_id
local times = _room.score_times
local str_des = _room.room_config:GetGameName()
if times ~= 1 then
str_des = string.format('%s %s倍', str_des, times)
end
str_des = string.format('%s %s', str_des, _room.room_config:GetDes())
com_roominfo:GetChild('tex_detail').text = str_des
local tex_time = com_roominfo:GetChild('tex_time')
2025-04-02 19:03:26 +08:00
self._co_timer = coroutine.start(function()
2025-04-01 10:48:36 +08:00
while true do
tex_time.text = os.date('%m-%d %H:%M')
local _client = ControllerManager.GameNetClinet
if not _client then
return
end
local ping = _client:getAveragePingTime()
if not ping then
return
end
local ctr_xh = com_roominfo:GetChild('gcm_xinhao'):GetController('c1')
ping = math.floor(ping / 2)
if ping > 300 then
ping = 300
end
if ping <= 100 then
ctr_xh.selectedIndex = 0
elseif ping <= 300 then
ctr_xh.selectedIndex = 1
else
ctr_xh.selectedIndex = 2
end
coroutine.wait(10)
end
end)
end
local list = _room.player_list
for i = 1, #list do
local p = list[i]
if (p.seat ~= 0) then
local info = self._player_info[self:GetPos(p.seat)]
info._view.visible = true
info:FillData(p)
end
end
-- 语音Stard
local gcm_chat = _view:GetChild('gcm_chat')
2025-04-02 19:03:26 +08:00
--gcm_chat.displayObject.gameObject:SetActive(false)
2025-04-01 10:48:36 +08:00
if gcm_chat then
gcm_chat.visible = false
local _btn_chat = gcm_chat:GetChild('n1')
_btn_chat.onClick:Add(function()
if self.chat_view == nil then
self.chat_view = ChatView.new(self)
end
if self._room.ban_chat1 then
if self.chat_view.HideInputField then
self.chat_view:HideInputField()
end
end
self.chat_view:Show()
end)
self._ctr_voice = gcm_chat:GetController('voice')
self._btn_record = gcm_chat:GetChild('btn_record')
2025-04-02 19:03:26 +08:00
self._btn_record.displayObject.gameObject:SetActive(false)
2025-04-01 10:48:36 +08:00
self.ctr_record_ban = self._btn_record:GetController('ban')
self.ctr_record_ban.selectedIndex = record_baned
self._record_time = 0
2025-06-17 20:26:53 +08:00
self._btn_record.onTouchBegin:Set(function()
2025-04-01 10:48:36 +08:00
if record_baned == 1 then
self:__SetRecordEnable()
else
self._record_time = 0
GameApplication.Instance.StopMusic = GameApplication.Instance.StopMusic + 1
self._btn_record.onTouchEnd:Set(self.__RecordTouchEnd, self)
Voice.BeginRecord()
self._ctr_voice.selectedIndex = 1
end
2025-06-17 20:26:53 +08:00
end)
2025-04-01 10:48:36 +08:00
end
2025-06-09 16:30:22 +08:00
local chatText = _view:GetChild('btn_sendText')
if chatText then
chatText.onClick:Add(function()
2025-08-13 23:07:05 +08:00
if self._room.room_config.config.hpData.BanChat == 1 then
ViewUtil.ShowBannerOnScreenCenter("本房间禁止快捷聊天")
return
end
2025-06-09 16:30:22 +08:00
if self.chat_view == nil then
self.chat_view = ChatView.new(self)
end
2025-08-06 18:34:58 +08:00
--[[
2025-06-09 16:30:22 +08:00
if self._room.ban_chat1 then
if self.chat_view.HideInputField then
self.chat_view:HideInputField()
end
end
2025-08-06 18:34:58 +08:00
]]
2025-08-13 23:07:05 +08:00
--[[
2025-08-06 18:34:58 +08:00
local group = DataManager.groups:get(self._room.group_id)
local play = group:getPlay(self._room.play_id)
local hpData = json.decode(play.hpData)
if hpData.BanChat and hpData.BanChat == 1 then
ViewUtil.ShowTips("本房间禁止快捷聊天")
return
end
2025-08-13 23:07:05 +08:00
]]
2025-08-06 18:34:58 +08:00
2025-06-09 16:30:22 +08:00
self.chat_view:Show()
end)
end
2025-06-10 16:11:48 +08:00
self._chat_Talk = _view:GetChild('btn_sendTalk')
if self._chat_Talk then
self._ctr_voice = _view:GetController('voice')
2025-08-23 22:23:17 +08:00
self._chat_Talk.onTouchBegin:Set(function(context)
2025-08-13 23:07:05 +08:00
if self._room.room_config.config.hpData.BanChat == 1 then
ViewUtil.ShowBannerOnScreenCenter("本房间禁止快捷聊天")
return
end
2025-06-10 16:11:48 +08:00
if record_baned == 1 then
self:__SetRecordEnable()
else
self._record_time = 0
2025-08-23 22:23:17 +08:00
self._record_pos = Vector2.New(context.inputEvent.x, context.inputEvent.y)
self._record_view = _view:GetChild('comp_voice')
self._record_view_ctr = self._record_view:GetController('ctr_cancel')
2025-06-10 16:11:48 +08:00
GameApplication.Instance.StopMusic = GameApplication.Instance.StopMusic + 1
self._chat_Talk.onTouchEnd:Set(self.__RecordTouchEnd, self)
2025-08-23 22:23:17 +08:00
self._chat_Talk.onTouchMove:Set(handler(self, self.__RecordTouchMove))
2025-06-17 20:26:53 +08:00
Voice.BeginRecord()
2025-06-10 16:11:48 +08:00
self._ctr_voice.selectedIndex = 1
2025-08-23 22:23:17 +08:00
-- self.__runwait_record = nil
-- self.__runwait_record = coroutine.start(self.__WaitRecord, self)
2025-06-10 16:11:48 +08:00
end
end)
end
2025-04-01 10:48:36 +08:00
local btn_ready = _view:GetChild('btn_ready')
2025-04-27 20:22:15 +08:00
if btn_ready ~= nil then
btn_ready.onClick:Set(function()
self._gamectr:PlayerReady()
end)
end
local Btn_Ready = _view:GetChild('Btn_Ready')
if Btn_Ready ~= nil then
Btn_Ready.onClick:Set(function()
self._gamectr:PlayerReady()
end)
end
2025-04-02 19:03:26 +08:00
2025-04-07 19:37:37 +08:00
if self._room.room_config.people_num ~= 2 then
local btn_xipai = _view:GetChild('btn_xipai')
if btn_xipai then
btn_xipai.onClick:Set(function()
self._gamectr:PlayerXiPai()
end)
end
2025-04-02 19:03:26 +08:00
2025-04-07 19:37:37 +08:00
local btn_start = _view:GetChild('btn_start')
btn_start.onClick:Set(function()
self._gamectr:StartGame()
end)
end
2025-04-02 19:03:26 +08:00
2025-04-01 10:48:36 +08:00
local _btn_wxyqhy = _view:GetChild('btn_wxyqhy')
if _btn_wxyqhy then
_btn_wxyqhy.visible = false
end
self:EventInit()
self._popEvent = true
self._left_time = 0
2025-08-28 15:02:07 +08:00
print("lingmeng _left_time1", self._left_time)
2025-04-01 10:48:36 +08:00
self.dismiss_room_cd_time = 0
local btn_back_exit = _view:GetChild('btn_back_exit')
2025-04-02 19:03:26 +08:00
--btn_back_exit.displayObject.gameObject:SetActive(false)
2025-04-01 10:48:36 +08:00
if btn_back_exit ~= nil then
btn_back_exit.onClick:Set(
function()
local tip_owner = '您是否退出房间?\n(退出房间后房间将解散)'
local tip = '您是否退出房间?'
local tipStr = ''
if self._room.agent then
tipStr = '您是否退出房间?'
else
tipStr = self._room.owner_id == self._room.self_player.self_user.account_id and tip_owner or tip
end
local _curren_msg = MsgWindow.new(self._root_view, tipStr, MsgWindow.MsgMode.OkAndCancel)
_curren_msg.onOk:Add(
function()
if self._state.selectedIndex > 0 and self._state.selectedIndex < 3 then
ViewUtil.ErrorTip(nil, '房间已开始,无法退出游戏。')
else
ViewUtil.ShowModalWait(self._root_view)
self._gamectr:LevelRoom(
function(res)
ViewUtil.CloseModalWait()
if res.ReturnCode == 0 then
ViewManager.ChangeView(ViewManager.View_Lobby)
else
ViewUtil.ErrorTip(res.ReturnCode)
end
end
)
end
end
)
_curren_msg:Show()
end
)
end
2025-04-02 19:03:26 +08:00
local btn_back_lobby = _view:GetChild('btn_back_lobby')
2025-04-01 10:48:36 +08:00
if btn_back_lobby ~= nil then
2025-04-02 19:03:26 +08:00
btn_back_lobby.onClick:Set(
2025-04-01 10:48:36 +08:00
function()
local tip_owner = '您是否退出房间?\n(退出房间后房间将解散)'
2025-04-02 19:03:26 +08:00
local tip = '您是否退出房间?' -- \n (请注意,申请洗牌后退出,不会返还洗牌分)
local tipStr = ''
if self._room.agent then
tipStr = '您是否退出房间?'
else
tipStr = self._room.owner_id == self._room.self_player.self_user.account_id and tip_owner or tip
end
local _curren_msg = MsgWindow.new(self._root_view, tipStr, MsgWindow.MsgMode.OkAndCancel)
_curren_msg.onOk:Add(
function()
if self._state.selectedIndex > 0 and self._state.selectedIndex < 3 then
ViewUtil.ErrorTip(nil, '房间已开始,无法退出游戏。')
else
ViewUtil.ShowModalWait(self._root_view)
self._gamectr:LevelRoom(
function(res)
ViewUtil.CloseModalWait()
if res.ReturnCode == 0 then
ViewManager.ChangeView(ViewManager.View_Lobby)
else
ViewUtil.ErrorTip(res.ReturnCode)
end
end
)
end
end
)
_curren_msg:Show()
end
)
end
2025-04-27 20:22:15 +08:00
local btn_closeRoom = _view:GetChild('Btn_CloseRoom')
if btn_closeRoom ~= nil then
btn_closeRoom.onClick:Set(
function()
local tip_owner = '您是否退出房间?\n(退出房间后房间将解散)'
local tip = '您是否退出房间?' -- \n (请注意,申请洗牌后退出,不会返还洗牌分)
local tipStr = ''
if self._room.agent then
tipStr = '您是否退出房间?'
else
tipStr = self._room.owner_id == self._room.self_player.self_user.account_id and tip_owner or tip
end
local _curren_msg = MsgWindow.new(self._root_view, tipStr, MsgWindow.MsgMode.OkAndCancel)
_curren_msg.onOk:Add(
function()
if self._state.selectedIndex > 0 and self._state.selectedIndex < 3 then
ViewUtil.ErrorTip(nil, '房间已开始,无法退出游戏。')
else
ViewUtil.ShowModalWait(self._root_view)
self._gamectr:LevelRoom(
function(res)
ViewUtil.CloseModalWait()
if res.ReturnCode == 0 then
ViewManager.ChangeView(ViewManager.View_Lobby)
else
ViewUtil.ErrorTip(res.ReturnCode)
end
end
)
end
end
)
_curren_msg:Show()
end
)
end
2025-04-01 10:48:36 +08:00
--[[local btn_back_lobby = _view:GetChild('btn_back_lobby')
btn_back_lobby.displayObject.gameObject:SetActive(false)
if btn_back_lobby ~= nil then
btn_back_lobby.onClick:Set(
function()
if self._state.selectedIndex > 0 and self._state.selectedIndex < 3 then
ViewUtil.ErrorTip(nil, '房间已开始,无法退出游戏。')
else
self._gamectr.tmpRoomID = self._room.room_id
self._gamectr.tmpGroupID = self._room.group_id
ViewManager.ChangeView(ViewManager.View_Lobby)
end
end
)
end--]]
UpdateBeat:Add(self.OnUpdate, self)
if self._room.room_config.people_num <= 4 and self._room.room_config.people_num >= 3 and self._gamectr:CheckGPS() then
2025-04-15 17:55:51 +08:00
------lingmeng-----暂时去除gps位置判定
-- self._show_distance = true
2025-04-01 10:48:36 +08:00
end
-- 显示牌友圈助手
if self._room.group_id ~= 0 and not self._hide_assist then
2025-04-02 19:03:26 +08:00
local bShow = true
2025-04-01 10:48:36 +08:00
local l_groups = DataManager.groups
2025-04-02 19:03:26 +08:00
local group = l_groups:get(self._room.group_id)
2025-04-01 10:48:36 +08:00
if group ~= nil then
local option = group.option or 0
2025-04-02 19:03:26 +08:00
if bit:_and(option, 8) > 0 then
2025-04-01 10:48:36 +08:00
bShow = false
end
end
if bShow then
2025-06-12 15:17:53 +08:00
-- self:ShowFGAssist()
2025-04-01 10:48:36 +08:00
end
end
if self._room.self_player.entrust then
self:MarkSelfTuoguan()
end
2025-04-02 19:03:26 +08:00
--[[local gameCommonBtn = UIPackage.CreateObjectFromURL('ui://Common/gameCommonPanel')
2025-04-01 10:48:36 +08:00
if gameCommonBtn then
self._view:AddChild(gameCommonBtn)
local shuaxingameBtn=gameCommonBtn:GetChild("shuaxinbtn")
if shuaxingameBtn then
shuaxingameBtn.onClick:Set(
function ()
ViewManager.refreshGameView()
end
)
end
end--]]
-------------------------lingmeng---------------------------
2025-04-27 20:22:15 +08:00
_view:GetChild('text_roomId').text = string.format("房间:%s", self._room.room_id)
2025-06-12 15:17:53 +08:00
2025-06-13 13:33:34 +08:00
local btn_inviteFamily = self._view:GetChild('btn_inviteFamily')
if btn_inviteFamily then
2025-06-12 15:17:53 +08:00
UIPackage.AddPackage('base/newgroup/ui/FGAssist')
2025-06-13 13:33:34 +08:00
btn_inviteFamily.onClick:Set(function()
2025-06-12 15:17:53 +08:00
local panel_assist = FGAssistView.new(self._root_view, self._room.group_id, function()
print("lingmeng assistcallback")
end)
panel_assist:ReloadView()
panel_assist:Show()
end)
end
2025-06-16 15:24:27 +08:00
self._viewBtn_pangGuang = self._view:GetChild('btn_pangGuang')
self._view_WitnessPlayer = self._view:GetChild('comp_witness')
self._ctr_showWitness = self._view:GetController('witness')
if self._viewBtn_pangGuang and self._view_WitnessPlayer and self._ctr_showWitness then
self._viewBtn_pangGuang.onClick:Set(function()
self._ctr_showWitness.selectedIndex = 1
self:ShowWitnessPlayer()
end)
end
2025-07-19 16:32:03 +08:00
2025-07-18 16:02:20 +08:00
RefalshBtnClose(self)
------------------------------------------------------------
2025-04-01 10:48:36 +08:00
end
function M:continue_game(continue)
if continue then
self.distance_view:Destroy()
else
local tip_owner = '您是否退出房间?\n(退出房间后房间将解散)'
local tip = '您是否退出房间?'
local tipStr = ''
if self._room.agent then
tipStr = '您是否返回大厅?'
else
tipStr = self._room.owner_id == self._room.self_player.self_user.account_id and tip_owner or tip
end
local _curren_msg = MsgWindow.new(self._root_view, tipStr, MsgWindow.MsgMode.OkAndCancel)
_curren_msg.onOk:Add(
function()
if self._state.selectedIndex > 0 and self._state.selectedIndex < 3 then
ViewUtil.ErrorTip(nil, '房间已开始,无法退出游戏。')
else
ViewUtil.ShowModalWait(self._root_view)
self._gamectr:LevelRoom(
function(res)
ViewUtil.CloseModalWait()
if res.ReturnCode == 0 then
ViewManager.ChangeView(ViewManager.View_Lobby)
else
ViewUtil.ErrorTip(res.ReturnCode)
end
end
)
end
end
)
_curren_msg:Show()
end
end
2025-06-16 15:24:27 +08:00
--展示观战
function M:ShowWitnessPlayer()
local view_witness = self._ctr_showWitness
local player_list = view_witness:GetChild('list_players')
local witnessPlayer = self._room.witnessPlayers
player_list:SetVirtual()
player_list.itemRenderer = function(index, obj)
obj:GetChild('text_name').text = witnessPlayer[index + 1].nick
end
if witnessPlayer then
player_list.numItems = #witnessPlayer
end
end
2025-04-01 10:48:36 +08:00
-- 公用的playerinfoview方法如果扩展有改动可以重写
function M:InitPlayerInfoView(isHideIpAdds)
self._player_info = {}
local _player_info = self._player_info
for i = 1, self._room.room_config.people_num do
local tem = self._view:GetChild('player_info' .. i)
_player_info[i] = PlayerInfoView.new(tem, self, isHideIpAdds)
tem.visible = false
end
end
-- 显示牌友圈助手
function M:ShowFGAssist()
UIPackage.AddPackage('base/newgroup/ui/FGAssist')
local btn_assist = UIPackage.CreateObjectFromURL('ui://FGAssist/btn_assist')
self.btn_assist = btn_assist
self._view:AddChild(btn_assist)
local panel_assist =
FGAssistView.new(
2025-04-02 19:03:26 +08:00
self._root_view,
function()
btn_assist.touchable = true
end
)
2025-04-01 10:48:36 +08:00
if self._full then
btn_assist.x = 40
else
btn_assist.x = (GRoot.inst.width - 1334) * -0.5 + 40
end
btn_assist.y = panel_assist._root_view.height / 3 - 0.5 * btn_assist.height
btn_assist.onClick:Set(
function()
panel_assist:ReloadView()
panel_assist:Show()
btn_assist.touchable = false
end
)
self.panel_assist = panel_assist
self._state.onChanged:Set(
function()
btn_assist.visible = self._state.selectedIndex == 0
if self._state.selectedIndex == 1 then
if panel_assist then
panel_assist:Close()
end
end
end
)
end
-- 设置助手按钮的位置
function M:SetBtnAssistPos(x, y)
if not self.btn_assist then
return
end
if self._full then
self.btn_assist.x = x
else
self.btn_assist.x = (GRoot.inst.width - 1334) * -0.5 + x
end
self.btn_assist.y = y
end
function M:NewSettingView()
local settingView = SettingView.new(self._root_view)
settingView:FillBgSection(
function(url)
LoadGameBg(url, self._root_view)
end,
self._room.game_id,
5
)
return settingView
end
2025-08-23 22:23:17 +08:00
function M:__RecordTouchMove(context)
if Mathf.Abs(context.inputEvent.x - self._record_pos.x) >= 50 or Mathf.Abs(context.inputEvent.y - self._record_pos.y) >= 50 then
self._record_view_ctr.selectedIndex = 1
else
self._record_view_ctr.selectedIndex = 0
end
end
2025-04-01 10:48:36 +08:00
function M:__RecordTouchEnd()
if (self.__runwait_record ~= nil) then
coroutine.stop(self.__runwait_record)
end
if self._record_time < 0.3 then
self:__SetRecordEnable()
end
2025-08-28 16:26:26 +08:00
2025-04-01 10:48:36 +08:00
self.__runwait_record = nil
self._ctr_voice.selectedIndex = 0
GameApplication.Instance.StopMusic = GameApplication.Instance.StopMusic - 1
2025-06-10 16:11:48 +08:00
self._chat_Talk.onTouchEnd:Remove(self.__RecordTouchEnd, self)
2025-04-01 10:48:36 +08:00
local room = self._room
2025-08-28 16:26:26 +08:00
if self._record_view_ctr.selectedIndex == 0 then
Voice.EndRecord(
room.room_id,
DataManager.SelfUser.account_id,
function(filename)
local _gamectr = ControllerManager.GetController(GameController)
_gamectr:SendInteraction(DataManager.SelfUser.account_id, 3, filename)
end
)
end
2025-04-01 10:48:36 +08:00
end
function M:__WaitRecord()
coroutine.wait(20)
self:__RecordTouchEnd()
end
function M:__SetRecordEnable()
record_baned = 1 - record_baned
self.ctr_record_ban.selectedIndex = record_baned
end
function M:FillRoomConfig(roominfo_panel, _room)
if roominfo_panel ~= nil then
local tex_roomid = roominfo_panel:GetChild('tex_roomid')
tex_roomid.text = _room.room_id
if _room.room_config.isHidden and _room.room_config.isHidden == 1 then
--tex_roomid.text = "000000"
end
local tex_gametype = roominfo_panel:GetChild('tex_gametype')
if (tex_gametype ~= nil) then
tex_gametype.text = _room.room_config:GetGameName()
end
local tex_roomconfig = roominfo_panel:GetChild('tex_roomconfig')
if (tex_roomconfig ~= nil) then
tex_roomconfig.text = _room.room_config:GetDes()
end
local tex_times = roominfo_panel:GetChild('tex_times')
if DataManager.CurrenRoom.hpOnOff == 1 and DataManager.CurrenRoom.score_times ~= 1 then
if tex_times then
tex_times.text = DataManager.CurrenRoom.score_times .. ''
end
end
end
end
function M:EventInit()
2025-05-14 19:34:03 +08:00
print("lingmengEventInit")
2025-04-01 10:48:36 +08:00
local _gamectr = self._gamectr
local _player_info = self._player_info
local _room = self._room
_gamectr:AddEventListener(GameEvent.PlayerEnter, handler(self, self.OnPlayerEnter))
_gamectr:AddEventListener(
GameEvent.PlayerState,
function(...)
2025-04-02 19:03:26 +08:00
local arg = { ... }
2025-04-01 10:48:36 +08:00
local p = arg[1]
local info = _player_info[self:GetPos(p.seat)]
info._ctr_offline.selectedIndex = p.line_state == 0 and 1 or 0
self:PlayerChangeLineState()
end
)
_gamectr:AddEventListener(GameEvent.OnUpdateInfo, handler(self, self.OnUpdateInfo))
_gamectr:AddEventListener(GameEvent.PlayerLeave, handler(self, self.OnPlayerLeave))
_gamectr:AddEventListener(GameEvent.PlayerReady, handler(self, self.OnPlayerReady))
2025-07-19 16:32:03 +08:00
_gamectr:AddEventListener(GameEvent.AddScore, handler(self, self.OnAddScoreAnimation))
2025-07-30 21:55:34 +08:00
--_gamectr:AddEventListener(GameEvent.MISSILE, handler(self, self.OnMissile))
2025-07-11 21:37:35 +08:00
2025-04-01 10:48:36 +08:00
_gamectr:AddEventListener(
GameEvent.DeskBreak,
function(...)
2025-04-02 19:03:26 +08:00
local arg = { ... }
2025-04-01 10:48:36 +08:00
local code = arg[1]
if code == 0 then
if self.dismissWin == nil then
self.dismissWin = DismissRoomWindow.new(self._root_view)
end
self.dismissWin:FillData(arg[2])
self.dismissWin:Show()
elseif code == 1 then
ViewManager.ChangeView(ViewManager.View_Family)
2025-04-01 10:48:36 +08:00
ViewUtil.ShowTips('房间已解散!')
elseif code == 2 then
-- self:DismissRoomAgree(p,result)
local p = arg[2]
local result = arg[3]
elseif code == 3 then
if self.dismissWin ~= nil then
self.dismissWin:Destroy()
end
self.dismissWin = nil
self.dismiss_room_cd_time = 30
ViewUtil.ShowTips('解散失败!')
end
end
)
_gamectr:AddEventListener(
GameEvent.Interaction,
function(...)
2025-04-02 19:03:26 +08:00
local arg = { ... }
2025-07-21 14:42:49 +08:00
local data = arg[1]
2025-08-05 20:29:11 +08:00
local _type = arg[2]
2025-08-06 16:58:34 +08:00
-- 扔番茄
if _type == 7 then
2025-08-05 20:29:11 +08:00
local sendSeat = arg[3].sendSeat
local targetSeat = arg[3].targetSeat
local Missile = arg[3].Missile
self:Missile(sendSeat, targetSeat, Missile)
2025-07-21 14:42:49 +08:00
end
2025-04-01 10:48:36 +08:00
local p = arg[1]
if not p or not p.seat or p.seat == 0 then
return
end
if DataManager.BanInteractRoom == _room.room_id and p.seat ~= _room.self_player.seat then
return
end
local info = self._player_info[self:GetPos(p.seat)]
local ttype = arg[2]
if ttype == 5 then
local parm = arg[3]
local array = split(parm, '_')
local tp = self._room:GetPlayerById(tonumber(array[2]))
if not tp or not tp.seat or tp.seat == 0 then
return
end
local pos = self._view:GlobalToLocal(info._view:LocalToGlobal(info:GetHeadCenter()))
if tp.seat == p.seat then
for i = 1, #_room.player_list do
local player = _room.player_list[i]
if player.seat ~= tp.seat then
tinfo = self._player_info[self:GetPos(player.seat)]
tpos = self._view:GlobalToLocal(tinfo._view:LocalToGlobal(tinfo:GetHeadCenter()))
self:PlayInteractAnimation(array[1], pos, tpos)
end
end
else
local tinfo = self._player_info[self:GetPos(tp.seat)]
local tpos = self._view:GlobalToLocal(tinfo._view:LocalToGlobal(tinfo:GetHeadCenter()))
self:PlayInteractAnimation(array[1], pos, tpos)
end
elseif ttype == 3 then
if record_baned == 0 then
info:ShowInteraction(ttype, arg[3])
end
else
info:ShowInteraction(ttype, arg[3])
end
end
)
_gamectr:AddEventListener(
GameEvent.OnKicked,
function()
2025-04-02 19:03:26 +08:00
printlog("GameEvent.OnKicked====》》》》》")
2025-04-01 10:48:36 +08:00
self:UnmarkSelfTuoguan()
local _curren_msg = MsgWindow.new(self._root_view, '由于长时间未准备,你已被踢出房间!', MsgWindow.MsgMode.OnlyOk)
_curren_msg.onOk:Add(
function()
ViewManager.ChangeView(ViewManager.View_Lobby)
end
)
_curren_msg:Show()
end
)
2025-04-02 19:03:26 +08:00
_gamectr:AddEventListener(
2025-04-01 10:48:36 +08:00
GameEvent.TupGuanOpen,
function(...)
2025-04-11 12:49:08 +08:00
---- print("刷新托管数据=====")
2025-04-02 19:03:26 +08:00
local arg = { ... }
local p = arg[1]
local info = self._player_info[self:GetPos(p.seat)]
2025-08-28 15:02:07 +08:00
self._left_time = tonumber(arg[3]) or 0
2025-04-02 19:03:26 +08:00
if info and info.IsShowTGTips then
info:IsShowTGTips(arg[2], arg[3])
end
if info and info.SetShowTGTips then
info:SetShowTGTips(arg[2], arg[3])
end
2025-04-01 10:48:36 +08:00
end
)
2025-06-16 15:24:27 +08:00
_gamectr:AddEventListener(
GameEvent.WitnessPlayerEnter,
function(...)
---- print("刷新托管数据=====")
local arg = { ... }
local witnessPlayerList = arg[1]
_room.witness_player_list = witnessPlayerList
2025-06-25 22:49:44 +08:00
_room._flag_updateWitness = true
2025-06-16 15:24:27 +08:00
end
)
_gamectr:AddEventListener(
GameEvent.WitnessPlayerLeave,
function(...)
2025-06-19 14:38:23 +08:00
-- print("刷新托管数据=====")
2025-06-16 15:24:27 +08:00
local arg = { ... }
local player = arg[1]
local witnessPlayerList = _room.witness_player_list
2025-06-25 22:49:44 +08:00
for i, _player in ipairs(witnessPlayerList) do
if _player.uid == player then
table.remove(witnessPlayerList, i)
return
end
end
_room._flag_updateWitness = true
2025-06-16 15:24:27 +08:00
end
)
2025-07-20 06:21:43 +08:00
_gamectr:AddEventListener(GameEvent.HOMESTATE, function(...)
2025-08-13 23:07:05 +08:00
local arg = { ... }
2025-07-20 06:21:43 +08:00
local uid = arg[1].uid
local setHome = arg[1].setHome
local gameStatus = arg[1].gameStatus
local seat = GetSeat(self, uid)
local info = self._player_info[self:GetPos(seat)]
2025-08-13 23:07:05 +08:00
if gameStatus == "out" then
2025-07-20 06:21:43 +08:00
info:UpdateLineState(0)
2025-08-13 23:07:05 +08:00
elseif gameStatus == "enter" then
2025-07-20 06:21:43 +08:00
info:UpdateLineState(1)
end
end)
2025-04-01 10:48:36 +08:00
end
-- 设置能否互动,1允许,0禁止
function M:SetInteractEnabled(val)
if val == 0 then
DataManager.BanInteractRoom = self._room.room_id
else
DataManager.BanInteractRoom = nil
end
end
-- 获取能否互动状态
function M:GetInteractEnabled()
return DataManager.BanInteractRoom == self._room.room_id and 0 or 1
end
-- 桌面动画效果
function M:PlayInteractAnimation(str, mypos, pos)
local eff = UIPackage.CreateObjectFromURL('ui://Common/Eff' .. str)
local myEff = UIPackage.CreateObjectFromURL('ui://Common/myEff' .. str)
self._view:AddChild(myEff)
myEff.x = mypos.x
myEff.y = mypos.y
local offsetX = pos.x - mypos.x
local offsetY = pos.y - mypos.y
if str ~= '5' and str ~= '1' then
local total_rotation = (offsetY + offsetX) / 100 * 50
self._run_move =
TweenUtils.TweenFloat(
2025-04-02 19:03:26 +08:00
0,
1,
0.5,
function(value)
myEff.x = mypos.x + offsetX * value
myEff.y = mypos.y + offsetY * value
if str == '2' then
myEff.rotation = total_rotation * value
end
2025-04-01 10:48:36 +08:00
end
2025-04-02 19:03:26 +08:00
)
2025-04-01 10:48:36 +08:00
end
self._run_eff =
coroutine.start(
2025-04-02 19:03:26 +08:00
function()
if str ~= '1' then
coroutine.wait(0.5)
else
local degree = math.atan2(offsetX, offsetY) * 180 / math.pi - 90
if degree < -180 then
degree = 360 + degree
end
degree = degree * -1
if degree > 90 or degree < -90 then
degree = degree + 180 * (degree > 90 and -1 or 1)
myEff.scaleX = -1
end
myEff.rotation = degree
coroutine.wait(0.2)
2025-04-01 10:48:36 +08:00
end
2025-04-02 19:03:26 +08:00
self._view:AddChild(eff)
eff.x = pos.x
eff.y = pos.y
coroutine.wait(1.5)
eff:Dispose()
myEff:Dispose()
2025-04-01 10:48:36 +08:00
end
2025-04-02 19:03:26 +08:00
)
2025-04-01 10:48:36 +08:00
end
function M:GetReadyNum()
local readyNum = 0
local list = self._room.player_list
for i = 1, #list do
local p = list[i]
if p.ready then
readyNum = readyNum + 1
end
end
return readyNum
end
function M:OnPlayerEnter(...)
printlog("进入房间222222222222222222++++++++++++++++++++++++++++")
2025-04-02 19:03:26 +08:00
local arg = { ... }
2025-04-01 10:48:36 +08:00
local p = arg[1]
if
p ~= self._room.self_player and self._room.room_config.people_num <= 4 and
2025-04-02 19:03:26 +08:00
self._room.room_config.people_num >= 3 and
self._gamectr:CheckGPS()
then
2025-04-01 10:48:36 +08:00
if self._room.self_player.seat == 0 then
return
end
2025-04-16 17:32:15 +08:00
-- ------lingmeng-----暂时去除gps位置判定
-- if self.distance_view then
-- self.distance_view:Destroy()
-- end
-- self.distance_view = PlayerDistanceView.new(true, self._gps_style, function(v)
-- self:continue_game(v)
-- end)
-- self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and
-- self._state.selectedIndex < 3 and 1 or 0
-- self.distance_view:Show()
2025-08-06 18:34:58 +08:00
--if self.btn_distance then
-- self.btn_distance:GetController("state").selectedIndex = 1
--end
2025-04-01 10:48:36 +08:00
end
local info = self._player_info[self:GetPos(p.seat)]
info:FillData(p)
info._view.visible = true
end
function M:OnPlayerReady(...)
2025-05-14 19:34:03 +08:00
print("lingmengOnPlayerReady")
2025-04-02 19:03:26 +08:00
local arg = { ... }
2025-04-01 10:48:36 +08:00
local p = arg[1]
2025-04-02 19:03:26 +08:00
if p.isSendCardState ~= nil and p.isSendCardState == true then
p.isSendCardState = false
ControllerManager.IsSendCard = false
2025-05-14 19:34:03 +08:00
print("进入设置计时器控制==========")
2025-04-02 19:03:26 +08:00
coroutine.start(function()
2025-05-14 19:34:03 +08:00
print("计时器倒计时5s=============")
2025-04-02 19:03:26 +08:00
coroutine.wait(5)
2025-05-14 19:34:03 +08:00
print("当前状态==============")
print(ControllerManager.IsSendCard)
2025-04-02 19:03:26 +08:00
if ControllerManager.IsSendCard == true then
2025-05-14 19:34:03 +08:00
print("以发送开牌======================")
2025-04-02 19:03:26 +08:00
return
else
2025-05-14 19:34:03 +08:00
print("开始断线重连")
ControllerManager.OnConnect(SocketCode.TimeoutDisconnect)
2025-04-02 19:03:26 +08:00
ViewManager.refreshGameView()
end
ControllerManager.IsSendCard = false
end)
end
2025-04-01 10:48:36 +08:00
if p.seat == self._room.self_player.seat then
if self._ctr_action then
self._ctr_action.selectedIndex = 0
end
end
local info = self._player_info[self:GetPos(p.seat)]
info:Ready(true)
printlog("基类准备++++++++++++++++++++++++++")
end
2025-07-11 21:37:35 +08:00
-- 飘字
2025-07-19 16:32:03 +08:00
function M:OnAddScoreAnimation(...)
print("OnAddScoreAnimation")
2025-07-16 15:07:29 +08:00
local arg = { ... }
2025-07-19 16:32:03 +08:00
local totalScoreList = arg[2].totalScoreList
local playerList = arg[2].playerList
local addScoreList = arg[2].addScoreList
2025-07-11 21:37:35 +08:00
pt(arg)
2025-07-16 15:07:29 +08:00
2025-07-19 16:32:03 +08:00
local scoreData = {}
for i = 1, #totalScoreList do
local p = {}
p.totalScore = totalScoreList[i]
p.player = playerList[i]
p.addScore = addScoreList[i]
2025-07-16 15:07:29 +08:00
2025-07-19 16:32:03 +08:00
scoreData[#scoreData + 1] = p
end
for _, p in pairs(scoreData) do
local infoView = self:GetPlayerInfo(p.player)
local player = GetPlayer(self, p.player)
player.cur_hp = p.totalScore
2025-07-11 21:37:35 +08:00
2025-07-19 16:32:03 +08:00
if p.addScore ~= 0 then
infoView:ScoreAnimation(p.addScore)
if player.cur_hp >= 0 then
infoView._view:GetChild("text_jifen").text = "+" .. player.cur_hp
else
infoView._view:GetChild("text_jifen").text = player.cur_hp
end
end
2025-07-16 15:07:29 +08:00
end
2025-07-11 21:37:35 +08:00
end
2025-07-30 21:55:34 +08:00
--[[
2025-07-19 16:32:03 +08:00
function M:OnMissile(...)
local arg = {...}
print("OnMissile 有人发表情了")
pt(arg)
2025-08-13 23:07:05 +08:00
2025-07-19 16:32:03 +08:00
--self:Missile()
end
2025-07-30 21:55:34 +08:00
]]
2025-07-19 16:32:03 +08:00
2025-04-01 10:48:36 +08:00
function M:OnUpdateInfo(...)
2025-04-02 19:03:26 +08:00
local arg = { ... }
2025-04-01 10:48:36 +08:00
local p = arg[1]
local t = arg[2]
-- 托管状态变化
if t == 5 then
if p == DataManager.CurrenRoom.self_player then
if p.entrust then
self:closeTipOnTuoguan()
self:MarkSelfTuoguan()
else
self:UnmarkSelfTuoguan()
end
else
local player_info = self._player_info[self:GetPos(p.seat)]
if p.entrust then
player_info:MarkTuoguan()
else
player_info:UnmarkTuoguan()
end
end
end
end
-- 标记自己托管
function M:MarkSelfTuoguan()
if self._com_tuoguan then
return
end
2025-04-02 19:03:26 +08:00
2025-04-01 10:48:36 +08:00
self._com_tuoguan = UIPackage.CreateObjectFromURL('ui://Common/com_tuoguan_self')
local com_tuoguan = self._com_tuoguan
GRoot.inst:AddChild(com_tuoguan)
--com_tuoguan:Center()
--com_tuoguan.y = GRoot.inst.height - com_tuoguan.height
--com_tuoguan.x = (GRoot.inst.width - com_tuoguan.width) * 0.5
local _msg_view = nil
com_tuoguan:GetChild('n0').onClick:Set(
function()
if _msg_view then
_msg_view:Dispose()
end
local _curren_msg = UIPackage.CreateObjectFromURL('ui://Common/MessageBox')
_msg_view = _curren_msg
_msg_view:GetChild('btn_ok').onClick:Set(
function()
_msg_view:Dispose()
_msg_view = nil
self._gamectr:Entrust(false)
end
)
_msg_view:GetChild('btn_close').onClick:Set(
function()
_msg_view:Dispose()
_msg_view = nil
end
)
_msg_view:GetChild('btn_close1').onClick:Set(
function()
_msg_view:Dispose()
_msg_view = nil
end
)
2025-04-02 19:03:26 +08:00
local roate = GRoot.inst.width / GRoot.inst.height
local num = 100
if roate < 1.9 then
num = 250
end
2025-04-01 10:48:36 +08:00
com_tuoguan:AddChild(_msg_view)
_msg_view:GetChild('tex_message').text = '确定要取消托管吗?'
2025-04-02 19:03:26 +08:00
_msg_view.x = (com_tuoguan.width - _msg_view.width) * 0.5 - num
2025-04-01 10:48:36 +08:00
_msg_view.y = (com_tuoguan.height - com_tuoguan.y - _msg_view.height) * 0.5
end
)
end
-- 取消标记自己托管
function M:UnmarkSelfTuoguan()
if self._com_tuoguan then
self._com_tuoguan:Dispose()
self._com_tuoguan = nil
end
end
function M:OnPlayerLeave(...)
2025-04-02 19:03:26 +08:00
local arg = { ... }
2025-04-01 10:48:36 +08:00
local p = arg[1]
local info = self._player_info[self:GetPos(p.seat)]
info._view.visible = false
if not self._gamectr:CheckGPS() then
2025-08-06 18:34:58 +08:00
--self.btn_distance:GetController("state").selectedIndex = 0
2025-04-01 10:48:36 +08:00
end
end
function M:PlayerChangeLineState()
end
function M:ReloadInteractView()
if self.chat_view then
self.chat_view:FillChatMsg()
end
end
function M:PlayChatSound(sex, chat_index)
local sex_path = ViewUtil.Sex_Chat[sex]
local path1 = string.format('base/common/sound/%s/chat_%s.mp3', sex_path, tostring(chat_index - 1))
GameApplication.Instance:PlaySound('base_chat', path1)
-- GameApplication.Instance:PlaySound(path1)
end
-- 获取语言
function M:GetLanguage()
if self._multilingual then
return self._language
else
return 0
end
end
-- 设置语言
function M:SetLanguage(language)
if self._multilingual then
self._language = language
end
end
2025-07-21 14:42:49 +08:00
function M:Missile(seat, targetSeat, Missile)
local animUrl = ""
local url = ""
2025-08-13 23:07:05 +08:00
if Missile == "boom" then
2025-07-21 14:42:49 +08:00
animUrl = "ui://Main_Majiang/Missile_boom"
url = "ui://Common/boom"
2025-08-13 23:07:05 +08:00
elseif Missile == "egg" then
2025-07-21 14:42:49 +08:00
animUrl = "ui://Main_Majiang/Missile_egg"
url = "ui://Common/egg"
2025-08-13 23:07:05 +08:00
elseif Missile == "diamo" then
2025-07-21 14:42:49 +08:00
animUrl = "ui://Main_Majiang/Missile_diamo"
url = "ui://Common/diamo"
2025-08-13 23:07:05 +08:00
elseif Missile == "flower" then
2025-07-21 14:42:49 +08:00
animUrl = "ui://Main_Majiang/Missile_flower"
url = "ui://Common/flower"
end
2025-07-16 15:07:29 +08:00
local send = self._player_info[self:GetPos(seat)]
local target = self._player_info[self:GetPos(targetSeat)]
2025-07-17 15:02:14 +08:00
MissileSender.Send(url, send._view, target._view, self._view, animUrl, 5, 1)
2025-07-16 15:07:29 +08:00
end
2025-04-01 10:48:36 +08:00
-- 获取消息使用的语言、序号
function M:GetChatMsgLanguage(msg_index)
local language = math.modf(msg_index / 100)
local index = math.fmod(msg_index, 100)
return language, index
end
function M:DismissRoomAgree(p, result)
local index = self:GetPos(p.seat)
self._player_info[index]:DismissRoom(result)
end
function M:PlaySound(sex, path)
end
function M:OnUpdate()
local deltaTime = Time.deltaTime
if (self._popEvent) then
local func = self._gamectr:PopEvent()
if (func ~= nil) then
2025-06-25 22:49:44 +08:00
local result, resultInfo = pcall(func)
if result then
2025-04-02 19:03:26 +08:00
else
2025-06-25 22:49:44 +08:00
error(resultInfo)
2025-04-02 19:03:26 +08:00
self._gamectr = ControllerManager.GetController(GameController)
if self._gamectr then
self._gamectr:ResetConnect()
end
end
2025-04-01 10:48:36 +08:00
--func()
end
end
if self._view:GetChild('gcm_chat') then
self._record_time = self._record_time + deltaTime
2025-08-23 22:23:17 +08:00
if self._record_view then
self._record_view.title = math.floor(self._record_time) .. "\""
end
2025-06-10 16:11:48 +08:00
elseif self._record_time then
self._record_time = self._record_time + deltaTime
2025-08-23 22:23:17 +08:00
if self._record_view then
self._record_view.title = math.floor(self._record_time) .. "\""
end
2025-04-01 10:48:36 +08:00
end
2025-06-10 16:11:48 +08:00
2025-04-01 10:48:36 +08:00
local _left_time = self._left_time
if (_left_time > 0) then
_left_time = _left_time - deltaTime
_left_time = math.max(0, _left_time)
local leftTime = math.floor(_left_time)
2025-08-28 15:02:07 +08:00
--旧的拼接方式
-- if leftTime < 10 then
-- self._tex_leftTime.text = '0' .. tostring(leftTime)
-- for i = 2, 4 do
-- local text = self["_tex_leftTime" .. i]
-- if text then
-- text.text = '0' .. tostring(leftTime)
-- end
-- end
-- else
-- self._tex_leftTime.text = tostring(leftTime)
-- for i = 2, 4 do
-- local text = self["_tex_leftTime" .. i]
-- if text then
-- text.text = tostring(leftTime)
-- end
-- end
-- end
self._tex_leftTime.text = string.format("%02d", _left_time)
2025-04-01 10:48:36 +08:00
self._left_time = _left_time
-- 桌面計時器聲音
if not self._curtime then
self._curtime = 15
end
if leftTime <= 3 and self._curtime ~= leftTime and leftTime ~= 0 then
self._curtime = leftTime
GameApplication.Instance:PlaySound('base/sound/daojishi1.mp3')
end
else
self:onLeftTimeOver()
if self._tex_leftTime then
self._tex_leftTime.text = '00'
end
2025-04-02 19:03:26 +08:00
for i = 2, 4 do
local text = self["_tex_leftTime" .. i]
2025-04-01 10:48:36 +08:00
if text then
text.text = '00'
end
end
end
if (self.dismiss_room_cd_time > 0) then
self.dismiss_room_cd_time = self.dismiss_room_cd_time - deltaTime
self.dismiss_room_cd_time = math.max(0, self.dismiss_room_cd_time)
end
if self._style == 1 then
if (self._rightPanelView) then
self._rightPanelView:OnUpdate(deltaTime)
end
end
if (self.dismissWin) then
-- local ctr = ControllerManager.GetCurrenController()
-- if(ctr.baseType ~= GameController) then
-- self.dismissWin:Destroy()
-- self.dismissWin = nil
-- else
self.dismissWin:OnUpdate(deltaTime)
2025-04-02 19:03:26 +08:00
-- end
end
if self.OnMuShiUpdate then
self:OnMuShiUpdate()
2025-04-01 10:48:36 +08:00
end
end
2025-04-02 19:03:26 +08:00
2025-04-01 10:48:36 +08:00
function M:onLeftTimeOver()
2025-04-02 19:03:26 +08:00
2025-04-01 10:48:36 +08:00
end
2025-04-02 19:03:26 +08:00
2025-04-01 10:48:36 +08:00
function M:Clear()
-- self:__CloseTip()
for i = 1, #self._player_info do
self._player_info[i]:Clear()
end
end
function M:DestroyPlayerInfo()
2025-04-02 19:03:26 +08:00
for i = 1, #self._player_info do
2025-04-01 10:48:36 +08:00
self._player_info[i]:Destroy()
end
end
function M:GetPos(seat)
return ViewUtil.GetPos(self._room.self_player.seat, seat, self._room.room_config.people_num)
end
2025-07-16 15:07:29 +08:00
function M:GetPlayerInfo(playId)
for _, info in pairs(self._player_info) do
if info._player.self_user.account_id == playId then
return info
end
end
end
function M:GetPlayer(playId)
for _, player in pairs(self._room.player_list) do
if player.self_user.account_id == playId then
return player
end
end
end
2025-04-01 10:48:36 +08:00
-- 托管时关闭一些提示窗口,如起手胡、吃碰提示、海底,由扩展实现
function M:closeTipOnTuoguan()
end
local last_pause_time = 0
--游戏暂停
function M:OnApplicationPause()
if self.panel_assist then
self.panel_assist:Close()
end
last_pause_time = os.time()
end
--游戏激活
function M:OnApplicationActive()
2025-04-11 12:49:08 +08:00
---- print("游戏激活================")
2025-04-01 10:48:36 +08:00
if os.time() - last_pause_time > 15 then
last_pause_time = os.time()
ControllerManager.WebClient:clearActionQueue()
local ctr = ControllerManager.GetCurrenController()
if (ctr.baseType == GameController) then
ControllerManager.OnConnect(SocketCode.TimeoutDisconnect)
end
end
end
function M:Show()
BaseView.Show(self)
2025-08-06 19:39:06 +08:00
--[[
2025-04-01 10:48:36 +08:00
if self._state.selectedIndex == 0 and self._show_distance then
if self._room.self_player.seat == 0 then
return
end
2025-04-16 17:32:15 +08:00
-- ------lingmeng-----暂时去除gps位置判定
-- self.distance_view = PlayerDistanceView.new(true, self._gps_style, function(v)
-- self:continue_game(v)
-- end)
-- self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and
-- self._state.selectedIndex < 3 and 1 or 0
-- self.distance_view:Show()
-- self.btn_distance:GetController("state").selectedIndex = 1
2025-04-01 10:48:36 +08:00
end
2025-08-06 19:39:06 +08:00
]]
2025-04-01 10:48:36 +08:00
end
function M:Destroy()
2025-04-02 19:03:26 +08:00
TimerManager.Clear()
2025-04-01 10:48:36 +08:00
self:UnmarkSelfTuoguan()
2025-04-02 19:03:26 +08:00
self:DestroyPlayerInfo()
2025-04-01 10:48:36 +08:00
DSTweenManager.ClearTween()
NetResetConnectWindow.CloseNetReset()
Voice.CrealRecord()
ControllerManager.resetJionRoom = false
self._popEvent = false
GRoot.inst:HidePopup()
ViewUtil.CloseModalWait()
GameApplication.Instance.StopMusic = 0
coroutine.stopAll()
UpdateBeat:Remove(self.OnUpdate, self)
BaseView.Destroy(self)
BaseWindow.DestroyAll()
ResourcesManager.UnLoadGroup('base_chat')
end