2025-09-08 14:39:21 +08:00
|
|
|
local WitnessView = require("Game.View.WitnessView")
|
|
|
|
|
local TableBG = require("Game.Data.TableBG")
|
2025-09-09 20:56:32 +08:00
|
|
|
local HuCardImg = import(".HuCardImg")
|
2025-09-10 20:32:26 +08:00
|
|
|
local MJSettingView = require("main.majiang.MJSettingViewNew")
|
2025-09-11 16:43:36 +08:00
|
|
|
local TX_GameEvent = import(".TX_GameEvent")
|
2025-09-08 14:39:21 +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" },
|
|
|
|
|
{ id = 3, url = "base/main_majiang/bg/bg4", thumb = "ui://Main_Majiang/b04" }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
setmetatable(M, { __index = WitnessView })
|
2025-09-09 20:56:32 +08:00
|
|
|
M.HuCardImg = HuCardImg
|
2025-09-08 14:39:21 +08:00
|
|
|
--- Create a new
|
|
|
|
|
function M.new()
|
|
|
|
|
local self = setmetatable({}, { __index = M })
|
|
|
|
|
self.class = "MJMJWitness"
|
|
|
|
|
self:init()
|
|
|
|
|
|
|
|
|
|
return self
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:init()
|
|
|
|
|
getmetatable(M).__index.init(self)
|
|
|
|
|
|
|
|
|
|
UIPackage.AddPackage("base/main_majiang/ui/Main_Majiang")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:InitView()
|
|
|
|
|
local room = self._room
|
|
|
|
|
|
|
|
|
|
UIPackage.AddPackage("base/main_majiang/ui/Main_Majiang")
|
|
|
|
|
getmetatable(M).__index.InitView(self,
|
|
|
|
|
string.format("ui://Main_Majiang/Main_new_%d_jiangxi", room.room_config.people_num))
|
|
|
|
|
|
|
|
|
|
--切换桌布功能
|
|
|
|
|
local default_bg = 1
|
|
|
|
|
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
|
|
|
|
|
TableBG.LoadTableBG(default_bg, self._room.game_id, self._root_view, bg_config)
|
2025-09-10 20:32:26 +08:00
|
|
|
|
|
|
|
|
self.btn_setting = self._view:GetChild("btn_setting")
|
2025-09-12 15:36:45 +08:00
|
|
|
self.btn_setting.onClick:Set(handler(self,self.ClickSetting))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:ClickSetting()
|
|
|
|
|
local view = MJSettingView.new(self, true)
|
|
|
|
|
view:Show()
|
2025-09-08 14:39:21 +08:00
|
|
|
end
|
|
|
|
|
|
2025-09-09 20:56:32 +08:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
function M:PlaySound(group, sex, path)
|
|
|
|
|
local sex_path = ViewUtil.Sex_Chat[sex]
|
|
|
|
|
local path1 = majiang_asset_path .. string.format("%s/%s.mp3", sex_path, path)
|
|
|
|
|
ViewUtil.PlaySound(group, path1)
|
|
|
|
|
end
|
|
|
|
|
|
2025-09-11 16:43:36 +08:00
|
|
|
function M:EventInit()
|
2025-09-11 21:11:49 +08:00
|
|
|
getmetatable(M).__index.EventInit(self)
|
2025-09-11 16:43:36 +08:00
|
|
|
local _gamectr = self._gamectr
|
|
|
|
|
local _room = self._room
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.SendCards, function(...)
|
|
|
|
|
self:ShowJing()
|
|
|
|
|
if self._clearingView then
|
|
|
|
|
self._clearingView:Destroy()
|
|
|
|
|
self._clearingView = nil
|
|
|
|
|
end
|
|
|
|
|
self:UpdateRound()
|
|
|
|
|
self:RemoveCursor()
|
|
|
|
|
self._state.selectedIndex = 4
|
|
|
|
|
local list = _room.player_list
|
|
|
|
|
for i = 1, #list do
|
|
|
|
|
local p = list[i]
|
|
|
|
|
local info = self._player_info[self:GetPos(p.seat)]
|
|
|
|
|
info:FillData(p)
|
|
|
|
|
info:MarkBank(p.seat == _room.banker_seat)
|
|
|
|
|
info:Ready(false)
|
|
|
|
|
local card_info = self._player_card_info[self:GetPos(p.seat)]
|
|
|
|
|
card_info:Clear()
|
|
|
|
|
card_info:UpdateHandCardWitness()
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...)
|
|
|
|
|
local arg = { ... }
|
2025-09-11 21:11:49 +08:00
|
|
|
if not self._left_time or self._left_time <= 15 then
|
|
|
|
|
self._left_time = 15
|
|
|
|
|
end
|
2025-09-11 16:43:36 +08:00
|
|
|
local seat = arg[1]
|
|
|
|
|
self:UpdateCardBox(self:GetPos(seat))
|
|
|
|
|
local info = self._player_card_info[self:GetPos(seat)]
|
|
|
|
|
info._player.hand_left_count = info._player.hand_left_count + 1
|
|
|
|
|
info:UpdateHandCardWitness(true)
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
|
|
_gamectr:AddEventListener(TX_GameEvent.OutCard, function(...)
|
|
|
|
|
local arg = { ... }
|
|
|
|
|
local p = arg[1]
|
|
|
|
|
local card = arg[2]
|
|
|
|
|
local seat = p.seat
|
|
|
|
|
local info = self._player_card_info[self:GetPos(seat)]
|
|
|
|
|
|
|
|
|
|
self:RemoveCursor()
|
|
|
|
|
|
|
|
|
|
info:UpdateHandCardWitness(false)
|
|
|
|
|
|
|
|
|
|
info:UpdateOutCardList(nil, nil, self._cursor)
|
|
|
|
|
self:PlayMJSound("chupai.mp3")
|
|
|
|
|
self:PlaySound("LiChuan_MJ", p.self_user.sex, tostring(card))
|
|
|
|
|
if seat == _room.self_player.seat then
|
|
|
|
|
_room.curren_outcard_seat = -1
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
end
|
|
|
|
|
|
2025-09-08 14:39:21 +08:00
|
|
|
return M
|