2025-04-01 10:48:36 +08:00
|
|
|
|
local MJPlayerCardInfoView = import(".MJPlayerCardInfoView")
|
|
|
|
|
|
local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView")
|
|
|
|
|
|
local TableBG = require("Game.Data.TableBG")
|
|
|
|
|
|
local MJSettingView = import(".MJSettingViewNew")
|
|
|
|
|
|
local MJMainRightPanelView = import(".MJMainRightPanelView")
|
2025-06-16 15:24:27 +08:00
|
|
|
|
local MJCheckG = import('.MJCheckG')
|
2025-08-06 22:42:31 +08:00
|
|
|
|
local GameInfoWindow = import(".GameInfoWindow")
|
2025-08-13 14:06:30 +08:00
|
|
|
|
local HuCardImg = import(".HuCardImg")
|
2025-04-01 10:48:36 +08:00
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
local bg_config = {
|
|
|
|
|
|
{ id = 1, url = "base/main_majiang/bg/bg1", thumb = "ui://Main_Majiang/b01" },
|
|
|
|
|
|
{ id = 2, url = "base/main_majiang/bg/bg2", thumb = "ui://Main_Majiang/b02" },
|
|
|
|
|
|
{ id = 3, url = "base/main_majiang/bg/bg3", thumb = "ui://Main_Majiang/b03" }
|
2025-04-01 10:48:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
setmetatable(M, { __index = MainView })
|
2025-04-01 10:48:36 +08:00
|
|
|
|
|
2025-08-13 14:06:30 +08:00
|
|
|
|
M.HuCardImg = HuCardImg
|
|
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local default_bg = 1
|
2025-07-27 02:57:39 +08:00
|
|
|
|
|
|
|
|
|
|
local function IsRoomOwer()
|
|
|
|
|
|
--local roomOwner = self._room.player_list[1].self_user.account_id
|
|
|
|
|
|
local roomOwner = DataManager.CurrenRoom.player_list[1].self_user.account_id
|
|
|
|
|
|
return roomOwner == DataManager.SelfUser.account_id
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-06-10 19:28:53 +08:00
|
|
|
|
function M:InitView(url, use_custom_bg, custom_bg_config)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
-- 加载牌型数据
|
|
|
|
|
|
if not DataManager.CardTypeList then
|
|
|
|
|
|
local json_data = Utils.LoadLocalFile("CardTypeData")
|
|
|
|
|
|
if json_data then
|
|
|
|
|
|
DataManager.CardTypeList = json.decode(json_data)
|
|
|
|
|
|
else
|
|
|
|
|
|
DataManager.CardTypeList = {}
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
self._room.card_type = DataManager.CardTypeList[tostring(self._room.game_id)] or 1
|
|
|
|
|
|
|
|
|
|
|
|
UIPackage.AddPackage("base/main_majiang/ui/Main_Majiang")
|
2025-08-09 22:05:28 +08:00
|
|
|
|
self._full = false
|
|
|
|
|
|
self._scale = true
|
2025-04-02 19:03:26 +08:00
|
|
|
|
MainView.InitView(self, url)
|
2025-08-13 14:06:30 +08:00
|
|
|
|
|
|
|
|
|
|
self.list_otherHuEffect = self._view:GetChild("list_otherHuEffect")
|
|
|
|
|
|
self.list_HuEffect = self._view:GetChild("list_HuEffect")
|
|
|
|
|
|
self.loader_otherHuCardEffect = self._view:GetChild("loader_otherHuCardEffect")
|
|
|
|
|
|
self.loader_selfHuCardEffect = self._view:GetChild("loader_selfHuCardEffect")
|
|
|
|
|
|
self.cHuCardEffect = self._view:GetController("cHuCardEffect")
|
2025-09-08 14:39:21 +08:00
|
|
|
|
-- self.effect_ZiMo = self._view:GetChild("effect_ZiMo")
|
2025-09-16 21:35:09 +08:00
|
|
|
|
self._ctr_more = self._view:GetController("more")
|
2025-09-17 16:02:57 +08:00
|
|
|
|
self._view_clearingFather = self._view:GetChild('clearing_show')
|
2025-08-13 14:06:30 +08:00
|
|
|
|
|
2025-08-15 19:35:15 +08:00
|
|
|
|
self.com_notice = self._view:GetChild("com_notice")
|
|
|
|
|
|
|
2025-07-25 22:17:17 +08:00
|
|
|
|
self.btn_setting = self._view:GetChild("btn_setting")
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local _view = self._view
|
|
|
|
|
|
self._cursor = UIPackage.CreateObjectFromURL("ui://Main_Majiang/Ani_play_bj")
|
2025-06-10 19:28:53 +08:00
|
|
|
|
bg_config = custom_bg_config == nil and bg_config or custom_bg_config
|
2025-06-10 20:36:42 +08:00
|
|
|
|
if use_custom_bg then
|
2025-04-01 10:48:36 +08:00
|
|
|
|
TableBG.LoadTableBG(default_bg, self._room.game_id, self._root_view, bg_config)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local _room = self._room
|
|
|
|
|
|
|
|
|
|
|
|
local _cardbox = _view:GetChild("cardbox")
|
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
self._zhuanpanCtr = _cardbox:GetController("zuozi")
|
2025-05-08 12:41:42 +08:00
|
|
|
|
-- self._ctr_cardbox = _cardbox:GetController("c1")
|
|
|
|
|
|
-- self._tex_leftTime = _cardbox:GetChild("tex_leftnum")
|
2025-04-02 19:03:26 +08:00
|
|
|
|
|
2025-05-08 12:41:42 +08:00
|
|
|
|
local centerBox = _view:GetChild("Comp_ConterBox")
|
|
|
|
|
|
self._ctr_cardbox = centerBox:GetController("seat")
|
|
|
|
|
|
self._tex_leftTime = centerBox:GetChild("Text_Time")
|
2025-04-01 10:48:36 +08:00
|
|
|
|
|
2025-07-30 21:55:34 +08:00
|
|
|
|
self.com_logocType = _view:GetChild("com_logo"):GetController("cType")
|
|
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
|
if self._room.card_type == 2 then
|
|
|
|
|
|
self:Change3d(true)
|
|
|
|
|
|
else
|
|
|
|
|
|
self:Change3d(false)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local rightpanel = self._view:GetChild("com_roominfo")
|
2025-04-02 19:03:26 +08:00
|
|
|
|
if self._rightPanelView ~= nil then
|
2025-04-01 10:48:36 +08:00
|
|
|
|
self._rightPanelView:Destroy()
|
|
|
|
|
|
end
|
2025-04-02 19:03:26 +08:00
|
|
|
|
self._rightPanelView = MJMainRightPanelView.new(self, rightpanel)
|
|
|
|
|
|
|
|
|
|
|
|
--local tempdsaf=self._view:GetChild("btn_back_jiesan")
|
|
|
|
|
|
--tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false)
|
|
|
|
|
|
|
2025-04-11 12:49:08 +08:00
|
|
|
|
---- print("2222222222222222222222")
|
|
|
|
|
|
---- print(self._view:GetChild("btn_back_jiesan").displayObject.gameObject.name)
|
2025-04-02 19:03:26 +08:00
|
|
|
|
--self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false)
|
|
|
|
|
|
--local temp111=self._view:GetChild("btn_back_jiesan").displayObject.gameObject
|
|
|
|
|
|
--temp111:SetActive(false)
|
|
|
|
|
|
self._view:GetChild("btn_back_jiesan").onClick:Set(function()
|
2025-04-01 10:48:36 +08:00
|
|
|
|
if self.dismiss_room_cd_time > 0 then
|
|
|
|
|
|
ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!")
|
|
|
|
|
|
else
|
|
|
|
|
|
local _gamectr = ControllerManager.GetController(GameController)
|
|
|
|
|
|
_gamectr:AskDismissRoom()
|
|
|
|
|
|
end
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
self._tex_LeftCard = _view:GetChild("remaining_card")
|
2025-04-02 19:03:26 +08:00
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
|
self._player_card_info = {}
|
|
|
|
|
|
|
|
|
|
|
|
local _player_card_info = self._player_card_info
|
|
|
|
|
|
for i = 1, _room.room_config.people_num do
|
|
|
|
|
|
local tem = _view:GetChild("player_card_info" .. i)
|
2025-04-18 16:45:07 +08:00
|
|
|
|
print("====================================", "player_card_info" .. i, tem)
|
|
|
|
|
|
pt(_view)
|
2025-04-02 19:03:26 +08:00
|
|
|
|
_player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local list = _room.player_list
|
2025-04-02 19:03:26 +08:00
|
|
|
|
for i = 1, #list do
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local p = list[i]
|
|
|
|
|
|
local info = _player_card_info[self:GetPos(p.seat)]
|
|
|
|
|
|
info:SetPlayer(p)
|
|
|
|
|
|
info:FillData()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local list = _room.player_list
|
|
|
|
|
|
local readyNum = 0
|
2025-04-02 19:03:26 +08:00
|
|
|
|
for i = 1, #list do
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local p = list[i]
|
|
|
|
|
|
if p.ready then readyNum = readyNum + 1 end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
for i = 1, #_room.player_list do
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local p = _room.player_list[i]
|
2025-04-02 19:03:26 +08:00
|
|
|
|
local zi, icon = self:GetPosString(p.seat)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
if self._room.card_type == 2 then
|
2025-04-02 19:03:26 +08:00
|
|
|
|
_cardbox:GetChild("3d_direction" .. self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/" .. icon
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
2025-04-02 19:03:26 +08:00
|
|
|
|
|
|
|
|
|
|
_cardbox:GetChild("direction" .. self:GetIndex(self:GetPos(p.seat))).text = zi
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
self._ctr_action = _view:GetController("action")
|
2025-04-01 10:48:36 +08:00
|
|
|
|
if _room.banker_seat == _room.self_player.seat and readyNum == _room.room_config.people_num then
|
|
|
|
|
|
--self._ctr_action.selectedIndex = 2
|
|
|
|
|
|
elseif not _room.self_player.ready then
|
2025-04-02 19:03:26 +08:00
|
|
|
|
local round = DataManager.CurrenRoom.room_config.config.times or 1
|
|
|
|
|
|
local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai
|
|
|
|
|
|
if xpconfig then
|
|
|
|
|
|
if round > 1 then
|
|
|
|
|
|
self._ctr_action.selectedIndex = 1
|
|
|
|
|
|
else
|
|
|
|
|
|
self._ctr_action.selectedIndex = 2
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
self._ctr_action.selectedIndex = 1
|
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
else
|
|
|
|
|
|
self._ctr_action.selectedIndex = 0
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-06-09 16:30:22 +08:00
|
|
|
|
local changeTable = self._view:GetChild('btn_change')
|
|
|
|
|
|
if changeTable then
|
|
|
|
|
|
changeTable.onClick:Set(function()
|
|
|
|
|
|
default_bg = default_bg + 1 > #bg_config and 1 or default_bg + 1
|
|
|
|
|
|
TableBG.LoadTableBG(default_bg, self._room.game_id, self._root_view, bg_config)
|
|
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-06-16 15:24:27 +08:00
|
|
|
|
local checkG = self._view:GetChild('btn_check')
|
|
|
|
|
|
if checkG then
|
|
|
|
|
|
checkG.onClick:Set(function()
|
|
|
|
|
|
local checkG = MJCheckG.new()
|
|
|
|
|
|
checkG:Show()
|
|
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-06-25 22:49:44 +08:00
|
|
|
|
local viewList_witness = self._view:GetChild('comp_witness'):GetChild('list_players')
|
|
|
|
|
|
viewList_witness:SetVirtual()
|
|
|
|
|
|
viewList_witness.itemRenderer = function(index, obj)
|
|
|
|
|
|
obj:GetChild('title').text = _room.witness_player_list[index + 1].nick
|
|
|
|
|
|
ImageLoad.Load(_room.witness_player_list[index + 1].portrait, obj:GetChild('btn_head')._iconObject)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local btn_witness = self._view:GetChild('btn_pangGuang')
|
|
|
|
|
|
if btn_witness then
|
|
|
|
|
|
btn_witness.onClick:Set(function()
|
|
|
|
|
|
self._view:GetController('witness').selectedIndex = 1
|
|
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-07-18 17:59:24 +08:00
|
|
|
|
self._view:GetChild('btn_closeRoom').onClick:Set(function()
|
2025-07-27 02:57:39 +08:00
|
|
|
|
if IsRoomOwer() then
|
|
|
|
|
|
self._gamectr:AskDismissRoom(
|
|
|
|
|
|
function(res)
|
|
|
|
|
|
ViewUtil.CloseModalWait()
|
|
|
|
|
|
if res.ReturnCode == 0 then
|
|
|
|
|
|
ViewManager.ChangeView(ViewManager.View_Family)
|
|
|
|
|
|
else
|
|
|
|
|
|
ViewUtil.ErrorTip(res.ReturnCode)
|
|
|
|
|
|
end
|
|
|
|
|
|
end)
|
|
|
|
|
|
return
|
2025-07-18 17:59:24 +08:00
|
|
|
|
end
|
2025-07-27 02:57:39 +08:00
|
|
|
|
self._gamectr:LevelRoom(function(res)
|
|
|
|
|
|
if res.ReturnCode ~= 0 then
|
|
|
|
|
|
ViewUtil.ErrorTip(res.ReturnCode)
|
2025-07-18 17:59:24 +08:00
|
|
|
|
end
|
2025-07-27 02:57:39 +08:00
|
|
|
|
ViewManager.ChangeView(ViewManager.View_Family)
|
|
|
|
|
|
end)
|
2025-07-18 17:59:24 +08:00
|
|
|
|
end)
|
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
self:InitXiPai()
|
|
|
|
|
|
self:InitXiPai1()
|
2025-07-25 22:17:17 +08:00
|
|
|
|
|
2025-09-13 20:41:59 +08:00
|
|
|
|
self.btn_setting.onClick:Set(handler(self, self.ClickSetting))
|
2025-09-12 15:36:45 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:ClickSetting()
|
|
|
|
|
|
local view = MJSettingView.new(self)
|
|
|
|
|
|
view:Show()
|
2025-04-02 19:03:26 +08:00
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
|
|
|
|
|
|
function M:InitXiPai()
|
2025-04-02 19:03:26 +08:00
|
|
|
|
self._xipaiPanel = UIPackage.CreateObjectFromURL("ui://Common/panel_handanim")
|
|
|
|
|
|
self._xipaiPanel.visible = false
|
|
|
|
|
|
self._root_view:AddChild(self._xipaiPanel)
|
|
|
|
|
|
|
|
|
|
|
|
local offset = get_offset(self._full_offset)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
|
|
|
|
|
|
self._xipaiPanel.width = GRoot.inst.width - (offset * 2)
|
|
|
|
|
|
self._xipaiPanel.height = GRoot.inst.height
|
|
|
|
|
|
self._xipaiPanel.x = offset
|
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
self._handAnimCtr = self._xipaiPanel:GetController("anim")
|
|
|
|
|
|
self._handAnimCtr.selectedIndex = 0
|
|
|
|
|
|
--self:PlayXiPai()
|
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
|
|
|
|
|
|
function M:InitXiPai1()
|
2025-04-02 19:03:26 +08:00
|
|
|
|
self._xipaiPanel1 = UIPackage.CreateObjectFromURL("ui://Common/panel_handanim02")
|
|
|
|
|
|
self._xipaiPanel1.visible = false
|
|
|
|
|
|
self._root_view:AddChild(self._xipaiPanel1)
|
|
|
|
|
|
|
|
|
|
|
|
local offset = get_offset(self._full_offset)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
|
|
|
|
|
|
self._xipaiPanel1.width = GRoot.inst.width - (offset * 2)
|
|
|
|
|
|
self._xipaiPanel1.height = GRoot.inst.height
|
|
|
|
|
|
self._xipaiPanel1.x = offset
|
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
self._handAnimCtr1 = self._xipaiPanel1:GetController("anim1")
|
|
|
|
|
|
self._handAnimCtr1.selectedIndex = 0
|
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
|
|
|
|
|
|
function M:PlayXiPai(xipaiCallBack)
|
2025-04-02 19:03:26 +08:00
|
|
|
|
if self._xipaiPanel then
|
|
|
|
|
|
coroutine.start(function()
|
|
|
|
|
|
self._xipaiPanel.visible = true
|
|
|
|
|
|
self._xipaiPanel:GetTransition("XiPai"):Play()
|
|
|
|
|
|
self._handAnimCtr.selectedIndex = 1
|
|
|
|
|
|
coroutine.wait(3)
|
|
|
|
|
|
self._handAnimCtr.selectedIndex = 0
|
|
|
|
|
|
self._xipaiPanel.visible = false
|
|
|
|
|
|
if xipaiCallBack then
|
|
|
|
|
|
xipaiCallBack()
|
|
|
|
|
|
end
|
|
|
|
|
|
end)
|
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:PlayXiPai1(xipaiCallBack)
|
2025-04-02 19:03:26 +08:00
|
|
|
|
if self._xipaiPanel1 then
|
|
|
|
|
|
coroutine.start(function()
|
|
|
|
|
|
self._xipaiPanel1.visible = true
|
|
|
|
|
|
self._xipaiPanel1:GetTransition("XiPai"):Play()
|
|
|
|
|
|
self._handAnimCtr1.selectedIndex = 1
|
|
|
|
|
|
coroutine.wait(3)
|
|
|
|
|
|
self._handAnimCtr1.selectedIndex = 0
|
|
|
|
|
|
self._xipaiPanel1.visible = false
|
|
|
|
|
|
if xipaiCallBack then
|
|
|
|
|
|
xipaiCallBack()
|
|
|
|
|
|
end
|
|
|
|
|
|
end)
|
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:EventInit()
|
2025-04-02 19:03:26 +08:00
|
|
|
|
MainView.EventInit(self)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:Change3d(flag)
|
|
|
|
|
|
local _room = self._room
|
|
|
|
|
|
local _view = self._view
|
|
|
|
|
|
|
|
|
|
|
|
local _cardbox = _view:GetChild("cardbox")
|
2025-04-02 19:03:26 +08:00
|
|
|
|
|
|
|
|
|
|
for i = 1, #_room.player_list do
|
|
|
|
|
|
local p = _room.player_list[i]
|
|
|
|
|
|
local zi, icon = self:GetPosString(p.seat)
|
|
|
|
|
|
if self._room.card_type == 2 then
|
|
|
|
|
|
_cardbox:GetChild("3d_direction" .. self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/" .. icon
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
_cardbox:GetChild("direction" .. self:GetIndex(self:GetPos(p.seat))).text = zi
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
|
-- 如果要切换3d牌桌的cardbox位置及上方文字(剩余牌,回合数)显示不错乱,需要做以下改动
|
|
|
|
|
|
-- 取消文字组合的3d控制器的位置, 并设置对cardbox的关联,左左,顶顶
|
|
|
|
|
|
if flag == true then
|
|
|
|
|
|
if _view:GetController("3d") ~= nil then
|
|
|
|
|
|
_view:GetController("3d").selectedIndex = 1
|
|
|
|
|
|
_cardbox.x = (_view.width - _cardbox.width) * 0.5
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
_cardbox:GetController("3d").selectedIndex = 1
|
|
|
|
|
|
_cardbox.x = (_view.width - _cardbox.width) * 0.5
|
|
|
|
|
|
else
|
|
|
|
|
|
if _view:GetController("3d") ~= nil then
|
|
|
|
|
|
_view:GetController("3d").selectedIndex = 0
|
|
|
|
|
|
_cardbox.x = (_view.width - _cardbox.width) * 0.5
|
|
|
|
|
|
end
|
2025-04-02 19:03:26 +08:00
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
|
_cardbox:GetController("3d").selectedIndex = 0
|
|
|
|
|
|
_cardbox.x = (_view.width - _cardbox.width) * 0.5
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- function M:NewSettingView()
|
|
|
|
|
|
-- local settingView = MJSettingView.new(self._root_view)
|
|
|
|
|
|
-- settingView:FillBgSection(function(url)
|
|
|
|
|
|
-- LoadGameBg(url, self._root_view)
|
|
|
|
|
|
-- end, self._room.game_id, default_bg)
|
|
|
|
|
|
-- settingView.onChangeCardCallback:Add(function()
|
|
|
|
|
|
|
|
|
|
|
|
-- self:Change3d(DataManager.CurrenRoom.card_type == 2)
|
|
|
|
|
|
-- self:ReloadRoom()
|
2025-04-02 19:03:26 +08:00
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
|
-- for i = 1, #self._room.player_list do
|
|
|
|
|
|
-- local p = self._room.player_list[i]
|
|
|
|
|
|
-- local card_info = self._player_card_info[self:GetPos(p.seat)]
|
|
|
|
|
|
-- card_info:ResetCardType()
|
|
|
|
|
|
-- end
|
|
|
|
|
|
-- end)
|
|
|
|
|
|
|
|
|
|
|
|
-- settingView.onEXVoiceCallback:Add(function()
|
|
|
|
|
|
|
|
|
|
|
|
-- end)
|
|
|
|
|
|
-- settingView.onEXChuPaiCallback:Add(function()
|
|
|
|
|
|
|
|
|
|
|
|
-- end)
|
|
|
|
|
|
-- return settingView
|
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
|
|
|
|
function M:NewSettingView()
|
|
|
|
|
|
local settingView = MJSettingView.new(self._root_view)
|
|
|
|
|
|
-- settingView._view:GetChild("btn_card_1").icon = pack_full_name .. "com_card_preview"
|
|
|
|
|
|
-- local gear = settingView._view:GetChild("panel_bg"):GetGear(0)
|
|
|
|
|
|
-- gear.pages = {"0", "1", "2"}
|
|
|
|
|
|
-- gear:Apply()
|
|
|
|
|
|
-- settingView.Change3d = function() end
|
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
settingView:FillBgSection(function(url, index)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
LoadGameBg(url, self._root_view)
|
2025-04-02 19:03:26 +08:00
|
|
|
|
self._zhuanpanCtr.selectedIndex = index - 1
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end, self._room.game_id, 1, bg_config)
|
|
|
|
|
|
|
|
|
|
|
|
settingView.onChangeCardCallback:Add(function()
|
|
|
|
|
|
self:RemoveCursor()
|
|
|
|
|
|
for i = 1, #self._room.player_list do
|
|
|
|
|
|
local p = self._room.player_list[i]
|
|
|
|
|
|
local card_info = self._player_card_info[self:GetPos(p.seat)]
|
|
|
|
|
|
card_info:Clear(true)
|
|
|
|
|
|
card_info:ResetCardType()
|
|
|
|
|
|
end
|
|
|
|
|
|
self:Change3d(DataManager.CurrenRoom.card_type == 2)
|
|
|
|
|
|
self:ReloadRoom(true)
|
|
|
|
|
|
end)
|
|
|
|
|
|
return settingView
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:GetIndex(seat)
|
|
|
|
|
|
local index = seat
|
|
|
|
|
|
local people_num = self._room.room_config.people_num
|
|
|
|
|
|
if people_num == 2 and seat == 2 then
|
|
|
|
|
|
index = 3
|
|
|
|
|
|
elseif people_num == 3 and seat == 3 then
|
|
|
|
|
|
index = 4
|
|
|
|
|
|
end
|
|
|
|
|
|
return index
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:GetPosString(seat)
|
|
|
|
|
|
if DataManager.CurrenRoom.room_config.people_num == 4 then
|
|
|
|
|
|
if seat == 1 then
|
2025-04-02 19:03:26 +08:00
|
|
|
|
return "东", "dir_1"
|
2025-04-01 10:48:36 +08:00
|
|
|
|
elseif seat == 2 then
|
2025-04-02 19:03:26 +08:00
|
|
|
|
return "南", "dir_2"
|
|
|
|
|
|
elseif seat == 3 then
|
|
|
|
|
|
return "西", "dir_3"
|
2025-04-01 10:48:36 +08:00
|
|
|
|
elseif seat == 4 then
|
2025-04-02 19:03:26 +08:00
|
|
|
|
return "北", "dir_4"
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
elseif DataManager.CurrenRoom.room_config.people_num == 3 then
|
|
|
|
|
|
if seat == 1 then
|
2025-04-02 19:03:26 +08:00
|
|
|
|
return "东", "dir_1"
|
2025-04-01 10:48:36 +08:00
|
|
|
|
elseif seat == 2 then
|
2025-04-02 19:03:26 +08:00
|
|
|
|
return "南", "dir_2"
|
2025-04-01 10:48:36 +08:00
|
|
|
|
elseif seat == 3 then
|
2025-04-02 19:03:26 +08:00
|
|
|
|
return "西", "dir_3"
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
elseif DataManager.CurrenRoom.room_config.people_num == 2 then
|
|
|
|
|
|
if seat == 1 then
|
2025-04-02 19:03:26 +08:00
|
|
|
|
return "东", "dir_1"
|
2025-04-01 10:48:36 +08:00
|
|
|
|
elseif seat == 2 then
|
2025-04-02 19:03:26 +08:00
|
|
|
|
return "西", "dir_3"
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:SetCardBoxPosition()
|
|
|
|
|
|
local _room = self._room
|
|
|
|
|
|
for i = 1, _room.room_config.people_num do
|
2025-04-02 19:03:26 +08:00
|
|
|
|
local tex = self._view:GetChild("cardbox"):GetChild("direction" .. i)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local index = _room.self_player.seat + i - 1
|
|
|
|
|
|
index = index > 4 and index - 4 or index
|
|
|
|
|
|
tex.text = self._gamectr:GetPosString(index)
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:markOutCards(showTip, data)
|
|
|
|
|
|
for i = 1, #self._room.player_list do
|
|
|
|
|
|
local p = self._room.player_list[i]
|
|
|
|
|
|
local info = self._player_card_info[self:GetPos(p.seat)]
|
2025-09-16 21:35:09 +08:00
|
|
|
|
-- for j = 1, #p.outcard_list do
|
|
|
|
|
|
-- local card = p.outcard_list[j]
|
|
|
|
|
|
-- if card == data then
|
|
|
|
|
|
-- for k = 1, #p.outcard_list do
|
|
|
|
|
|
-- local obj = info:GetOutCardByIndex(k)
|
|
|
|
|
|
-- if obj.data == card then
|
|
|
|
|
|
-- obj:GetController("gray").selectedIndex = showTip and 1 or 0
|
|
|
|
|
|
-- end
|
|
|
|
|
|
-- end
|
|
|
|
|
|
-- end
|
|
|
|
|
|
-- end
|
|
|
|
|
|
for j = 1, info._view_outCardList.numItems do
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local card = p.outcard_list[j]
|
|
|
|
|
|
if card == data then
|
2025-09-16 21:35:09 +08:00
|
|
|
|
for k = 1, info._view_outCardList.numItems do
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local obj = info:GetOutCardByIndex(k)
|
|
|
|
|
|
if obj.data == card then
|
|
|
|
|
|
obj:GetController("gray").selectedIndex = showTip and 1 or 0
|
2025-04-02 19:03:26 +08:00
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:OnPlayerEnter(...)
|
2025-08-21 22:10:22 +08:00
|
|
|
|
self:PlayMJSound("user_enter.mp3")
|
2025-04-02 19:03:26 +08:00
|
|
|
|
MainView.OnPlayerEnter(self, ...)
|
|
|
|
|
|
local arg = { ... }
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local p = arg[1]
|
|
|
|
|
|
local info = self._player_card_info[self:GetPos(p.seat)]
|
|
|
|
|
|
info:SetPlayer(p)
|
|
|
|
|
|
info:FillData()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
function M:OnPlayerReady(...)
|
2025-08-21 22:10:22 +08:00
|
|
|
|
self:PlayMJSound("user_ready.mp3")
|
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
local arg = { ... }
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local p = arg[1]
|
|
|
|
|
|
local _room = self._room
|
|
|
|
|
|
local _view = self._view
|
2025-04-02 19:03:26 +08:00
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local _player_info = self._player_info
|
|
|
|
|
|
if p.seat == _room.self_player.seat then
|
|
|
|
|
|
self._ctr_action.selectedIndex = 0
|
|
|
|
|
|
if p.entrust and self._clearingView and self._clearingView.DestroyWithCallback then
|
|
|
|
|
|
self._clearingView:DestroyWithCallback()
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
local info = _player_info[self:GetPos(p.seat)]
|
|
|
|
|
|
info:Ready(true)
|
|
|
|
|
|
|
|
|
|
|
|
local readyNum = self:GetReadyNum()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if readyNum == _room.room_config.people_num then
|
|
|
|
|
|
local _cardbox = _view:GetChild("cardbox")
|
2025-04-02 19:03:26 +08:00
|
|
|
|
for i = 1, #_room.player_list do
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local p = _room.player_list[i]
|
2025-04-02 19:03:26 +08:00
|
|
|
|
local zi, icon = self:GetPosString(p.seat)
|
|
|
|
|
|
_cardbox:GetChild("3d_direction" .. self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/" .. icon
|
|
|
|
|
|
_cardbox:GetChild("direction" .. self:GetIndex(self:GetPos(p.seat))).text = zi
|
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
|
|
|
|
if _room.banker_seat == _room.self_player.seat and readyNum == _room.room_config.people_num then
|
|
|
|
|
|
if self._state.selectedIndex == 2 then
|
2025-04-02 19:03:26 +08:00
|
|
|
|
local _gamectr = ControllerManager.GetController(GameController)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
_gamectr:StartGame()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
--self._ctr_action.selectedIndex = 2
|
2025-04-01 10:48:36 +08:00
|
|
|
|
elseif not _room.self_player.ready then
|
2025-04-02 19:03:26 +08:00
|
|
|
|
--self._ctr_action.selectedIndex = 1
|
|
|
|
|
|
local round = DataManager.CurrenRoom.room_config.config.times or 1
|
|
|
|
|
|
local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai
|
|
|
|
|
|
if xpconfig then
|
|
|
|
|
|
if round > 1 then
|
|
|
|
|
|
self._ctr_action.selectedIndex = 1
|
|
|
|
|
|
else
|
|
|
|
|
|
self._ctr_action.selectedIndex = 2
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
2025-09-17 16:02:57 +08:00
|
|
|
|
--江西这边没有洗牌,暂时把这个洗牌相关的准备注释了
|
|
|
|
|
|
-- self._ctr_action.selectedIndex = 1
|
2025-04-02 19:03:26 +08:00
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
else
|
2025-04-02 19:03:26 +08:00
|
|
|
|
self._ctr_action.selectedIndex = 0
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-09-02 16:23:32 +08:00
|
|
|
|
function M:OnPlayerWitnessEnter(...)
|
|
|
|
|
|
self:PlayMJSound("user_enter.mp3")
|
|
|
|
|
|
local arg = { ... }
|
|
|
|
|
|
local witnessPlayerList = arg[1]
|
|
|
|
|
|
self._room.witness_player_list = witnessPlayerList
|
|
|
|
|
|
|
|
|
|
|
|
local _room = DataManager.CurrenRoom
|
|
|
|
|
|
local viewList_witness = self._view:GetChild('comp_witness'):GetChild('list_players')
|
|
|
|
|
|
print("linemng", _room._flag_updateWitness, #_room.witness_player_list, viewList_witness.numItems)
|
2025-09-09 16:55:41 +08:00
|
|
|
|
if viewList_witness.numItems == #_room.witness_player_list then
|
|
|
|
|
|
viewList_witness:RefreshVirtualList()
|
|
|
|
|
|
else
|
|
|
|
|
|
viewList_witness.numItems = #_room.witness_player_list
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:OnPlayerWitnessLeave(...)
|
|
|
|
|
|
---- print("刷新托管数据=====")
|
|
|
|
|
|
local arg = { ... }
|
|
|
|
|
|
local player = arg[1]
|
|
|
|
|
|
local witnessPlayerList = self._room.witness_player_list
|
|
|
|
|
|
for i, _player in ipairs(witnessPlayerList) do
|
|
|
|
|
|
if _player.aid == player then
|
|
|
|
|
|
table.remove(witnessPlayerList, i)
|
|
|
|
|
|
break
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local _room = DataManager.CurrenRoom
|
|
|
|
|
|
local viewList_witness = self._view:GetChild('comp_witness'):GetChild('list_players')
|
|
|
|
|
|
print("linemng", _room._flag_updateWitness, #_room.witness_player_list, viewList_witness.numItems)
|
2025-09-02 16:23:32 +08:00
|
|
|
|
if viewList_witness.numItems == #_room.witness_player_list then
|
|
|
|
|
|
viewList_witness:RefreshVirtualList()
|
|
|
|
|
|
else
|
|
|
|
|
|
viewList_witness.numItems = #_room.witness_player_list
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
|
function M:CountCardLeftNum(card)
|
|
|
|
|
|
local player_list = DataManager.CurrenRoom.player_list
|
|
|
|
|
|
local count = 4
|
|
|
|
|
|
for i = 1, #player_list do
|
|
|
|
|
|
local p = player_list[i]
|
|
|
|
|
|
if p.card_list then
|
|
|
|
|
|
for j = 1, #p.card_list do
|
|
|
|
|
|
if p.card_list[j] == card then
|
|
|
|
|
|
count = count - 1
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
for j = 1, #p.outcard_list do
|
|
|
|
|
|
if p.outcard_list[j] == card then
|
|
|
|
|
|
count = count - 1
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
for j = 1, #p.fz_list do
|
|
|
|
|
|
local fz = p.fz_list[j]
|
|
|
|
|
|
if fz.type == FZType.Chi then
|
|
|
|
|
|
for k = 1, #fz.opcard do
|
|
|
|
|
|
if card == fz.opcard[k] then
|
|
|
|
|
|
count = count - 1
|
|
|
|
|
|
break
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
else
|
|
|
|
|
|
local num = fz.type == FZType.Peng and 3 or 4
|
|
|
|
|
|
if card == fz.card then
|
|
|
|
|
|
count = count - num
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
return count
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
function M:OnPlayerLeave(...)
|
2025-08-21 22:10:22 +08:00
|
|
|
|
self:PlayMJSound("user_leave.mp3")
|
2025-04-01 10:48:36 +08:00
|
|
|
|
MainView.OnPlayerLeave(self, ...)
|
|
|
|
|
|
local _room = self._room
|
|
|
|
|
|
if _room.banker_seat == _room.self_player.seat then
|
2025-04-02 19:03:26 +08:00
|
|
|
|
self._ctr_action.selectedIndex = 0
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:PlayerChangeLineState()
|
2025-04-02 19:03:26 +08:00
|
|
|
|
local isOutCard = true
|
|
|
|
|
|
local str = "玩家 "
|
|
|
|
|
|
for _, player in ipairs(self._room.player_list) do
|
|
|
|
|
|
if player.line_state == 0 then
|
|
|
|
|
|
isOutCard = false
|
|
|
|
|
|
-- str = str .. self._gamectr:GetPosString(player.seat) .. "、"
|
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
2025-04-02 19:03:26 +08:00
|
|
|
|
-- if not isOutCard then
|
|
|
|
|
|
-- str = str.sub(str, 1, string.len(str) - string.len("、"))
|
|
|
|
|
|
-- str = str .. " 正在赶来,请稍等"
|
|
|
|
|
|
-- if self._room.curren_round > 0 then
|
|
|
|
|
|
-- self._waitingView = ModalWaitingView.new(self._view, str)
|
|
|
|
|
|
-- end
|
|
|
|
|
|
-- else
|
|
|
|
|
|
-- if self._waitingView then
|
|
|
|
|
|
-- self._waitingView:CloseWaitingView()
|
|
|
|
|
|
-- end
|
|
|
|
|
|
-- end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
self._player_card_info[1]._area_handcard_list.touchable = isOutCard
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
function M:NewMJPlayerCardInfoView(view, index)
|
2025-08-19 22:17:52 +08:00
|
|
|
|
local infoView = {}
|
|
|
|
|
|
if self._room.room_config.people_num == 2 then
|
|
|
|
|
|
if index == 1 then
|
|
|
|
|
|
infoView = MJPlayerSelfCardInfoView.new(view, self, nil, "S")
|
|
|
|
|
|
elseif index == 2 then
|
|
|
|
|
|
infoView = MJPlayerCardInfoView.new(view, self, nil, "N")
|
|
|
|
|
|
end
|
|
|
|
|
|
elseif self._room.room_config.people_num == 3 then
|
|
|
|
|
|
if index == 1 then
|
|
|
|
|
|
infoView = MJPlayerSelfCardInfoView.new(view, self, nil, "S")
|
|
|
|
|
|
elseif index == 2 then
|
|
|
|
|
|
infoView = MJPlayerCardInfoView.new(view, self, nil, "E")
|
|
|
|
|
|
elseif index == 3 then
|
|
|
|
|
|
infoView = MJPlayerCardInfoView.new(view, self, nil, "N")
|
|
|
|
|
|
end
|
|
|
|
|
|
elseif self._room.room_config.people_num == 4 then
|
|
|
|
|
|
if index == 1 then
|
|
|
|
|
|
infoView = MJPlayerSelfCardInfoView.new(view, self, nil, "S")
|
|
|
|
|
|
elseif index == 2 then
|
|
|
|
|
|
infoView = MJPlayerCardInfoView.new(view, self, nil, "E")
|
|
|
|
|
|
elseif index == 3 then
|
|
|
|
|
|
infoView = MJPlayerCardInfoView.new(view, self, nil, "N")
|
|
|
|
|
|
elseif index == 4 then
|
|
|
|
|
|
infoView = MJPlayerCardInfoView.new(view, self, nil, "W")
|
|
|
|
|
|
end
|
2025-04-02 19:03:26 +08:00
|
|
|
|
end
|
2025-08-19 22:17:52 +08:00
|
|
|
|
return infoView
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:RemoveCursor()
|
2025-06-10 19:49:18 +08:00
|
|
|
|
-- if self._cursor.parent then
|
|
|
|
|
|
-- self._cursor.parent:GetController("color").selectedIndex = 0
|
|
|
|
|
|
-- end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
self._cursor:RemoveFromParent()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:Destroy()
|
|
|
|
|
|
UIPackage.RemovePackage("base/main_majiang/ui/Main_Majiang")
|
|
|
|
|
|
MainView.Destroy(self)
|
|
|
|
|
|
self._cursor:Dispose()
|
2025-04-02 19:03:26 +08:00
|
|
|
|
self._xipaiPanel:Dispose()
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local majiang_asset_path = "base/main_majiang/sound/"
|
|
|
|
|
|
function M:PlayMJSound(path)
|
|
|
|
|
|
ViewUtil.PlaySound(self.asset_group, majiang_asset_path .. path)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:PlayMJMusic(path)
|
|
|
|
|
|
ViewUtil.PlayMuisc(self.asset_group, majiang_asset_path .. path)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
function M:PlaySound(group, sex, path)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
local sex_path = ViewUtil.Sex_Chat[sex]
|
2025-04-02 19:03:26 +08:00
|
|
|
|
local path1 = majiang_asset_path .. string.format("%s/%s.mp3", sex_path, path)
|
|
|
|
|
|
ViewUtil.PlaySound(group, path1)
|
2025-04-01 10:48:36 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:GetPrefix()
|
|
|
|
|
|
return get_majiang_prefix(DataManager.CurrenRoom.game_id)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-07-18 16:28:57 +08:00
|
|
|
|
-- 所有对家显示手牌
|
|
|
|
|
|
function M:ShowHand(msg)
|
2025-07-18 16:46:03 +08:00
|
|
|
|
local data = msg[1]
|
2025-07-18 17:59:24 +08:00
|
|
|
|
|
|
|
|
|
|
for _, player in pairs(data.info_list) do
|
|
|
|
|
|
local infoView = self._player_card_info[self:GetPos(player.seat)]
|
|
|
|
|
|
|
2025-07-18 16:46:03 +08:00
|
|
|
|
if infoView.class ~= "PlayerSelfCardInfoView" then
|
2025-08-21 18:35:26 +08:00
|
|
|
|
printlog("ShowHand", player.seat)
|
2025-09-02 16:23:32 +08:00
|
|
|
|
table.sort(player.hand_card, self.HandCardSortAndJing)
|
2025-09-03 16:52:14 +08:00
|
|
|
|
infoView:ShowHand(player.hand_card, self:GetPos(player.seat) == 1)
|
2025-07-18 16:46:03 +08:00
|
|
|
|
end
|
2025-07-18 16:28:57 +08:00
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-08-04 19:20:35 +08:00
|
|
|
|
function M:OnResult1(...)
|
|
|
|
|
|
local _room = self._room
|
|
|
|
|
|
self._popEvent = false
|
|
|
|
|
|
self:__CloseTip()
|
|
|
|
|
|
self._left_time = 0
|
|
|
|
|
|
self:UpdateCardBox(0)
|
|
|
|
|
|
self._ctr_cardbox.selectedIndex = 0
|
|
|
|
|
|
local arg = { ... }
|
|
|
|
|
|
self:ShowHand(arg)
|
|
|
|
|
|
local result = arg[1]
|
|
|
|
|
|
local liuju = result.liuju
|
|
|
|
|
|
local data = result.info_list
|
|
|
|
|
|
local niao = result.niao
|
2025-09-08 14:39:21 +08:00
|
|
|
|
-- self:RemoveCursor()
|
2025-09-17 16:02:57 +08:00
|
|
|
|
self._clearingView = self.EXClearingViewClass.new(self)
|
2025-08-04 19:20:35 +08:00
|
|
|
|
coroutine.start(function()
|
2025-09-16 21:35:09 +08:00
|
|
|
|
if liuju then
|
|
|
|
|
|
self:PlayMJSound("liuju.mp3")
|
2025-09-17 16:02:57 +08:00
|
|
|
|
coroutine.wait(3)
|
2025-09-16 21:35:09 +08:00
|
|
|
|
self:PlayMJSound("end_music.mp3")
|
|
|
|
|
|
else
|
|
|
|
|
|
self:PlayMJSound("end_music.mp3")
|
|
|
|
|
|
end
|
2025-08-04 19:20:35 +08:00
|
|
|
|
coroutine.wait(0.5)
|
|
|
|
|
|
self._clearingView:Show()
|
|
|
|
|
|
self._popEvent = true
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
if _room.curren_round ~= _room.room_config.round then
|
|
|
|
|
|
-- if #niao == 0 then self._view:GetChild("n13").visible = false end
|
|
|
|
|
|
self._clearingView:InitData(0, _room, result, nil, function(...)
|
|
|
|
|
|
for i = 1, #data do
|
|
|
|
|
|
local p = _room:GetPlayerBySeat(data[i].seat)
|
|
|
|
|
|
p.total_score = data[i].total_score
|
|
|
|
|
|
local card_info = self._player_card_info[self:GetPos(p.seat)]
|
|
|
|
|
|
local info = self._player_info[self:GetPos(p.seat)]
|
2025-08-19 22:17:52 +08:00
|
|
|
|
--card_info:Clear()
|
2025-08-04 19:20:35 +08:00
|
|
|
|
card_info:ResetCardType()
|
|
|
|
|
|
if _room:checkHpNonnegative() then
|
|
|
|
|
|
p.cur_hp = data[i].total_score
|
|
|
|
|
|
end
|
2025-08-15 15:01:35 +08:00
|
|
|
|
info:UpdateScore()
|
2025-08-04 19:20:35 +08:00
|
|
|
|
info._view:GetChild("zhanji").visible = true
|
|
|
|
|
|
local num = data[i].total_score
|
|
|
|
|
|
if num >= 0 then
|
|
|
|
|
|
info._view:GetController("text_color").selectedIndex = 0
|
|
|
|
|
|
info._view:GetChild("text_jifen").text = "+" .. num
|
|
|
|
|
|
else
|
|
|
|
|
|
info._view:GetController("text_color").selectedIndex = 1
|
|
|
|
|
|
info._view:GetChild("text_jifen").text = num
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
info._view:GetChild("mask_piao").title = ""
|
|
|
|
|
|
info._view:GetController("piao_niao").selectedIndex = 0
|
|
|
|
|
|
p.fz_list = {}
|
|
|
|
|
|
end
|
|
|
|
|
|
DataManager.CurrenRoom.self_player.card_list = {}
|
2025-08-19 22:17:52 +08:00
|
|
|
|
--self._state.selectedIndex = 2
|
2025-08-04 19:20:35 +08:00
|
|
|
|
self._clearingView = nil
|
|
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-08-13 14:06:30 +08:00
|
|
|
|
function M:OnHuCard(...)
|
|
|
|
|
|
self._left_time = 0
|
|
|
|
|
|
self:UpdateCardBox(0)
|
|
|
|
|
|
self:__CloseTip()
|
|
|
|
|
|
self._popEvent = false
|
|
|
|
|
|
local arg = { ... }
|
|
|
|
|
|
local win_seat = arg[1]
|
|
|
|
|
|
local lose_seat = arg[2]
|
|
|
|
|
|
local win_card = arg[3]
|
|
|
|
|
|
local cards = arg[4]
|
|
|
|
|
|
local win_list = arg[5]
|
2025-08-15 15:40:31 +08:00
|
|
|
|
local scoreData = arg[6]
|
2025-08-13 14:06:30 +08:00
|
|
|
|
local index = self:GetPos(win_seat)
|
|
|
|
|
|
local info = self._player_card_info[index]
|
|
|
|
|
|
local player = self._room:GetPlayerBySeat(win_seat)
|
2025-09-08 14:39:21 +08:00
|
|
|
|
-- self:RemoveCursor()
|
2025-08-13 14:06:30 +08:00
|
|
|
|
--info:UpdateHandCard(false, false)
|
2025-09-03 16:52:14 +08:00
|
|
|
|
info:ShowHuCard(win_card, index == 1)
|
2025-08-13 14:06:30 +08:00
|
|
|
|
|
|
|
|
|
|
self.cHuCardEffect.selectedIndex = 1
|
|
|
|
|
|
|
2025-09-01 20:15:53 +08:00
|
|
|
|
local loader_HuEffect = info._viewLoader_selfHuCardEffect
|
|
|
|
|
|
-- local list_HuCardEffect = nil
|
|
|
|
|
|
local list_HuCardEffect = info._viewList_HuEffect
|
|
|
|
|
|
--不走main麻将的,直接读各自的胡牌区域
|
|
|
|
|
|
-- if win_seat == self._room.self_player.seat then
|
|
|
|
|
|
-- loader_HuEffect = self.loader_selfHuCardEffect
|
|
|
|
|
|
-- -- list_HuCardEffect = self.list_HuEffect
|
|
|
|
|
|
-- else
|
|
|
|
|
|
-- loader_HuEffect = self.loader_otherHuCardEffect
|
|
|
|
|
|
-- -- list_HuCardEffect = self.list_otherHuEffect
|
|
|
|
|
|
-- end
|
2025-08-13 14:06:30 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
local isZiMo = win_seat == lose_seat
|
|
|
|
|
|
DataManager.CurrenRoom.isZiMoHu = isZiMo
|
|
|
|
|
|
local hu_sound = isZiMo and ("zimo") or ("hu")
|
|
|
|
|
|
printlog("声音====>>>", hu_sound)
|
|
|
|
|
|
self:PlaySound(self.asset_group, player.self_user.sex, hu_sound)
|
|
|
|
|
|
|
|
|
|
|
|
local effects = isZiMo and ("tile_zimo") or ("tile_hu")
|
|
|
|
|
|
loader_HuEffect.visible = true
|
|
|
|
|
|
loader_HuEffect.url = "ui://Main_Majiang/" .. effects
|
|
|
|
|
|
loader_HuEffect:SetScale(2, 2)
|
|
|
|
|
|
loader_HuEffect:TweenScale(Vector2(1, 1), 0.3):SetEase(EaseType.QuartOut)
|
|
|
|
|
|
|
2025-09-08 14:39:21 +08:00
|
|
|
|
self.effect_ZiMo = info._viewClip_effect_ZiMo
|
2025-08-13 14:06:30 +08:00
|
|
|
|
self.effect_ZiMo:SetPlaySettings(0, -1, 1, -1);
|
|
|
|
|
|
self.effect_ZiMo.visible = true
|
|
|
|
|
|
self.effect_ZiMo.playing = true
|
|
|
|
|
|
self.effect_ZiMo.onPlayEnd:Set(function()
|
|
|
|
|
|
self.effect_ZiMo.visible = false
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
coroutine.start(function()
|
2025-09-01 16:18:56 +08:00
|
|
|
|
coroutine.wait(0.5)
|
2025-08-13 14:06:30 +08:00
|
|
|
|
|
|
|
|
|
|
loader_HuEffect.visible = false
|
|
|
|
|
|
local Effects = {}
|
2025-09-16 21:35:09 +08:00
|
|
|
|
--先循环一遍把杠上开花放在最前面
|
|
|
|
|
|
for i = 1, #win_list do
|
|
|
|
|
|
local HuMsg = win_list[i]
|
2025-09-17 19:51:05 +08:00
|
|
|
|
if HuMsg.type > 2 and HuMsg.type < 60 then
|
2025-09-16 21:35:09 +08:00
|
|
|
|
if self.HuCardImg[HuMsg.type][1] == "tile_cs_gangshanghua" then
|
|
|
|
|
|
local imgPath = "ui://Main_Majiang/tile_cs_gangshanghua"
|
|
|
|
|
|
local imgObj = list_HuCardEffect:AddItemFromPool()
|
|
|
|
|
|
local imgLoader = imgObj:GetChild("loader_img")
|
|
|
|
|
|
imgLoader.url = imgPath
|
|
|
|
|
|
imgObj.visible = false
|
|
|
|
|
|
Effects[#Effects + 1] = imgObj
|
|
|
|
|
|
table.remove(win_list, i)
|
|
|
|
|
|
break
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-08-13 14:06:30 +08:00
|
|
|
|
for i = 1, #win_list do
|
|
|
|
|
|
local HuMsg = win_list[i]
|
|
|
|
|
|
|
|
|
|
|
|
-- ↓↓↓先排列好特效图片
|
2025-09-17 19:51:05 +08:00
|
|
|
|
if HuMsg.type > 2 and HuMsg.type < 60 then
|
2025-08-13 14:06:30 +08:00
|
|
|
|
local sound_name = string.format(self.Sound_path .. "%s/%s.mp3",
|
|
|
|
|
|
ViewUtil.Sex_Chat[player.self_user.sex],
|
|
|
|
|
|
"he" .. HuMsg.type)
|
|
|
|
|
|
ViewUtil.PlaySound(self.asset_group, sound_name)
|
|
|
|
|
|
|
|
|
|
|
|
local imgList = self.HuCardImg[HuMsg.type]
|
|
|
|
|
|
for _, img in pairs(imgList) do
|
|
|
|
|
|
local imgPath = "ui://Main_Majiang/" .. img
|
|
|
|
|
|
local imgObj = list_HuCardEffect:AddItemFromPool()
|
|
|
|
|
|
local imgLoader = imgObj:GetChild("loader_img")
|
|
|
|
|
|
imgLoader.url = imgPath
|
|
|
|
|
|
imgObj.visible = false
|
|
|
|
|
|
Effects[#Effects + 1] = imgObj
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
-- ↓↓↓播放动画
|
|
|
|
|
|
for _, imgObj in pairs(Effects) do
|
|
|
|
|
|
imgObj.visible = true
|
|
|
|
|
|
|
|
|
|
|
|
local effect_xingxing = imgObj:GetChild("effect_xingxing")
|
|
|
|
|
|
effect_xingxing:SetPlaySettings(0, -1, 1, -1);
|
|
|
|
|
|
effect_xingxing.visible = true
|
|
|
|
|
|
effect_xingxing.playing = true
|
|
|
|
|
|
effect_xingxing.onPlayEnd:Set(function()
|
|
|
|
|
|
effect_xingxing.visible = false
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
local imgLoader = imgObj:GetChild("loader_img")
|
|
|
|
|
|
imgLoader:SetScale(2, 2)
|
|
|
|
|
|
imgLoader:Center()
|
|
|
|
|
|
imgLoader:TweenScale(Vector2(1, 1), 0.3)
|
2025-09-01 20:15:53 +08:00
|
|
|
|
coroutine.wait(0.5)
|
2025-08-13 14:06:30 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2025-08-15 15:40:31 +08:00
|
|
|
|
-- 扣分动画
|
2025-08-19 22:17:52 +08:00
|
|
|
|
for _, pScore in pairs(scoreData) do
|
|
|
|
|
|
local infoView = self._player_info[self:GetPos(pScore.seat)]
|
|
|
|
|
|
infoView:UpdateScore(pScore.total_score, true)
|
2025-08-15 15:40:31 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2025-08-13 14:06:30 +08:00
|
|
|
|
coroutine.wait(0.5)
|
|
|
|
|
|
self._popEvent = true
|
|
|
|
|
|
list_HuCardEffect:RemoveChildrenToPool()
|
|
|
|
|
|
|
|
|
|
|
|
self.cHuCardEffect.selectedIndex = 0
|
|
|
|
|
|
end)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-09-13 20:41:59 +08:00
|
|
|
|
function M:OnFangziAction(...)
|
|
|
|
|
|
self:__CloseTip()
|
|
|
|
|
|
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 loader_HuEffect = info._viewClip_Peng_Gang
|
|
|
|
|
|
local effects = ""
|
|
|
|
|
|
if fz.type == FZType.Peng then
|
2025-09-16 21:35:09 +08:00
|
|
|
|
self:PlaySound("Main_Majiang", player.self_user.sex, "peng")
|
2025-09-13 20:41:59 +08:00
|
|
|
|
effects = "clip_peng"
|
|
|
|
|
|
elseif fz.type == FZType.Chi then
|
|
|
|
|
|
|
|
|
|
|
|
else
|
2025-09-16 21:35:09 +08:00
|
|
|
|
self:PlaySound("Main_Majiang", player.self_user.sex, "gang")
|
2025-09-13 20:41:59 +08:00
|
|
|
|
effects = "clip_gang"
|
|
|
|
|
|
end
|
|
|
|
|
|
local clip = UIPackage.CreateObjectFromURL(string.format("ui://Main_Majiang/%s", effects))
|
|
|
|
|
|
clip:SetSize(loader_HuEffect.width, loader_HuEffect.height)
|
|
|
|
|
|
loader_HuEffect:AddChild(clip)
|
|
|
|
|
|
clip:SetPlaySettings(0, -1, 1, -1)
|
|
|
|
|
|
clip.onPlayEnd:Add(function()
|
|
|
|
|
|
if clip.parent then
|
|
|
|
|
|
clip.parent:RemoveChild(clip)
|
|
|
|
|
|
end
|
|
|
|
|
|
clip:Dispose()
|
|
|
|
|
|
end)
|
|
|
|
|
|
clip.playing = true
|
|
|
|
|
|
coroutine.start(function()
|
|
|
|
|
|
coroutine.wait(0.3)
|
|
|
|
|
|
self._popEvent = true
|
|
|
|
|
|
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)
|
|
|
|
|
|
local getcard = fz.type == FZType.Peng or fz.type == FZType.Chi
|
|
|
|
|
|
printlog(getcard)
|
|
|
|
|
|
info:UpdateHandCard(getcard)
|
|
|
|
|
|
self:__CloseTip()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-09-01 20:15:53 +08:00
|
|
|
|
function M:ShowJing()
|
|
|
|
|
|
if self._room.jing then
|
|
|
|
|
|
self.jing.visible = true
|
2025-09-03 18:22:12 +08:00
|
|
|
|
MJPlayerCardInfoView.fillCard2(self, self.jing, "b202_", self._room.jing)
|
2025-09-01 20:15:53 +08:00
|
|
|
|
else
|
|
|
|
|
|
self.jing.visible = false
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-08-06 20:21:46 +08:00
|
|
|
|
function M:Show()
|
|
|
|
|
|
MainView.Show(self)
|
2025-08-23 22:23:17 +08:00
|
|
|
|
if self._room and self._room.curren_round == 0 and self._flag_showTip then
|
2025-08-21 18:35:26 +08:00
|
|
|
|
local win = GameInfoWindow.New()
|
|
|
|
|
|
win:Show(self._room)
|
|
|
|
|
|
end
|
2025-09-18 13:32:05 +08:00
|
|
|
|
self:PlayMJSound("game_backmusic.mp3")
|
2025-08-15 19:35:15 +08:00
|
|
|
|
self:DoNoticeAnimation()
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
function M:DoNoticeAnimation()
|
|
|
|
|
|
self.noticeIndex = self.noticeIndex or 1
|
|
|
|
|
|
if not DataManager.GameNotice or #DataManager.GameNotice == 0 then
|
|
|
|
|
|
return
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local text_notice = self.com_notice:GetChild("text_notice")
|
|
|
|
|
|
text_notice.text = DataManager.GameNotice[self.noticeIndex]
|
|
|
|
|
|
local speed = 44
|
|
|
|
|
|
local time = text_notice.width / speed
|
|
|
|
|
|
|
|
|
|
|
|
text_notice.x = self.com_notice.width
|
|
|
|
|
|
|
|
|
|
|
|
local tween = text_notice:TweenMove(Vector2(-text_notice.width, text_notice.y), time):OnComplete(function()
|
|
|
|
|
|
self:DoNoticeAnimation()
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
|
|
tween:SetEase(EaseType.Linear)
|
|
|
|
|
|
|
|
|
|
|
|
self.noticeIndex = self.noticeIndex + 1
|
|
|
|
|
|
if self.noticeIndex > #DataManager.GameNotice then
|
|
|
|
|
|
self.noticeIndex = 1
|
|
|
|
|
|
end
|
2025-08-06 20:21:46 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
2025-09-02 16:23:32 +08:00
|
|
|
|
function M.HandCardSortAndJing(a, b)
|
|
|
|
|
|
local jing = DataManager.CurrenRoom.jing
|
|
|
|
|
|
if a == jing or b == jing then
|
|
|
|
|
|
if a == b then
|
|
|
|
|
|
return a < b
|
|
|
|
|
|
end
|
|
|
|
|
|
return a == jing
|
|
|
|
|
|
else
|
|
|
|
|
|
if a < 200 then
|
|
|
|
|
|
a = a + 1000
|
|
|
|
|
|
elseif a < 300 then
|
|
|
|
|
|
a = a + 3000
|
|
|
|
|
|
elseif a < 400 then
|
|
|
|
|
|
a = a + 2000
|
|
|
|
|
|
else
|
|
|
|
|
|
a = a + 4000
|
|
|
|
|
|
end
|
|
|
|
|
|
if b < 200 then
|
|
|
|
|
|
b = b + 1000
|
|
|
|
|
|
elseif b < 300 then
|
|
|
|
|
|
b = b + 3000
|
|
|
|
|
|
elseif b < 400 then
|
|
|
|
|
|
b = b + 2000
|
|
|
|
|
|
else
|
|
|
|
|
|
b = b + 4000
|
|
|
|
|
|
end
|
|
|
|
|
|
return a < b
|
|
|
|
|
|
end
|
|
|
|
|
|
end
|
|
|
|
|
|
|
2025-04-02 19:03:26 +08:00
|
|
|
|
return M
|