hengyang_client/lua_probject/extend_project/extend/majiang/chaoshan/EXMainView.lua

770 lines
26 KiB
Lua
Raw Normal View History

2025-04-01 10:48:36 +08:00
local MJPlayerSelfCardInfoView = import(".MJPlayerSelfCardInfoView")
local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView")
local MJMainView = require("main.majiang.MJMainView")
local EXClearingView = import(".EXClearingView")
local TX_GameEvent = import(".GameEvent")
local HuTipView = import("main.majiang.HuTipView")
local SettingView = import("main.majiang.MJSettingViewNew")
local PlayerInfoView = import(".EXPlayerInfoView")
local M = {}
--- Create a new ZZ_MainView
function M.new()
2025-04-11 12:49:08 +08:00
setmetatable(M, { __index = MJMainView })
local self = setmetatable({}, { __index = M })
2025-04-01 10:48:36 +08:00
self.class = "MainView"
self.asset_group = "ChaoShan_MJ"
self:init()
ViewUtil.PlayMuisc(self.asset_group, "extend/majiang/chaoshan/sound/bg.mp3")
return self
end
function M:InitView(url)
local room = self._room
self._style = 1
self._gps_style = 1
self._full = true
UIPackage.AddPackage("extend/majiang/chaoshan/ui/Extend_MJ_ChaoShan")
2025-04-11 12:49:08 +08:00
MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2")
2025-04-01 10:48:36 +08:00
self._hu_tip = HuTipView.new(self)
2025-04-11 12:49:08 +08:00
self._view:GetChild('wanfa_text').text = room.room_config.people_num .. '人潮汕 ' .. room.score_times .. ''
self.LaiziBG = self._view:GetChild('n103')
self.LaiziBG.text = "鬼牌"
self.LaiziBG.visible = false
self.selectLaiziBtn = self._view:GetChild('selectlaizi')
self.Laizi1Btn = self._view:GetChild('selectlaizi1')
self.Laizi2Btn = self._view:GetChild('selectlaizi2')
self.Laizi1Btn.visible = false
self.Laizi2Btn.visible = false
self.selectLaiziBtn.visible = false
self:SetReconnentLaiziTips()
self:PlayerChangeLineState()
if room.playing or room.curren_round > 0 then
2025-04-01 10:48:36 +08:00
self:ReloadRoom()
end
end
function M:SetReconnentLaiziTips()
2025-04-11 12:49:08 +08:00
local room = DataManager.CurrenRoom
if room.beforelaiziCardId and room.beforelaiziCardId > 0 then
self:SetShowLaiZiProcess(room.beforelaiziCardId, room.laiziInfo[1], room.laiziInfo[2], false)
end
2025-04-01 10:48:36 +08:00
end
2025-04-11 12:49:08 +08:00
function M:SetLaiZiCard(btn, cardId)
btn.icon = 'ui://Main_Majiang/' .. get_majiang_prefix(DataManager.CurrenRoom.game_id) .. "201_" .. cardId
2025-04-01 10:48:36 +08:00
end
2025-04-11 12:49:08 +08:00
function M:IsShowLaiZi(btn, isShow)
btn.visible = isShow
2025-04-01 10:48:36 +08:00
end
function M:HideAllLaiZiCard()
2025-04-11 12:49:08 +08:00
self.Laizi1Btn.visible = false
self.Laizi2Btn.visible = false
self.selectLaiziBtn.visible = false
self.LaiziBG.visible = false
2025-04-01 10:48:36 +08:00
end
2025-04-11 12:49:08 +08:00
function M:SetShowLaiZiProcess(beforeLaiziID, currentLaizi1ID, currentLaizi2ID, isShowAnim)
--zhongid=currentLaizi1ID
if isShowAnim == nil then isShowAnim = false end
printlog("当前赋值结果为====>>>")
-- print(beforeLaiziID)
-- print(currentLaizi1ID)
-- print(currentLaizi2ID)
self:HideAllLaiZiCard()
self:SetLaiZiCard(self.selectLaiziBtn, beforeLaiziID)
self:SetLaiZiCard(self.Laizi1Btn, currentLaizi1ID)
if currentLaizi2ID then
self:SetLaiZiCard(self.Laizi2Btn, currentLaizi2ID)
end
2025-04-01 10:48:36 +08:00
2025-04-11 12:49:08 +08:00
if isShowAnim == true then
self:IsShowLaiZi(self.selectLaiziBtn, true)
coroutine.start(
function()
coroutine.wait(1)
self:HideAllLaiZiCard()
self.LaiziBG.visible = true
self:IsShowLaiZi(self.Laizi1Btn, true)
if currentLaizi2ID then
self:IsShowLaiZi(self.Laizi2Btn, true)
end
end
)
else
self.LaiziBG.visible = true
self:IsShowLaiZi(self.Laizi1Btn, true)
if currentLaizi2ID then
self:IsShowLaiZi(self.Laizi2Btn, true)
end
end
self.LaiziBG.visible = true
end
2025-04-01 10:48:36 +08:00
function M:UpdateRound()
self._view:GetChild("tex_round1").text = self._room.curren_round
self._view:GetChild("tex_round2").text = self._room.room_config.round
end
function M:InitPlayerInfoView()
2025-04-11 12:49:08 +08:00
self._player_info = {}
2025-04-01 10:48:36 +08:00
local _player_info = self._player_info
for i = 1, self._room.room_config.people_num do
local tem = self._view:GetChild("player_info" .. i)
2025-04-11 12:49:08 +08:00
_player_info[i] = PlayerInfoView.new(tem, self)
2025-04-01 10:48:36 +08:00
tem.visible = false
end
end
2025-04-11 12:49:08 +08:00
function M:NewMJPlayerCardInfoView(view, index)
if index == 1 then
return MJPlayerSelfCardInfoView.new(view, self)
2025-04-01 10:48:36 +08:00
end
2025-04-11 12:49:08 +08:00
return MJPlayerCardInfoView.new(view, self)
2025-04-01 10:48:36 +08:00
end
function M:EventInit()
2025-04-11 12:49:08 +08:00
-- UIPackage.AddPackage("extend/majiang/hongzhong/ui/Extend_MJ_HongZhong")
MainView.EventInit(self)
2025-04-01 10:48:36 +08:00
local _room = self._room
local _view = self._view
local _gcm_outcard_url = UIPackage.GetItemURL("Main_Majiang", "Gcm_OutCard")
local _player_info = self._player_info
2025-04-11 12:49:08 +08:00
local _gamectr = self._gamectr
2025-04-01 10:48:36 +08:00
2025-04-11 12:49:08 +08:00
_gamectr:AddEventListener(TX_GameEvent.SendLaiZi, function(...)
local arg = { ... }
self:SetShowLaiZiProcess(arg[1], arg[2], arg[3], arg[4])
2025-04-01 10:48:36 +08:00
end)
2025-04-11 12:49:08 +08:00
_gamectr:AddEventListener(TX_GameEvent.SendCards, function(...)
2025-04-01 10:48:36 +08:00
-- self:ShowHuTip()
self:UpdateRound()
self._state.selectedIndex = 1
local list = _room.player_list
2025-04-11 12:49:08 +08:00
for i = 1, #list do
2025-04-01 10:48:36 +08:00
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)]
2025-04-11 12:49:08 +08:00
card_info:UpdateHandCard()
2025-04-01 10:48:36 +08:00
end
end)
2025-04-11 12:49:08 +08:00
_gamectr:AddEventListener(TX_GameEvent.EventTurn, function(...)
local arg = { ... }
2025-04-01 10:48:36 +08:00
self._left_time = 15
local seat = arg[1]
self:UpdateCardBox(self:GetPos(seat))
-- if seat == self._room.self_player.seat then
-- self:ShowHuTip()
-- end
end)
_gamectr:AddEventListener(TX_GameEvent.OutHint, function(...)
local info = self._player_card_info[self:GetPos(_room.self_player.seat)]
info:UpdateHandCard(true)
end)
2025-04-11 12:49:08 +08:00
local _gcm_outcard_url = "ui://Main_Majiang/Gcm_OutCard"
2025-04-01 10:48:36 +08:00
_gamectr:AddEventListener(TX_GameEvent.OutCard, function(...)
self:__CloseTip()
self._left_time = 0
2025-04-11 12:49:08 +08:00
local arg = { ... }
2025-04-01 10:48:36 +08:00
local p = arg[1]
local card = arg[2]
local seat = p.seat
local info = self._player_card_info[self:GetPos(seat)]
self:RemoveCursor()
info:UpdateHandCard()
local outcard = UIPackage.CreateObjectFromURL(_gcm_outcard_url)
info:UpdateOutCardList(outcard, card, self._cursor)
self:PlaySound("ChaoShan_MJ", p.self_user.sex, tostring(card))
self:PlayMJSound("chupai.mp3")
if seat == _room.self_player.seat then
_room.curren_outcard_seat = -1
end
end)
_gamectr:AddEventListener(TX_GameEvent.GetCard, function(...)
self:__CloseTip()
2025-04-11 12:49:08 +08:00
local arg = { ... }
2025-04-01 10:48:36 +08:00
local seat = arg[1]
local card = arg[2]
-- self._tex_leftTime.text = arg[3]
self._tex_LeftCard.text = arg[3]
-- self:UpdateRoomInfo()
local info = self._player_card_info[self:GetPos(seat)]
info:UpdateHandCard(true)
end)
_gamectr:AddEventListener(TX_GameEvent.FZTips, function(...)
2025-04-11 12:49:08 +08:00
local arg = { ... }
2025-04-01 10:48:36 +08:00
local _tip = arg[1]
local weight = arg[2]
self:__FangziTip(_tip, weight)
end)
2025-04-11 12:49:08 +08:00
_gamectr:AddEventListener(TX_GameEvent.FangziAction, handler(self, self.OnFangziAction))
2025-04-01 10:48:36 +08:00
_gamectr:AddEventListener(TX_GameEvent.ZPHuCard, function(...)
self._left_time = 0
self:UpdateCardBox(0)
self:__CloseTip()
self._popEvent = false
2025-04-11 12:49:08 +08:00
local arg = { ... }
2025-04-01 10:48:36 +08:00
local win_seat = arg[1]
2025-04-11 12:49:08 +08:00
local lose_seat = arg[2]
local win_card = arg[3]
local cards = arg[4]
local win_list = arg[5]
local index = self:GetPos(win_seat)
local info = self._player_card_info[index]
2025-04-01 10:48:36 +08:00
self:RemoveCursor()
info:UpdateHandCard(true, true)
local obj_win_card = UIPackage.CreateObjectFromURL("ui://Main_Majiang/Btn_Card")
obj_win_card.icon = "ui://Main_Majiang/202_" .. win_card
obj_win_card:GetController("bg").selectedIndex = 1
info._view:AddChild(obj_win_card)
obj_win_card:Center()
local url, pNode
local player = _room:GetPlayerBySeat(win_seat)
if win_seat ~= _room.self_player.seat then
url = "ui://Main_Majiang/别人胡"
pNode = info._mask_liangpai
elseif win_seat == _room.self_player.seat then
url = "ui://Main_Majiang/自己胡牌"
pNode = self._view
end
if win_seat == lose_seat then
url = "ui://Main_Majiang/eff_zimo"
end
2025-04-11 12:49:08 +08:00
2025-04-01 10:48:36 +08:00
local he = UIPackage.CreateObjectFromURL(url)
pNode:AddChild(he)
he:GetTransition("t2"):Play()
2025-04-11 12:49:08 +08:00
he:Center()
if _room.room_config.people_num == 2 then
if win_seat ~= _room.self_player.seat then
he.scaleY = 0.4
he.scaleX = 0.4
he.x = he.width * 0.4 * 0.5 * -1
he.y = he.height * 0.4 * 0.5 * -1
end
end
if win_seat == _room.self_player.seat then
printlog("自己位置=====")
he:Center()
2025-04-01 10:48:36 +08:00
elseif url == "ui://Main_Majiang/eff_zimo" then
2025-04-11 12:49:08 +08:00
printlog("自摸地址==========")
2025-04-01 10:48:36 +08:00
he.scaleY = 0.4
he.scaleX = 0.4
he.x = he.width * 0.4 * 0.5 * -1
he.y = he.height * 0.4 * 0.5 * -1
end
2025-04-11 12:49:08 +08:00
---
local isZiMo = win_seat == lose_seat
DataManager.CurrenRoom.isZiMoHu = isZiMo
local hu_sound = isZiMo and ("zimo" .. math.random(1, 3)) or ("hu" .. math.random(1, 2))
printlog("声音====>>>", hu_sound)
self:PlaySound("ChaoShan_MJ", player.self_user.sex, hu_sound)
local pNode = info._view
local url = "eff_list1"
2025-04-01 10:48:36 +08:00
local he_list = UIPackage.CreateObjectFromURL("ui://Extend_MJ_ChaoShan/" .. url)
he_list.touchable = false
pNode:AddChild(he_list)
he_list:Center()
2025-04-11 12:49:08 +08:00
2025-04-01 10:48:36 +08:00
coroutine.start(function()
2025-04-11 12:49:08 +08:00
for i = 1, #win_list do
local tem = win_list[i]
if tem.type > 0 and tem.type < 32 then
local com_name = "he" .. tem.type
local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_ChaoShan/" .. com_name)
coroutine.wait(0.3)
end
end
coroutine.wait(2)
obj_win_card:Dispose()
he:Dispose()
he_list:Dispose()
self._popEvent = true
2025-04-01 10:48:36 +08:00
end)
end)
_gamectr:AddEventListener(TX_GameEvent.EventNiao, function(...)
2025-04-11 12:49:08 +08:00
local arg = { ... }
2025-04-01 10:48:36 +08:00
self._popEvent = false
local list = arg[1]
local start_seat = arg[2]
2025-04-11 12:49:08 +08:00
-- ViewUtil.PlaySound("ChaoShan_MJ", "extend/majiang/chaoshan/sound/zhuaniao.mp3")
coroutine.start(self.RunNiao, self, list, start_seat)
2025-04-01 10:48:36 +08:00
end)
_gamectr:AddEventListener(TX_GameEvent.ZPResult1, function(...)
self._popEvent = false
self:__CloseTip()
self._left_time = 0
self:UpdateCardBox(0)
self._ctr_cardbox.selectedIndex = 0
2025-04-11 12:49:08 +08:00
local arg = { ... }
2025-04-01 10:48:36 +08:00
local result = arg[1]
local liuju = result.liuju
local data = result.info_list
local niao = result.niao
if liuju then
local le = UIPackage.CreateObjectFromURL("ui://Main_Majiang/LiuJu")
self._view:AddChild(le)
le:Center()
le:GetTransition("t0"):Play()
coroutine.start(function()
coroutine.wait(1)
le:Dispose()
end)
end
self:RemoveCursor()
if self._clearingView == nil then
self._clearingView = EXClearingView.new(self._root_view)
2025-04-11 12:49:08 +08:00
coroutine.start(function()
2025-04-01 10:48:36 +08:00
coroutine.wait(0.5)
self._clearingView:Show()
self._popEvent = true
2025-04-11 12:49:08 +08:00
end)
2025-04-01 10:48:36 +08:00
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)]
card_info:Clear()
card_info:ResetCardType()
if _room:checkHpNonnegative() then
p.cur_hp = data[i].hp_info.cur_hp
end
info:UpdateScore()
info._view:GetChild("zhanji").visible = true
2025-04-11 12:49:08 +08:00
local num = data[i].hp_info.total_hp
2025-04-01 10:48:36 +08:00
if num > 0 then
info._view:GetController("text_color").selectedIndex = 0
info._view:GetChild("text_jifen").text = "+" .. d2ad(num)
else
info._view:GetController("text_color").selectedIndex = 1
info._view:GetChild("text_jifen").text = d2ad(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 = {}
self._state.selectedIndex = 2
self._clearingView = nil
end)
end
2025-04-11 12:49:08 +08:00
self._player_card_info[1]:ShowHuTip()
2025-04-01 10:48:36 +08:00
end)
_gamectr:AddEventListener(TX_GameEvent.ZPResult2, function(...)
self:UnmarkSelfTuoguan()
self._left_time = 0
self:UpdateCardBox(0)
self._ctr_cardbox.selectedIndex = 0
2025-04-11 12:49:08 +08:00
local arg = { ... }
2025-04-01 10:48:36 +08:00
local total_result = arg[2]
local result = arg[1]
local over = arg[3]
self._clearingView = EXClearingView.new()
coroutine.start(function()
coroutine.wait(0.5)
self._clearingView:Show()
2025-04-11 12:49:08 +08:00
end)
2025-04-01 10:48:36 +08:00
self._clearingView:InitData(over, _room, result, total_result)
ControllerManager.ChangeController(LoddyController)
end)
_gamectr:AddEventListener(TX_GameEvent.EvnetPiaoTip, function()
self:UpdateRound()
self._tex_LeftCard.text = "0"
2025-04-11 12:49:08 +08:00
self._state.selectedIndex = 1
2025-04-01 10:48:36 +08:00
self:__PiaoNiaoTip()
end)
_gamectr:AddEventListener(TX_GameEvent.EvnetPiao, function(...)
2025-04-11 12:49:08 +08:00
local arg = { ... }
2025-04-01 10:48:36 +08:00
local seat = arg[1]
local num = arg[2]
if num > 0 then
local head_info = self._player_info[self:GetPos(seat)]
head_info._view:GetChild("mask_piao").title = "飘分 " .. num
head_info._view:GetController("piao_niao").selectedIndex = 1
2025-04-11 12:49:08 +08:00
end
2025-04-01 10:48:36 +08:00
if seat == _room.self_player.seat then
2025-04-11 12:49:08 +08:00
if self._com_piao and _room.self_player.entrust then
2025-04-01 10:48:36 +08:00
self._com_piao:Dispose()
self._com_piao = nil
_room.curren_round = _room.curren_round - 1
end
end
end)
end
function M:OutCard(card)
if card ~= 0 then
2025-04-11 12:49:08 +08:00
printlog("当前出牌为===>>>" .. card)
2025-04-01 10:48:36 +08:00
local _gamectr = ControllerManager.GetController(GameController)
self._room.curren_outcard_seat = -1
_gamectr:SendOutCard(card, function()
2025-04-11 12:49:08 +08:00
local info = self._player_card_info[1]
self:RemoveCursor()
info:UpdateHandCard()
info:UpdateOutCardList(nil, card, self._cursor)
self:PlaySound("ChaoShan_MJ", self._room.self_player.self_user.sex, tostring(card))
self:PlayMJSound("chupai.mp3")
-- self:ShowHuTip()
end)
else
printlog("鬼牌不能出===>>>" .. card)
2025-04-01 10:48:36 +08:00
end
end
function M:__FangziTip(tip, weight)
local _gamectr = self._gamectr
local _chipeng_tip = UIPackage.CreateObject("Main_Majiang", "Gcm_action_tips")
_chipeng_tip:GetController("hide_bg").selectedIndex = 1
self._chipeng_tip = _chipeng_tip
local p = self._room.self_player
-- self._player_card_info[self:GetPos(p.seat)]
local _lit_fanzi = _chipeng_tip:GetChild("lit_fanzi")
_lit_fanzi:RemoveChildrenToPool()
local _tlist = table.keys(tip.tip_map_type)
local tip_hu = false
local count = #_tlist
2025-04-11 12:49:08 +08:00
for k = 1, #_tlist do
2025-04-01 10:48:36 +08:00
local td = tip.tip_map_type[_tlist[k]][1]
local url = "ui://Main_Majiang/Btn_fztip"
local td_weight = td.weight
if td_weight == 16 then td_weight = 8 end
if td_weight == 8 then url = "ui://Main_Majiang/Btn_hu" end
local btn_t = _lit_fanzi:AddItemFromPool(url)
2025-04-11 12:49:08 +08:00
btn_t.icon = "ui://Main_Majiang/fztip_" .. td_weight
2025-04-01 10:48:36 +08:00
btn_t.data = { tip, td }
2025-04-11 12:49:08 +08:00
btn_t.onClick:Add(self.__TipAction, self)
2025-04-01 10:48:36 +08:00
end
-- if not (tonumber(weight) >= 16) then
2025-04-11 12:49:08 +08:00
local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass")
-- local _btn_pass = _chipeng_tip:GetChild("btn_pass")
_btn_pass.onClick:Set(function()
if tonumber(weight) >= 8 then
local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel)
guo_msg.onOk:Add(function()
2025-04-01 10:48:36 +08:00
_gamectr:SendAction(0)
_chipeng_tip:Dispose()
self._chipeng_tip = nil
2025-04-11 12:49:08 +08:00
guo_msg:Close()
end)
guo_msg:Show()
else
_gamectr:SendAction(0)
_chipeng_tip:Dispose()
self._chipeng_tip = nil
end
end)
2025-04-01 10:48:36 +08:00
-- end
self._view:AddChild(_chipeng_tip)
_chipeng_tip:Center()
end
function M:__TipAction(context)
local data = context.sender.data
local _gamectr = self._gamectr
local tip = data[1]
local td = data[2]
local list = tip.tip_map_type[td.weight]
if (#list > 1) then
self:_ChiView(list, function(id)
_gamectr:SendAction(id)
self:__CloseTip()
end)
self._chipeng_tip.visible = false
return
end
_gamectr:SendAction(td.id)
if (self._chipeng_tip == nil) then return end
self._chipeng_tip:Dispose()
self._chipeng_tip = nil
end
function M:_ChiView(tiplist, callback)
self._chipeng_tip.visible = false
local _pop_tip_choice = UIPackage.CreateObject("Main_Majiang", "Pop_tip_choice")
local list_choose = _pop_tip_choice:GetChild("Lst_choose")
local crossCtr = _pop_tip_choice:GetController("state")
crossCtr.selectedIndex = #tiplist == 3 and 0 or 1
_pop_tip_choice:GetChild("Btn_cross").onClick:Add(function()
_pop_tip_choice:Dispose()
self._chipeng_tip.visible = true
end)
list_choose:RemoveChildrenToPool()
for i = 1, #tiplist do
local item_choose = list_choose:AddItemFromPool()
item_choose:GetController("type").selectedIndex = 0
for j = 1, 4 do
2025-04-11 12:49:08 +08:00
item_choose:GetChild("card" .. j).icon = UIPackage.GetItemURL("Main_Majiang", "202_" .. tiplist[i].card)
2025-04-01 10:48:36 +08:00
end
item_choose.onClick:Add(function()
callback(tiplist[i].id)
end)
end
2025-04-11 12:49:08 +08:00
_pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width) / 2,
(self._view.height - _pop_tip_choice.height) / 2)
2025-04-01 10:48:36 +08:00
self._view:AddChild(_pop_tip_choice)
self._pop_tip_choice = _pop_tip_choice
end
function M:OnFangziAction(...)
self:__CloseTip()
2025-04-11 12:49:08 +08:00
local arg = { ... }
2025-04-01 10:48:36 +08:00
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_ChaoShan", "FzEffect")
if fz.type == FZType.Peng then
2025-04-11 12:49:08 +08:00
self:PlaySound("ChaoShan_MJ", player.self_user.sex, "peng" .. math.random(1, 3))
2025-04-01 10:48:36 +08:00
effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "")
effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "")
-- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "碰框")
else
2025-04-11 12:49:08 +08:00
self:PlaySound("ChaoShan_MJ", player.self_user.sex, "gang" .. math.random(1, 2))
2025-04-01 10:48:36 +08:00
effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", "")
2025-04-11 12:49:08 +08:00
effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", "")
-- effect:GetChild("kuang").icon = UIPackage.GetItemURL("Main_Majiang", "杠框")
2025-04-01 10:48:36 +08:00
end
effect.touchable = false
effect:GetTransition("t2"):Play()
pNode:AddChild(effect)
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
info:UpdateFzList(fz, index, true)
local getcard = fz.type == FZType.Peng or fz.type == FZType.Chi
info:UpdateHandCard(getcard)
self:__CloseTip()
end
function M:RunNiao(list, start_seat)
local _room = self._room
--local _niao_View = self._niao_View
2025-04-11 12:49:08 +08:00
self._niao_View = UIPackage.CreateObject("Extend_MJ_ChaoShan", "Panel_Birds")
2025-04-01 10:48:36 +08:00
self._view:AddChild(self._niao_View)
self._niao_View:Center()
local _niao_View = self._niao_View
local list_niao_card = self._niao_View:GetChild("Lst_birds")
list_niao_card:RemoveChildrenToPool()
2025-04-11 12:49:08 +08:00
for i = 1, #list do
2025-04-01 10:48:36 +08:00
--添加背面的麻將
local item = list_niao_card:AddItemFromPool()
item.icon = UIPackage.GetItemURL("Main_Majiang", "202_00")
item:GetChild("tex_score").text = "+" .. list[i].score
end
for i = 1, #list do
--顯示正面
local item = list_niao_card:GetChildAt(i - 1)
local card = list[i].card
coroutine.wait(0.3)
item:GetTransition("appear"):Play()
2025-04-11 12:49:08 +08:00
item.icon = UIPackage.GetItemURL("Main_Majiang", "201_" .. card)
2025-04-01 10:48:36 +08:00
if list[i].score > 0 then item:GetController("bg").selectedIndex = 1 end
end
coroutine.start(function()
coroutine.wait(2)
_niao_View:Dispose()
self._popEvent = true
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)]
-- for j = 1, #p.outcard_list do
-- local card = p.outcard_list[j]
-- if card == data then
-- local obj = info:GetOutCardByIndex(j)
-- obj:GetController("gray").selectedIndex = showTip and 1 or 0
-- end
-- end
-- end
-- end
function M:__PiaoNiaoTip()
2025-04-11 12:49:08 +08:00
local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao")
self._view:AddChild(obj_piao)
obj_piao.x = (self._view.width - obj_piao.width) * 0.5
obj_piao.y = self._view.height * 0.6
for i = 1, 4 do
obj_piao:GetChild("btn_" .. i).onClick:Add(function()
self._gamectr:SendAction(i - 1)
obj_piao:Dispose()
end)
end
self._com_piao = obj_piao
2025-04-01 10:48:36 +08:00
end
function M:ReloadRoom(bskip)
local room = self._room
-- if not room.playing then
-- self._state.selectedIndex = 2
-- else
-- self._state.selectedIndex = 1
-- self._room._reload_flag = true
-- end
if bskip == nil or bskip == false then
2025-04-11 12:49:08 +08:00
if not room.playing then
self._state.selectedIndex = 2
else
self._state.selectedIndex = 1
self._room._reload_flag = true
end
2025-04-01 10:48:36 +08:00
end
2025-04-11 12:49:08 +08:00
2025-04-01 10:48:36 +08:00
for i = 1, #room.player_list do
local p = room.player_list[i]
local info = self._player_card_info[self:GetPos(p.seat)]
for i = 1, #p.fz_list do
info:UpdateFzList(p.fz_list[i], -1)
end
2025-04-11 12:49:08 +08:00
info:UpdateHandCard()
2025-04-01 10:48:36 +08:00
local head_info = self._player_info[self:GetPos(p.seat)]
head_info:UpdateScore()
head_info._view:GetChild('zhanji').visible = true
2025-04-11 12:49:08 +08:00
local num = p.total_hp or 0
if num > 0 then
head_info._view:GetController('text_color').selectedIndex = 0
head_info._view:GetChild('text_jifen').text = "+" .. d2ad(num)
else
head_info._view:GetController('text_color').selectedIndex = 1
head_info._view:GetChild('text_jifen').text = d2ad(num)
end
2025-04-01 10:48:36 +08:00
if p.seat == room.last_outcard_seat then
local card = p.outcard_list[#p.outcard_list]
2025-04-11 12:49:08 +08:00
info:UpdateOutCardList(nil, card, self._cursor)
2025-04-01 10:48:36 +08:00
elseif p.seat == room.curren_outcard_seat then
info:UpdateHandCard(true)
info:UpdateOutCardList()
else
info:UpdateOutCardList()
end
if p.seat == room.banker_seat then
head_info:MarkBank(true)
end
-- if p.ready then
-- self._player_info[self:GetPos(p.seat)]:Ready(true)
-- end
if bskip == nil or bskip == false then
2025-04-11 12:49:08 +08:00
if p.ready and room.playing == false then
self._player_info[self:GetPos(p.seat)]:Ready(true)
end
end
if p.piao_niao ~= nil and p.piao_niao > 0 then
2025-04-01 10:48:36 +08:00
local head_info = self._player_info[self:GetPos(p.seat)]
head_info._view:GetChild("mask_piao").title = "飘分 " .. p.piao_niao
head_info._view:GetController("piao_niao").selectedIndex = 1
end
end
-- self:ShowHuTip()
2025-04-11 12:49:08 +08:00
2025-04-01 10:48:36 +08:00
if bskip == nil or bskip == false then
self:UpdateCardBox(self:GetPos(room.curren_outcard_seat))
self._tex_LeftCard.text = room.left_count
self:UpdateRound()
2025-04-11 12:49:08 +08:00
end
2025-04-01 10:48:36 +08:00
end
function M:PlayerChangeLineState()
2025-04-11 12:49:08 +08:00
-- local isOutCard = true
-- local str = "玩家 "
-- for _ , player in ipairs(self._room.player_list) do
-- if player.line_state == 0 then
-- isOutCard = false
-- end
-- end
-- self._player_card_info[1]._area_handcard_list.touchable = isOutCard
2025-04-01 10:48:36 +08:00
end
function M:UpdateCardBox(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
self._ctr_cardbox.selectedIndex = index
end
function M:__CloseTip()
if self._chipeng_tip then
self._chipeng_tip:Dispose()
self._chipeng_tip = nil
end
if self._pop_tip_choice then
self._pop_tip_choice:Dispose()
self._pop_tip_choice = nil
end
end
function M:closeTipOnTuoguan()
self:__CloseTip()
end
function M:Destroy()
MJMainView.Destroy(self)
UIPackage.RemovePackage("extend/majiang/chaoshan/ui/Extend_MJ_ChaoShan")
end
2025-04-11 12:49:08 +08:00
return M