From 3f6e4ee15deca15f95d07e6f846c0cb0f703669f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=AE=B6=E7=82=9C?= <2029049582@qq.com> Date: Wed, 10 Sep 2025 21:55:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=A8=E9=BA=BB=E5=B0=86=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extend/majiang/fuzhou/EXWitnessView.lua | 149 +++++++++++------ .../extend/majiang/jinxi/EXWitnessView.lua | 150 ++++++++++++------ .../extend/majiang/nancheng/EXWitnessView.lua | 149 +++++++++++------ 3 files changed, 300 insertions(+), 148 deletions(-) diff --git a/lua_probject/extend_project/extend/majiang/fuzhou/EXWitnessView.lua b/lua_probject/extend_project/extend/majiang/fuzhou/EXWitnessView.lua index 248910d5..288c7b33 100644 --- a/lua_probject/extend_project/extend/majiang/fuzhou/EXWitnessView.lua +++ b/lua_probject/extend_project/extend/majiang/fuzhou/EXWitnessView.lua @@ -66,24 +66,46 @@ function M:InitView() self:InitPlayerInfoView() self._player_card_info = {} local _player_card_info = self._player_card_info - for i = 1, #room.player_list do - local p = room.player_list[i] - local index = self:GetPos(p.seat) - print("lingmeng index", index) - local info = self._player_info[index] - local tem = self._view:GetChild("player_card_info" .. index) - _player_card_info[index] = self:NewMJPlayerCardInfoView(tem, index) - local cardInfo = _player_card_info[index] - cardInfo:SetPlayer(p) - cardInfo:UpdateHandCardWitness(false) - cardInfo:UpdateOutCardList(nil, nil, self._cursor) - for i = 1, #p.fz_list do - cardInfo:UpdateFzList(p.fz_list[i], -1) + if room.curren_round > 0 then + for i = 1, #room.room_config.people_num do + local p = room.player_list[i] + local index = self:GetPos(p.seat) + print("lingmeng index", index) + local info = self._player_info[i] + local tem = self._view:GetChild("player_card_info" .. i) + _player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i) + local cardInfo = _player_card_info[i] + cardInfo:SetPlayer(p) + cardInfo:UpdateHandCardWitness(false) + cardInfo:UpdateOutCardList(nil, nil, self._cursor) + for i = 1, #p.fz_list do + cardInfo:UpdateFzList(p.fz_list[i], -1) + end + info:FillData(p) + info._view.visible = false + end + else + for i = 1, room.room_config.people_num do + local tem = self._view:GetChild("player_card_info" .. i) + _player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i) + end + for i = 1, #room.player_list do + local p = room.player_list[i] + local index = self:GetPos(p.seat) + local info = self._player_info[i] + local cardInfo = _player_card_info[index] + cardInfo:SetPlayer(p) + cardInfo:UpdateHandCardWitness(false) + cardInfo:UpdateOutCardList(nil, nil, self._cursor) + for i = 1, #p.fz_list do + cardInfo:UpdateFzList(p.fz_list[i], -1) + end + info:FillData(p) + info._view.visible = true end - info:FillData(p) - info._view.visible = true end + local btn_rule = self._view:GetChild('btn_rule') if btn_rule ~= nil then btn_rule.onClick:Set(function() @@ -145,11 +167,21 @@ function M:EventInit() self:PlayMJSound("user_enter.mp3") local arg = { ... } local p = arg[1] - local info = self._player_info[self:GetPos(p.seat)] - info:FillData(p) - info._view.visible = true - info:SetPlayer(p) - info:FillData() + local info1 = self._player_info[self:GetPos(p.seat)] + info1:FillData(p) + info1._view.visible = true + + local info2 = self._player_card_info[self:GetPos(p.seat)] + info2:SetPlayer(p) + info2:FillData() + end) + + _gamectr:AddEventListener(GameEvent.PlayerLeave, function(...) + local arg = { ... } + local p = arg[1] + local info1 = self._player_info[self:GetPos(p.seat)] + info1._view.visible = false + self:PlayMJSound("user_leave.mp3") end) _gamectr:AddEventListener(GameEvent.WitnessPlayerEnter, function(...) @@ -277,6 +309,7 @@ function M:EventInit() _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self, self.OnFangziAction)) _gamectr:AddEventListener(TX_GameEvent.ZPHuCard, function(...) + self._popEvent = false self._left_time = 0 self:UpdateCardBox(0) local arg = { ... } @@ -433,10 +466,12 @@ function M:EventInit() local result = arg[1] local over = arg[3] self._clearingView = EXClearingView.new() - coroutine.start(function() - coroutine.wait(0.5) - self._clearingView:Show() - end) + if over ~= 2 or _room.curren_round > 0 then + coroutine.start(function() + coroutine.wait(0.5) + self._clearingView:Show() + end) + end self._clearingView:InitData(over, _room, result, total_result) ControllerManager.ChangeController(LoddyController) end) @@ -496,17 +531,54 @@ function M:OnFangziAction(...) local info = _player_card_info[self:GetPos(player.seat)] -- local pNode = info._mask_liangpai + + + local arg = { ... } + local _player_card_info = self._player_card_info + local fz = arg[1] + local player = arg[2] + local index = arg[3] + local info = _player_card_info[self:GetPos(player.seat)] + -- local pNode = info._mask_liangpai + local effect = UIPackage.CreateObject("Extend_MJ_JinXi", "FzEffect") + if fz.type == FZType.Peng then + self:PlaySound("JinXi_MJ", player.self_user.sex, "peng") + effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "碰") + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "碰") + -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "碰框") + elseif fz.type == FZType.Chi then + self:PlaySound("JinXi_MJ", player.self_user.sex, "chi") + effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "吃") + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "吃") + else + self:PlaySound("JinXi_MJ", player.self_user.sex, "gang") + effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "杠") + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "杠") + -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框") + end + effect.touchable = false + effect:GetTransition("t2"):Play() + -- pNode:AddChild(effect) + coroutine.start(function() + coroutine.wait(0.3) + self._popEvent = true + end) + coroutine.start(function() + coroutine.wait(2) + effect:Dispose() + end) + self:RemoveCursor() if (player.seat ~= fz.from_seat) then local fs_info = _player_card_info[self:GetPos(fz.from_seat)] fs_info:UpdateOutCardList() end + local seat = (self._room.room_config.people_num == 2 and fz.from_seat == 2) and 2 or fz.from_seat - 1 + info:UpdateFzList(fz, index, true, seat) - info:UpdateFzList(fz, index, true) - local getcard = fz.type == FZType.Peng or fz.type == FZType.Chi - --printlog(getcard) + --因为观战没有手牌,等预处理完扣牌数之后矫正一次(最粗暴的修正方式,手牌数等于13-3*吃碰数) - info._player.hand_left_count = info._player.hand_left_count - 1 + info._player.hand_left_count = 14 - 3 * #info._player.fz_list info:UpdateHandCardWitness(true) -- self:__CloseTip() end @@ -551,27 +623,6 @@ end -- end -- end -function M:OnUpdate() - if (self._popEvent) then - local func = self._gamectr:PopEvent() - if (func ~= nil) then - local success, result = pcall(func) - if success then - - else - print("witness error") - print(result) - error(result) - -- self._gamectr = ControllerManager.GetController(GameController) - -- if self._gamectr then - -- self._gamectr:ResetConnect() - -- end - end - --func() - end - end -end - function M:ResetConnect() end diff --git a/lua_probject/extend_project/extend/majiang/jinxi/EXWitnessView.lua b/lua_probject/extend_project/extend/majiang/jinxi/EXWitnessView.lua index 9ca493ab..222511c8 100644 --- a/lua_probject/extend_project/extend/majiang/jinxi/EXWitnessView.lua +++ b/lua_probject/extend_project/extend/majiang/jinxi/EXWitnessView.lua @@ -66,24 +66,46 @@ function M:InitView(url) self:InitPlayerInfoView() self._player_card_info = {} local _player_card_info = self._player_card_info - for i = 1, #room.player_list do - local p = room.player_list[i] - local index = self:GetPos(p.seat) - print("lingmeng index", index) - local info = self._player_info[index] - local tem = self._view:GetChild("player_card_info" .. index) - _player_card_info[index] = self:NewMJPlayerCardInfoView(tem, index) - local cardInfo = _player_card_info[index] - cardInfo:SetPlayer(p) - cardInfo:UpdateHandCardWitness(false) - cardInfo:UpdateOutCardList(nil, nil, self._cursor) - for i = 1, #p.fz_list do - cardInfo:UpdateFzList(p.fz_list[i], -1) + if room.curren_round > 0 then + for i = 1, #room.room_config.people_num do + local p = room.player_list[i] + local index = self:GetPos(p.seat) + print("lingmeng index", index) + local info = self._player_info[i] + local tem = self._view:GetChild("player_card_info" .. i) + _player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i) + local cardInfo = _player_card_info[i] + cardInfo:SetPlayer(p) + cardInfo:UpdateHandCardWitness(false) + cardInfo:UpdateOutCardList(nil, nil, self._cursor) + for i = 1, #p.fz_list do + cardInfo:UpdateFzList(p.fz_list[i], -1) + end + info:FillData(p) + info._view.visible = false + end + else + for i = 1, room.room_config.people_num do + local tem = self._view:GetChild("player_card_info" .. i) + _player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i) + end + for i = 1, #room.player_list do + local p = room.player_list[i] + local index = self:GetPos(p.seat) + local info = self._player_info[i] + local cardInfo = _player_card_info[index] + cardInfo:SetPlayer(p) + cardInfo:UpdateHandCardWitness(false) + cardInfo:UpdateOutCardList(nil, nil, self._cursor) + for i = 1, #p.fz_list do + cardInfo:UpdateFzList(p.fz_list[i], -1) + end + info:FillData(p) + info._view.visible = true end - info:FillData(p) - info._view.visible = true end + local btn_rule = self._view:GetChild('btn_rule') if btn_rule ~= nil then btn_rule.onClick:Set(function() @@ -145,11 +167,21 @@ function M:EventInit() self:PlayMJSound("user_enter.mp3") local arg = { ... } local p = arg[1] - local info = self._player_info[self:GetPos(p.seat)] - info:FillData(p) - info._view.visible = true - info:SetPlayer(p) - info:FillData() + local info1 = self._player_info[self:GetPos(p.seat)] + info1:FillData(p) + info1._view.visible = true + + local info2 = self._player_card_info[self:GetPos(p.seat)] + info2:SetPlayer(p) + info2:FillData() + end) + + _gamectr:AddEventListener(GameEvent.PlayerLeave, function(...) + local arg = { ... } + local p = arg[1] + local info1 = self._player_info[self:GetPos(p.seat)] + info1._view.visible = false + self:PlayMJSound("user_leave.mp3") end) _gamectr:AddEventListener(GameEvent.WitnessPlayerEnter, function(...) @@ -160,7 +192,6 @@ function M:EventInit() local _room = DataManager.CurrenRoom local viewList_witness = self._view:GetChild('comp_witness'):GetChild('list_players') - print("linemng tcp", _room._flag_updateWitness, #_room.witness_player_list, viewList_witness.numItems) if viewList_witness.numItems == #_room.witness_player_list then viewList_witness:RefreshVirtualList() else @@ -277,6 +308,7 @@ function M:EventInit() _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self, self.OnFangziAction)) _gamectr:AddEventListener(TX_GameEvent.ZPHuCard, function(...) + self._popEvent = false self._left_time = 0 self:UpdateCardBox(0) local arg = { ... } @@ -433,10 +465,12 @@ function M:EventInit() local result = arg[1] local over = arg[3] self._clearingView = EXClearingView.new() - coroutine.start(function() - coroutine.wait(0.5) - self._clearingView:Show() - end) + if over ~= 2 or _room.curren_round > 0 then + coroutine.start(function() + coroutine.wait(0.5) + self._clearingView:Show() + end) + end self._clearingView:InitData(over, _room, result, total_result) ControllerManager.ChangeController(LoddyController) end) @@ -496,17 +530,54 @@ function M:OnFangziAction(...) local info = _player_card_info[self:GetPos(player.seat)] -- local pNode = info._mask_liangpai + + + local arg = { ... } + local _player_card_info = self._player_card_info + local fz = arg[1] + local player = arg[2] + local index = arg[3] + local info = _player_card_info[self:GetPos(player.seat)] + -- local pNode = info._mask_liangpai + local effect = UIPackage.CreateObject("Extend_MJ_JinXi", "FzEffect") + if fz.type == FZType.Peng then + self:PlaySound("JinXi_MJ", player.self_user.sex, "peng") + effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "碰") + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "碰") + -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "碰框") + elseif fz.type == FZType.Chi then + self:PlaySound("JinXi_MJ", player.self_user.sex, "chi") + effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "吃") + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "吃") + else + self:PlaySound("JinXi_MJ", player.self_user.sex, "gang") + effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "杠") + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "杠") + -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框") + end + effect.touchable = false + effect:GetTransition("t2"):Play() + -- pNode:AddChild(effect) + coroutine.start(function() + coroutine.wait(0.3) + self._popEvent = true + end) + coroutine.start(function() + coroutine.wait(2) + effect:Dispose() + end) + self:RemoveCursor() if (player.seat ~= fz.from_seat) then local fs_info = _player_card_info[self:GetPos(fz.from_seat)] fs_info:UpdateOutCardList() end + local seat = (self._room.room_config.people_num == 2 and fz.from_seat == 2) and 2 or fz.from_seat - 1 + info:UpdateFzList(fz, index, true, seat) - info:UpdateFzList(fz, index, true) - local getcard = fz.type == FZType.Peng or fz.type == FZType.Chi - --printlog(getcard) + --因为观战没有手牌,等预处理完扣牌数之后矫正一次(最粗暴的修正方式,手牌数等于13-3*吃碰数) - info._player.hand_left_count = info._player.hand_left_count - 1 + info._player.hand_left_count = 14 - 3 * #info._player.fz_list info:UpdateHandCardWitness(true) -- self:__CloseTip() end @@ -551,27 +622,6 @@ end -- end -- end -function M:OnUpdate() - if (self._popEvent) then - local func = self._gamectr:PopEvent() - if (func ~= nil) then - local success, result = pcall(func) - if success then - - else - print("witness error") - print(result) - error(result) - -- self._gamectr = ControllerManager.GetController(GameController) - -- if self._gamectr then - -- self._gamectr:ResetConnect() - -- end - end - --func() - end - end -end - function M:ResetConnect() end diff --git a/lua_probject/extend_project/extend/majiang/nancheng/EXWitnessView.lua b/lua_probject/extend_project/extend/majiang/nancheng/EXWitnessView.lua index b46004cb..c0a57a14 100644 --- a/lua_probject/extend_project/extend/majiang/nancheng/EXWitnessView.lua +++ b/lua_probject/extend_project/extend/majiang/nancheng/EXWitnessView.lua @@ -66,24 +66,46 @@ function M:InitView() self:InitPlayerInfoView() self._player_card_info = {} local _player_card_info = self._player_card_info - for i = 1, #room.player_list do - local p = room.player_list[i] - local index = self:GetPos(p.seat) - print("lingmeng index", index) - local info = self._player_info[index] - local tem = self._view:GetChild("player_card_info" .. index) - _player_card_info[index] = self:NewMJPlayerCardInfoView(tem, index) - local cardInfo = _player_card_info[index] - cardInfo:SetPlayer(p) - cardInfo:UpdateHandCardWitness(false) - cardInfo:UpdateOutCardList(nil, nil, self._cursor) - for i = 1, #p.fz_list do - cardInfo:UpdateFzList(p.fz_list[i], -1) + if room.curren_round > 0 then + for i = 1, #room.room_config.people_num do + local p = room.player_list[i] + local index = self:GetPos(p.seat) + print("lingmeng index", index) + local info = self._player_info[i] + local tem = self._view:GetChild("player_card_info" .. i) + _player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i) + local cardInfo = _player_card_info[i] + cardInfo:SetPlayer(p) + cardInfo:UpdateHandCardWitness(false) + cardInfo:UpdateOutCardList(nil, nil, self._cursor) + for i = 1, #p.fz_list do + cardInfo:UpdateFzList(p.fz_list[i], -1) + end + info:FillData(p) + info._view.visible = false + end + else + for i = 1, room.room_config.people_num do + local tem = self._view:GetChild("player_card_info" .. i) + _player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i) + end + for i = 1, #room.player_list do + local p = room.player_list[i] + local index = self:GetPos(p.seat) + local info = self._player_info[i] + local cardInfo = _player_card_info[index] + cardInfo:SetPlayer(p) + cardInfo:UpdateHandCardWitness(false) + cardInfo:UpdateOutCardList(nil, nil, self._cursor) + for i = 1, #p.fz_list do + cardInfo:UpdateFzList(p.fz_list[i], -1) + end + info:FillData(p) + info._view.visible = true end - info:FillData(p) - info._view.visible = true end + local btn_rule = self._view:GetChild('btn_rule') if btn_rule ~= nil then btn_rule.onClick:Set(function() @@ -145,11 +167,21 @@ function M:EventInit() self:PlayMJSound("user_enter.mp3") local arg = { ... } local p = arg[1] - local info = self._player_info[self:GetPos(p.seat)] - info:FillData(p) - info._view.visible = true - info:SetPlayer(p) - info:FillData() + local info1 = self._player_info[self:GetPos(p.seat)] + info1:FillData(p) + info1._view.visible = true + + local info2 = self._player_card_info[self:GetPos(p.seat)] + info2:SetPlayer(p) + info2:FillData() + end) + + _gamectr:AddEventListener(GameEvent.PlayerLeave, function(...) + local arg = { ... } + local p = arg[1] + local info1 = self._player_info[self:GetPos(p.seat)] + info1._view.visible = false + self:PlayMJSound("user_leave.mp3") end) _gamectr:AddEventListener(GameEvent.WitnessPlayerEnter, function(...) @@ -277,6 +309,7 @@ function M:EventInit() _gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self, self.OnFangziAction)) _gamectr:AddEventListener(TX_GameEvent.ZPHuCard, function(...) + self._popEvent = false self._left_time = 0 self:UpdateCardBox(0) local arg = { ... } @@ -433,10 +466,12 @@ function M:EventInit() local result = arg[1] local over = arg[3] self._clearingView = EXClearingView.new() - coroutine.start(function() - coroutine.wait(0.5) - self._clearingView:Show() - end) + if over ~= 2 or _room.curren_round > 0 then + coroutine.start(function() + coroutine.wait(0.5) + self._clearingView:Show() + end) + end self._clearingView:InitData(over, _room, result, total_result) ControllerManager.ChangeController(LoddyController) end) @@ -496,17 +531,54 @@ function M:OnFangziAction(...) local info = _player_card_info[self:GetPos(player.seat)] -- local pNode = info._mask_liangpai + + + local arg = { ... } + local _player_card_info = self._player_card_info + local fz = arg[1] + local player = arg[2] + local index = arg[3] + local info = _player_card_info[self:GetPos(player.seat)] + -- local pNode = info._mask_liangpai + local effect = UIPackage.CreateObject("Extend_MJ_NanCheng", "FzEffect") + if fz.type == FZType.Peng then + self:PlaySound("NanCheng_MJ", player.self_user.sex, "peng") + effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "碰") + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "碰") + -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "碰框") + elseif fz.type == FZType.Chi then + self:PlaySound("NanCheng_MJ", player.self_user.sex, "chi") + effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "吃") + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "吃") + else + self:PlaySound("NanCheng_MJ", player.self_user.sex, "gang") + effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "杠") + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "杠") + -- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框") + end + effect.touchable = false + effect:GetTransition("t2"):Play() + -- pNode:AddChild(effect) + coroutine.start(function() + coroutine.wait(0.3) + self._popEvent = true + end) + coroutine.start(function() + coroutine.wait(2) + effect:Dispose() + end) + self:RemoveCursor() if (player.seat ~= fz.from_seat) then local fs_info = _player_card_info[self:GetPos(fz.from_seat)] fs_info:UpdateOutCardList() end + local seat = (self._room.room_config.people_num == 2 and fz.from_seat == 2) and 2 or fz.from_seat - 1 + info:UpdateFzList(fz, index, true, seat) - info:UpdateFzList(fz, index, true) - local getcard = fz.type == FZType.Peng or fz.type == FZType.Chi - --printlog(getcard) + --因为观战没有手牌,等预处理完扣牌数之后矫正一次(最粗暴的修正方式,手牌数等于13-3*吃碰数) - info._player.hand_left_count = info._player.hand_left_count - 1 + info._player.hand_left_count = 14 - 3 * #info._player.fz_list info:UpdateHandCardWitness(true) -- self:__CloseTip() end @@ -551,27 +623,6 @@ end -- end -- end -function M:OnUpdate() - if (self._popEvent) then - local func = self._gamectr:PopEvent() - if (func ~= nil) then - local success, result = pcall(func) - if success then - - else - print("witness error") - print(result) - error(result) - -- self._gamectr = ControllerManager.GetController(GameController) - -- if self._gamectr then - -- self._gamectr:ResetConnect() - -- end - end - --func() - end - end -end - function M:ResetConnect() end