diff --git a/lua_probject/base_project/Game/Controller/GameController.lua b/lua_probject/base_project/Game/Controller/GameController.lua index 1c122a95..1e0a0da3 100644 --- a/lua_probject/base_project/Game/Controller/GameController.lua +++ b/lua_probject/base_project/Game/Controller/GameController.lua @@ -9,6 +9,10 @@ GameEvent = { PlayerLeave = 'PlayerLeave', -- 玩家进入 PlayerEnter = 'PlayerEnter', + -- 观战玩家离开 + WitnessPlayerLeave = 'WitnessPlayerLeave', + -- 观战玩家进入 + WitnessPlayerEnter = 'WitnessPlayerEnter', -- 玩家准备 PlayerReady = 'PlayerReady', -- 解散 @@ -70,6 +74,9 @@ function M:init(name) self._eventmap[Protocol.GAME_EVT_READY_ENTRUST] = self.OnEvtOpenTupGTips self._eventmap[Protocol.GAME_EVT_CANCEL_READY_ENTRUST] = self.OnEvtCloseTupGTips + self._eventmap[Protocol.GAME_EVT_WITNESS_ROOM] = self.OnEvtEnterWitness + self._eventmap[Protocol.GAME_EVT_Exit_WITNESS_ROOM] = self.OnEvtExieWitness + --self._eventmap[Protocol.GAME_AUTO_CARD] = self.OnEvtOpenGameHuTuoGtips end @@ -632,3 +639,11 @@ function M:OnEvtOpenGameHuTuoGtips(isAuto) data.autoCard = isAuto _client:send(Protocol.GAME_AUTO_CARD, data) end + +function M:OnEvtEnterWitness(msg) + DispatchEvent(self._dispatcher, GameEvent.WitnessPlayerEnter, msg.tableInfo.playerSpectatorData) +end + +function M:OnEvtExieWitness(msg) + DispatchEvent(self._dispatcher, GameEvent.WitnessPlayerLeave, msg.playyer) +end diff --git a/lua_probject/base_project/Game/Controller/GroupMgrController.lua b/lua_probject/base_project/Game/Controller/GroupMgrController.lua index 950bfcc7..8d1c1ecc 100644 --- a/lua_probject/base_project/Game/Controller/GroupMgrController.lua +++ b/lua_probject/base_project/Game/Controller/GroupMgrController.lua @@ -290,8 +290,9 @@ function M:FG_GetOnlinePlayers(callback) end -- 邀请在线玩家 -function M:FG_InvitePlayer(tag, roomid, pid, game_name, callback) +function M:FG_InvitePlayer(group_id, tag, roomid, pid, game_name, callback) local _data = {} + _data.id = group_id _data.tagId = tag _data.roomid = roomid _data.pid = pid diff --git a/lua_probject/base_project/Game/Data/Room.lua b/lua_probject/base_project/Game/Data/Room.lua index d3499f6c..b7a91dd4 100644 --- a/lua_probject/base_project/Game/Data/Room.lua +++ b/lua_probject/base_project/Game/Data/Room.lua @@ -1,7 +1,7 @@ -- 房间基本数据类 --author:-- -StateType = +StateType = { Ready = 0, Palying = 1, @@ -35,6 +35,9 @@ local Room = { -- 玩家列表 player_list = nil, + -- 观战玩家列表 + witness_player_list = nil, + -- 游戏中 playing = false, @@ -63,7 +66,7 @@ RoomConfig = { opt_round = 1, } ---- +--- -- @type Room local M = Room @@ -71,14 +74,14 @@ local M = Room --- Create a new Room function Room.new() local self = {} - setmetatable(self, {__index = M}) + setmetatable(self, { __index = M }) self:init() return self end function M:init() self.player_list = {} - self.room_config ={} + self.room_config = {} end -- 创建玩家 @@ -89,16 +92,14 @@ end -- 添加玩家 function M:AddPlayer(player) if (not player) then return end - for k , tem in ipairs(self.player_list) do - if(tem.self_user.account_id == player.self_user.account_id) then + for k, tem in ipairs(self.player_list) do + if (tem.self_user.account_id == player.self_user.account_id) then -- tem = player self.player_list[k] = player return end end - self.player_list[#self.player_list+1] = player - - + self.player_list[#self.player_list + 1] = player end -- 是否为不可负分房间 @@ -110,24 +111,22 @@ function M:checkHpNonnegative() return false end - -- 删除指定玩家 -- function M:RemovePlayer(player) - for i , _player in ipairs(self.player_list) do + for i, _player in ipairs(self.player_list) do if _player == player then - table.remove(self.player_list , i) - return + table.remove(self.player_list, i) + return end end end - -- 获取指定玩家_userid -- -- function M:GetPlayerById(id) - for _ , tem in pairs(self.player_list) do + for _, tem in pairs(self.player_list) do if (tem.self_user.account_id == id) then return tem end @@ -135,12 +134,11 @@ function M:GetPlayerById(id) return nil; end - -- 获取指定玩家_桌号 -- -- function M:GetPlayerBySeat(seat) - for _ , tem in ipairs(self.player_list) do + for _, tem in ipairs(self.player_list) do if (tem.seat == seat) then return tem end @@ -156,6 +154,7 @@ function M:GetTotalScore(score) return score end end + -- 获取乘倍数前的积分 function M:GetOriginScore(total_score) if self.hpOnOff == 1 then @@ -164,10 +163,12 @@ function M:GetOriginScore(total_score) return total_score end end + -- 设置房间重连状态 function M:SetReloadStatus(flag) self.reloading = flag end + -- 获取房间重连状态 function M:GetReloadStatus() return self.reloading @@ -186,10 +187,10 @@ function RoomConfig:init(config) --不可负分 self.isNonnegative = config["isNonnegative"] self.pid = config["pid"] - return self + return self end -local str_tuoguan = {"当局结算", "二局结算", "三局结算","满局结算"} +local str_tuoguan = { "当局结算", "二局结算", "三局结算", "满局结算" } function RoomConfig:GetDes(sp, str_people_num) local str = "" if not str_people_num and self.people_num then diff --git a/lua_probject/base_project/Game/Protocol.lua b/lua_probject/base_project/Game/Protocol.lua index 0339ec89..6c493690 100644 --- a/lua_probject/base_project/Game/Protocol.lua +++ b/lua_probject/base_project/Game/Protocol.lua @@ -379,6 +379,10 @@ Protocol = { GAME_WITNESS_ROOM = "3013", -- 观战退出房间 GAME_Exit_WITNESS_ROOM = "3023", + -- 观战进入事件 + GAME_EVT_WITNESS_ROOM = "3012", + -- 观战退出事件 + GAME_EVT_Exit_WITNESS_ROOM = "3022", -- 进入房间 GAME_JOIN_ROOM = "1002", diff --git a/lua_probject/base_project/Game/View/FGAssistView.lua b/lua_probject/base_project/Game/View/FGAssistView.lua index 5fe78b57..057adb54 100644 --- a/lua_probject/base_project/Game/View/FGAssistView.lua +++ b/lua_probject/base_project/Game/View/FGAssistView.lua @@ -68,7 +68,8 @@ function M:PlayerRenderer(index, obj) btn_invite.onClick:Set(function() local mgr_ctr = ControllerManager.GetController(GroupMgrController) local room = DataManager.CurrenRoom - mgr_ctr:FG_InvitePlayer(self._data_number[i].uid, room.room_id, room.play_id, room.room_config:GetGameName(), + mgr_ctr:FG_InvitePlayer(self.group_id, self._data_number[i].uid, room.room_id, room.play_id, + room.room_config:GetGameName(), function() end) end) diff --git a/lua_probject/base_project/Game/View/MainView.lua b/lua_probject/base_project/Game/View/MainView.lua index 1ce298e5..c4e6f849 100644 --- a/lua_probject/base_project/Game/View/MainView.lua +++ b/lua_probject/base_project/Game/View/MainView.lua @@ -481,6 +481,18 @@ function M:InitView(url, isHideIpAdds) panel_assist:Show() end) end + + 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 + ------------------------------------------------------------ end @@ -520,6 +532,20 @@ function M:continue_game(continue) end end +--展示观战 +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 + -- 公用的playerinfoview方法,如果扩展有改动可以重写 function M:InitPlayerInfoView(isHideIpAdds) self._player_info = {} @@ -782,6 +808,32 @@ function M:EventInit() end end ) + + _gamectr:AddEventListener( + GameEvent.WitnessPlayerEnter, + function(...) + ---- print("刷新托管数据=====") + local arg = { ... } + local witnessPlayerList = arg[1] + _room.witness_player_list = witnessPlayerList + end + ) + + _gamectr:AddEventListener( + GameEvent.WitnessPlayerLeave, + function(...) + ---- print("刷新托管数据=====") + local arg = { ... } + local player = arg[1] + local witnessPlayerList = _room.witness_player_list + for i, _player in ipairs(witnessPlayerList) do + if _player.uid == player then + table.remove(witnessPlayerList, i) + return + end + end + end + ) end -- 设置能否互动,1允许,0禁止 diff --git a/lua_probject/extend_project/extend/majiang/lichuan/EXClearingView.lua b/lua_probject/extend_project/extend/majiang/lichuan/EXClearingView.lua index 34c14fa5..ebc4e04c 100644 --- a/lua_probject/extend_project/extend/majiang/lichuan/EXClearingView.lua +++ b/lua_probject/extend_project/extend/majiang/lichuan/EXClearingView.lua @@ -258,7 +258,7 @@ function M:fillResult1(room, peopleNum, total_result) local familyIDText = self._view:GetChild("Text_FamilyID") print("lingmeng fillResult1") pt(room) - for i, v in pairs(room.self_player.self_user.games) do + for i, v in pairs(DataManager.SelfUser.games) do if v.game_id == room.game_id then gameNameAndRoomIDText.text = string.format("%s 房号:%s", v.name, room.room_id) end diff --git a/lua_probject/extend_project/extend/majiang/lichuan/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/lichuan/ExtendConfig.lua index 0331e7d1..c980a76c 100644 --- a/lua_probject/extend_project/extend/majiang/lichuan/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/lichuan/ExtendConfig.lua @@ -246,7 +246,6 @@ function M:FillWitnessData(pd_data) room:AddPlayer(p) end - room.self_player.self_user = DataManager.SelfUser end function M.HandCardSortAndJing(a, b) diff --git a/lua_probject/main_project/main/majiang/MJCheckG.lua b/lua_probject/main_project/main/majiang/MJCheckG.lua new file mode 100644 index 00000000..f1ef2894 --- /dev/null +++ b/lua_probject/main_project/main/majiang/MJCheckG.lua @@ -0,0 +1,42 @@ +-- local EXMainView = import(".EXMainView") + +local MJCheckG = { +} +local M = MJCheckG +function MJCheckG.new() + setmetatable(M, { __index = BaseWindow }) + -- setmetatable(M, { __index = BaseWindow }) + local self = setmetatable({}, { __index = M }) + self.class = 'MJCheckG' + self._currenIndex = 0 + self._close_destroy = true + self:init('ui://Common/comp_checkG') + + return self +end + +function M:init(url) + BaseWindow.init(self, url) + + self._view:GetChild('btn_ok').onClick:Set(function() + self:Destroy() + end) + + self.valueTemp = 0 + self.silder = self._view:GetChild('slider_check') + local showText = self._view:GetChild('n3') + + self.coroutine = coroutine.start(function(...) + self.valueTemp = 0 + while self.valueTemp < 100 do + self.valueTemp = self.valueTemp + math.random(4) + self.silder.value = self.valueTemp + coroutine.wait(0.1) + end + showText.text = "检测完成,没有外挂痕迹" + coroutine.wait(2) + self:Destroy() + end) +end + +return M diff --git a/lua_probject/main_project/main/majiang/MJMainView.lua b/lua_probject/main_project/main/majiang/MJMainView.lua index c1862711..6ae87893 100644 --- a/lua_probject/main_project/main/majiang/MJMainView.lua +++ b/lua_probject/main_project/main/majiang/MJMainView.lua @@ -3,6 +3,7 @@ local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView") local TableBG = require("Game.Data.TableBG") local MJSettingView = import(".MJSettingViewNew") local MJMainRightPanelView = import(".MJMainRightPanelView") +local MJCheckG = import('.MJCheckG') local bg_config = { { id = 1, url = "base/main_majiang/bg/bg1", thumb = "ui://Main_Majiang/b01" }, @@ -142,6 +143,14 @@ function M:InitView(url, use_custom_bg, custom_bg_config) end) end + local checkG = self._view:GetChild('btn_check') + if checkG then + checkG.onClick:Set(function() + local checkG = MJCheckG.new() + checkG:Show() + end) + end + self:InitXiPai() self:InitXiPai1() end diff --git a/wb_new_ui/assets/FGAssist/invite/panel_invited.xml b/wb_new_ui/assets/FGAssist/invite/panel_invited.xml index aee88ce4..fe5fd813 100644 --- a/wb_new_ui/assets/FGAssist/invite/panel_invited.xml +++ b/wb_new_ui/assets/FGAssist/invite/panel_invited.xml @@ -8,26 +8,27 @@ - +