yunque9/lua_probject/extend_project/extend/zipai/fulushou/main/ZPPlayerSelfCardInfoView.lua

846 lines
29 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

local CardCheck = import('.CardCheck')
local PendulumRule = import('.PendulumRule')
AreaOderType = {
left_right = 'left_right',
right_left = 'right_left',
up_down = 'up_down',
down_up = 'down_up'
}
local CardView = {
btn_card = nil,
-- 牌序号
card_item = 0,
-- 牌层级
Hierarchy = 0,
-- 牌的列数
index_X = 0,
-- 每一列第几张牌
index_Y = 0,
-- 原始位置
old_postion = Vector2.zero,
--相同牌数量
sameNum=0
}
local function NewCardView(card, cardItem, index_X, index_Y,num)
local self = {}
setmetatable(self, {__index = CardView})
self.btn_card = card
self.card_item = cardItem
self.index_X = index_X
self.index_Y = index_Y
self.sameNum=num
return self
end
local PlayerSelfCardInfoView = {
_view = nil,
_mainView = nil,
_mask_liangpai = nil,
_area_outcard_list = nil,
_area_handcard_list = nil
}
local M = PlayerSelfCardInfoView
function M.new(view, mainView)
local self = {}
setmetatable(self, {__index = M})
self._view = view
self._mainView = mainView
self:init()
return self
end
function M:init()
local view = self._view
self._isDrg = false
self.card_list = {} -- 牌的btn code type pos 等等
self.cards_count = 0 -- 牌的总列数
self.card_width = 99
self.card_hight = 121
self.outcard_button = nil
self._room = DataManager.CurrenRoom
self._area_handcard_list = view:GetChild('area_handcard_list')
self._area_outcard_list = view:GetChild('area_outcard_list')
self._area_fz_list = view:GetChild('area_fz_list')
self._area_qipai_list = view:GetChild('windcard_list')
self._mask_liangpai = view:GetChild('mask_liangpai')
UIPackage.AddPackage('base/main_zipaimajiang/ui/Main_RunBeardMaJiang')
self.ctr_piao = self._view:GetController('piao')
self.ctr_piao_value = self._view:GetController('piaovalue')
self:BtnEvent()
end
function M:ShowPiao(piao)
self:UpdateIsOnClick(true)
self:IsShowAllPiao(true)
self.ctr_piao.selectedIndex = piao
if piao ==3 then
local tconfig=DataManager.CurrenRoom.room_config.config
if tconfig.piao1==false then
self:IsEnablePiao(1,false)
end
if tconfig.piao2==false then
self:IsEnablePiao(2,false)
end
if tconfig.piao3==false then
self:IsEnablePiao(3,false)
end
if tconfig.piao4==false then
self:IsEnablePiao(8,false)
end
end
end
function M:ShowSpecialPiao(piao,lastPiao)
self:UpdateIsOnClick(true)
self:IsShowAllPiao(true)
self.ctr_piao.selectedIndex = piao
for k,v in pairs(self.PiaoList) do
if k<lastPiao then
self:IsEnablePiao(k,false)
end
end
end
function M:HidePiao()
self.ctr_piao.selectedIndex = 0
end
function M:IsShowAllPiao(isShow)
for k,v in pairs(self.PiaoList) do
v.visible=isShow
end
end
function M:IsEnablePiao(index,enabled)
self.PiaoList[index].visible=enabled
end
function M:BtnEvent()
self.btn_tips = self._view:GetChild('btn_tips')
local function click_piao()
local closePiaoTipsFunc=function ()
self.ctr_piao.selectedIndex = 0
end
ControllerManager.GetController(GameController):SendPiao(tonumber(self.ctr_piao_value.selectedPage),closePiaoTipsFunc)
end
self.PiaoList={}
local btn_piao0 = self._view:GetChild('piao0')
btn_piao0.onClick:Set(click_piao)
self.PiaoList[0]=btn_piao0
local btn_piao1 = self._view:GetChild('piao1')
btn_piao1.onClick:Set(click_piao)
self.PiaoList[1]=btn_piao1
local btn_piao2 = self._view:GetChild('piao2')
btn_piao2.onClick:Set(click_piao)
self.PiaoList[2]=btn_piao2
local btn_piao3 = self._view:GetChild('piao3')
btn_piao3.onClick:Set(click_piao)
self.PiaoList[3]=btn_piao3
--local btn_piao5 = self._view:GetChild('piao5')
--btn_piao5.onClick:Set(click_piao)
local btn_piao8 = self._view:GetChild('piao8')
btn_piao8.onClick:Set(click_piao)
self.PiaoList[8]=btn_piao8
end
function M:SetPlayer(p)
self._player = p
end
function M:FillData(begin)
end
function M:Clear()
self.outcard_button = nil
self._area_outcard_list:RemoveChildren(0, -1, true)
self._area_fz_list:RemoveChildren(0, -1, true)
self._area_handcard_list:RemoveChildren(0, -1, true)
self._area_qipai_list:RemoveChildren(0, -1, true)
self._mask_liangpai:RemoveChildren(0, -1, true)
self.card_list = {}
end
function M:fillCard(obj, card_type, cards)
end
function M:ShowHuTip(card)
if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then
local x = {}
self._mainView._hu_tip:FillData(x)
return
end
--[[local _aplayer = DataManager.CurrenRoom.self_player
local selfplayeTable = {}
selfplayeTable.handcard_list = _aplayer.handcard_list
selfplayeTable.fz_list = _aplayer.fz_list
selfplayeTable.tiCount = _aplayer.tiCount
selfplayeTable.paoCount = _aplayer.paoCount
selfplayeTable.hu_xi = _aplayer.hu_xi
local player = membe_deep_clone(selfplayeTable)
if card ~= nil then
list_remove(player.handcard_list, card)
end
local tingList = CardCheck.tingPai(player, DataManager.CurrenRoom)
if self._mainView._hu_tip ~= nil then
self._mainView._hu_tip:FillData(tingList)
end--]]
if card then
if DataManager.CurrenRoom.self_player.CardTingList then
local tempV=DataManager.CurrenRoom.self_player.CardTingList[card]
if tempV and #tempV>0 then
self._mainView._hu_tip:FillData(tempV)
else
self._mainView._hu_tip:FillData({})
end
end
else
end
end
function M:SetNotPutCard()
local tempNotPutList=DataManager.CurrenRoom.self_player.currentNotPutCardList
if tempNotPutList and #tempNotPutList>0 then
for i=1,#tempNotPutList do
self:UpdateKan(tempNotPutList[i])
end
end
end
--手牌
function M:InitHandCard(isPlayAni)
self:HidePiao()
if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then
return
end
self.outcard_button = nil
if self.cor_init_poker ~= nil then
coroutine.stop(self.cor_init_poker)
end
self.cor_init_poker = nil
local _room = DataManager.CurrenRoom
--得到排序好的 list
local pokerList = PendulumRule.GetHandCard(_room.self_player.handcard_list)
--printlog("计算牌型mySelf==>>>")
--pt(pokerList)
if pokerList == nil or #pokerList == 0 then
return
end
self.cards_count = #pokerList
self.card_list = {}
self._area_handcard_list:RemoveChildren(0, -1, true)
--开始发牌动画
if isPlayAni == true then
self.cor_init_poker =
coroutine.start(
function()
self._mainView._popEvent = false
if self._mainView._rightPanelView._settingView ~= nil then
self._mainView._rightPanelView._settingView:SetBtnUpdateCardEnable(false)
end
for i = 1, #pokerList do
local pokerListNum = 0
for j = #pokerList[i],1,-1 do
for k=1,#pokerList[i][j] do
local currentCardNum=#pokerList[i][j]
local card_code = pokerList[i][j][k]
local btn_card = UIPackage.CreateObjectFromURL('ui://Main_RunBeardMaJiang/Btn_Card')
btn_card:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeardMaJiang/201_', card_code)
btn_card:GetChild('icon'):SetScale(self:getCardSize(), self:getCardSize())
btn_card:GetChild('n6'):SetScale(self:getCardSize(), self:getCardSize())
self.card_width = 95 * self:getCardSize()
self.card_hight = 121 * self:getCardSize()
local x, y = 500, (j * 75) + 500
btn_card:SetXY(x, y)
btn_card:GetController('cardnum').selectedIndex=currentCardNum-1
local cardNums=currentCardNum-1
if cardNums>0 then
for n=1,cardNums do
local tempCardBtn=btn_card:GetChild('icon'..n)
tempCardBtn.icon = self:getCardItem('ui://Main_RunBeardMaJiang/201_', card_code)
tempCardBtn:SetScale(self:getCardSize(), self:getCardSize())
end
end
self._area_handcard_list:AddChild(btn_card)
self._area_handcard_list:SetChildIndex(btn_card, j)
btn_card.sortingOrder=j
local card_view = NewCardView(btn_card, card_code, i, j,currentCardNum)
--存牌堆
self.card_list[#self.card_list + 1] = card_view
btn_card.data = card_view
btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin))
btn_card.onTouchMove:Set(handler(self, self.onTouchMove))
btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd))
btn_card.onClick:Set(self.__OnClickHandCard,self)
end
end
for j = 1, #self.card_list, -1 do
coroutine.wait(0.005)
if pokerListNum == #pokerList[i] then
break
end
pokerListNum = pokerListNum + 1
local card_view = self.card_list[j]
card_view.btn_card:RemoveFromParent()
self._area_handcard_list:AddChild(card_view.btn_card)
card_view.btn_card:TweenMove(self:GetHandCardPos(card_view, self.cards_count), 0.08)
end
end
self:UpdateHandCardsPos()
--------------------
self._mainView._popEvent = true
self:UpdateIsOnClick(true)
if self._mainView._rightPanelView._settingView ~= nil then
coroutine.start(
function()
coroutine.wait(1)
self._mainView._rightPanelView._settingView:SetBtnUpdateCardEnable(true)
end
)
end
end
)
else
for i = 1, #pokerList do
for j = #pokerList[i],1,-1 do
for k=1,#pokerList[i][j] do
local currentCardNum=#pokerList[i][j]
local card_code = pokerList[i][j][k]
local btn_card = UIPackage.CreateObjectFromURL('ui://Main_RunBeardMaJiang/Btn_Card')
btn_card:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeardMaJiang/201_', card_code)
btn_card:GetChild('icon'):SetScale(self:getCardSize(), self:getCardSize())
btn_card:GetChild('n6'):SetScale(self:getCardSize(), self:getCardSize())
self.card_width = 95 * self:getCardSize()
self.card_hight = 121 * self:getCardSize()
btn_card:GetController('cardnum').selectedIndex=currentCardNum-1
local cardNums=currentCardNum-1
if cardNums>0 then
for n=1,cardNums do
local tempCardBtn=btn_card:GetChild('icon'..n)
tempCardBtn.icon = self:getCardItem('ui://Main_RunBeardMaJiang/201_', card_code)
tempCardBtn:SetScale(self:getCardSize(), self:getCardSize())
end
end
self._area_handcard_list:AddChild(btn_card)
self._area_handcard_list:SetChildIndex(btn_card,j)
btn_card.sortingOrder=j
local card_view = NewCardView(btn_card, card_code, i, j,currentCardNum)
--存牌堆
self.card_list[#self.card_list + 1] = card_view
btn_card.data = card_view
btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin))
btn_card.onTouchMove:Set(handler(self, self.onTouchMove))
btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd))
btn_card.onClick:Set(self.__OnClickHandCard,self)
end
end
--存牌堆
for j = 1, #self.card_list do
local card_view = self.card_list[j]
card_view.btn_card.xy = self:GetHandCardPos(card_view, self.cards_count)
end
end
self:UpdateHandCardsPos()
end
self:SetNotPutCard()
end
function M:__OnClickHandCard(context)
if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then
return
end
if self.outcard_button then
self.outcard_button = nil
end
local button = context.sender
local card = button.data
local _room = DataManager.CurrenRoom
if (Utils.IsDoubleClick(context) and _room.curren_outcard_seat == _room.self_player.seat) then
local OutCardCallBackFunc=function ()
button.touchable = false
self.outcard_button = card
self:UpdateIsOnClick(false)
self._mainView:OutCard(card.card_item)
end
local tingpaiList=DataManager.CurrenRoom.self_player.tingPaiList
local isHasTing=CheckDictionaryFromContent(card.card_item,DataManager.CurrenRoom.self_player.tingPaiList)
--printlog("是否包含有====》》》》",isHasTing)
--pt(tingpaiList)
if isHasTing==nil then isHasTing=false end
if isHasTing==false and tingpaiList and #tingpaiList>0 then
local spCallBackFunc=function (isOP)
if isOP then
OutCardCallBackFunc()
else
local isChangeCard = false
self.outcard_button = nil
card.btn_card:GetController('cardnum').selectedIndex=card.sameNum-1
card.btn_card:GetChild("icon").icon = self:getCardItem("ui://Main_RunBeardMaJiang/201_",card.card_item)
self._area_handcard_list:AddChild(button)
if card.btn_card.sortingOrder then
card.btn_card.sortingOrder = card.order or 1
end
if #self.card_list == 1 then
isChangeCard = false
self:UpdateHandCardsPos()
return
end
card.btn_card.xy=card.startPos
end
end
local SPView=SanPaiInfoView.new(spCallBackFunc)
else
OutCardCallBackFunc()
end
end
end
--更新手牌
function M:UpdateHandCards(list)
self.card_list = {}
self._area_handcard_list:RemoveChildren(0, -1, true)
self.outcard_button = nil
local CountCards = {}
for i = 1, #list do
CountCards[list[i].index_X] = CountCards[list[i].index_X] == nil and 1 or CountCards[list[i].index_X] + 1
end
for i = 1, #list do
local card_code = list[i].card_item
local btn_card = UIPackage.CreateObjectFromURL('ui://Main_RunBeardMaJiang/Btn_Card')
btn_card:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeardMaJiang/201_', card_code)
btn_card:GetChild('icon'):SetScale(self:getCardSize(), self:getCardSize())
btn_card:GetChild('n6'):SetScale(self:getCardSize(), self:getCardSize())
self.card_width = 87 * self:getCardSize()
self.card_hight = 110 * self:getCardSize()
local card_view = NewCardView(btn_card, card_code, list[i].index_X, list[i].index_Y)
--存牌堆
self.card_list[#self.card_list + 1] = card_view
btn_card.data = card_view
btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin))
btn_card.onTouchMove:Set(handler(self, self.onTouchMove))
btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd))
end
for j = #self.card_list, 1, -1 do
local card_view = self.card_list[j]
card_view.btn_card:RemoveFromParent()
self._area_handcard_list:AddChild(card_view.btn_card)
card_view.btn_card.xy = self:GetHandCardPos(card_view, #CountCards)
end
if self._player.fz_list ~= nil then
for i = 1, #self._player.fz_list do
if self._player.fz_list[i].type == RB_FZTypeFLS.Kan then
self:UpdateKan(self._player.fz_list[i].card)
end
end
end
self:SetNotPutCard()
end
-- --
function M:onTouchBegin(context)
if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then
return
end
local button = context.sender
local card = button.data
if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then
self:ShowHuTip(card.card_item)
end
card.startPos=card.btn_card.xy
printlog("拖动开始位置===>>>",card.startPos)
card.btn_card:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeardMaJiang/203_', card.card_item)
-- card.btn_card.sortingOrder = 100
local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y))
card.btn_card.xy = Vector2.New(card.btn_card.x + 20, card.btn_card.y - 50)
card.touch_pos = xy - button.xy
end
function M:onTouchMove(context)
local button = context.sender
local card = button.data
local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y))
button.xy = xy - card.touch_pos
end
--出牌提示动画
function M:ChuPaiTiShi()
if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then
return
end
if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then
self._view:GetController('chupai').selectedIndex = 1
else
self._view:GetController('chupai').selectedIndex = 0
end
end
-- 删手牌
function M:DeleteHandCard(carditem)
local card = nil
if self.outcard_button ~= nil and carditem == self.outcard_button.card_item then
list_remove(self.card_list, self.outcard_button)
self._area_handcard_list:RemoveChild(self.outcard_button.btn_card, true)
card = self.outcard_button
self.outcard_button = nil
else
for i = 1, #self.card_list do
local card_view = self.card_list[i]
if carditem == card_view.card_item then
card_view.btn_card.touchable = false
list_remove(self.card_list, card_view)
card = card_view
--card_view.btn_card:RemoveFromParent()
self._area_handcard_list:RemoveChild(card_view.btn_card, true)
break
end
end
end
if card ~= nil then
local num = 0
for i = 1, #self.card_list do
if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then
self.card_list[i].index_Y = self.card_list[i].index_Y - 1
end
if card.index_X == self.card_list[i].index_X then
num = num + 1
end
end
if num == 0 then
for i = 1, #self.card_list do
if self.card_list[i].index_X > card.index_X then
self.card_list[i].index_X = self.card_list[i].index_X - 1
end
end
end
end
--self:UpdateHandCardsPos()
end
--更新手牌的坎
function M:UpdateKan(card)
for i = 1, #self.card_list do
local card_view = self.card_list[i]
if card_view.card_item == card then
card_view.btn_card.touchable = false
card_view.btn_card:GetController('Kan').selectedIndex = 1
end
end
end
-- 手牌更新位置方法 self.card_list 里面的对象 NewCardViewindex_X index_Y 就是xy序号
function M:UpdateHandCardsPos()
--得到有 多少列
local CountCards = {}
for i = 1, #self.card_list do
CountCards[self.card_list[i].index_X] =
CountCards[self.card_list[i].index_X] == nil and 1 or CountCards[self.card_list[i].index_X] + 1
end
for i = #self.card_list, 1, -1 do
local card_view = self.card_list[i]
card_view.btn_card:RemoveFromParent()
self._area_handcard_list:AddChild(card_view.btn_card)
card_view.old_postion = self:GetHandCardPos(card_view, #CountCards)
card_view.btn_card:TweenMove(card_view.old_postion, 0.3)
end
self:ShowHuTip()
end
--刷新手牌字体
function M:UpdateCardDisplay()
local CountCards = {}
for i = 1, #self.card_list do
CountCards[self.card_list[i].index_X] =
CountCards[self.card_list[i].index_X] == nil and 1 or CountCards[self.card_list[i].index_X] + 1
end
for i = #self.card_list, 1, -1 do
local card_view = self.card_list[i]
card_view.btn_card:RemoveFromParent()
card_view.btn_card:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeardMaJiang/201_', card_view.card_item)
self._area_handcard_list:AddChild(card_view.btn_card)
card_view.btn_card:TweenMove(self:GetHandCardPos(card_view, #CountCards), 0.3)
end
end
--更新手牌大小
function M:UpdateCardSize()
local CountCards = {}
for i = 1, #self.card_list do
CountCards[self.card_list[i].index_X] =
CountCards[self.card_list[i].index_X] == nil and 1 or CountCards[self.card_list[i].index_X] + 1
end
for i = #self.card_list, 1, -1 do
local card_view = self.card_list[i]
card_view.btn_card:RemoveFromParent()
card_view.btn_card:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeardMaJiang/201_', card_view.card_item)
card_view.btn_card:GetChild('icon'):SetScale(self:getCardSize(), self:getCardSize())
card_view.btn_card:GetChild('n6'):SetScale(self:getCardSize(), self:getCardSize())
self.card_width = 99 * self:getCardSize()
self.card_hight = 121 * self:getCardSize()
self._area_handcard_list:AddChild(card_view.btn_card)
card_view.btn_card:TweenMove(self:GetHandCardPos(card_view, #CountCards), 0.3)
end
end
function M:UpdateIsOnClick(isOut)
self._view.touchable = isOut
end
-- 结束 拖拽事件
-- 根据牌结束点的位置 判断是出牌还是调整位置 button.xy 和 牌的xy比较
function M:__OnDragEnd(context)
if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then
return
end
if self.outcard_button then
self.outcard_button = nil
end
local button = context.sender
local card = button.data
-- card.btn_card.sortingOrder = 0
local _room = DataManager.CurrenRoom
if (button.y < -320 and _room ~= nil and _room.curren_outcard_seat == _room.self_player.seat) then
button.touchable = false
self.outcard_button = card
self:UpdateIsOnClick(false)
self._mainView:OutCard(card.card_item)
else
local isChangeCard = false
self.outcard_button = nil
card.btn_card:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeardMaJiang/201_', card.card_item)
self._area_handcard_list:AddChild(button)
if #self.card_list == 1 then
isChangeCard = false
self:UpdateHandCardsPos()
return
end
printlog("拖动结束位置为===>>>",card.startPos)
card.btn_card.xy=card.startPos
end
end
--改变手牌排列发给服务器
function M:SendChangeCard(...)
local list = {}
for i = 1, #self.card_list do
local data = {}
data.card = self.card_list[i].card_item
data.X = self.card_list[i].index_X
data.Y = self.card_list[i].index_Y
list[#list + 1] = data
end
self._mainView:ChangeCards(list)
end
--计算手牌位置
function M:GetHandCardPos(cards_view, cards)
local x, y = 0, 0
local card_width = self.card_width -- 牌的宽度
local middle_x = self._area_handcard_list.width / 2
local start_x = middle_x - (cards / 2 * (card_width))
x = start_x + (card_width) * (cards_view.index_X - 1)
if self:getCardSize() == 1.2 then
--y = 90 - (85 * cards_view.index_Y)
y = (115 * cards_view.index_Y)-450
elseif self:getCardSize() == 1 then
y = (115 * cards_view.index_Y)-450
--printlog("Y坐标==>>>",y)
elseif self:getCardSize() == 0.8 then
-- y = 100 - (65 * cards_view.index_Y)
y = (115 * cards_view.index_Y)-450
end
if cards_view.index_Y>1 then
--y=y-15
end
return Vector2.New(x, y)
end
--更新 吃碰
function M:UpdateFzList1(fz_list)
self._area_fz_list:RemoveChildren(0, -1, true)
for i = 1, #fz_list do
local fzitem = nil
if fz_list[i].type ~= RB_FZTypeFLS.Kan then
fzitem = UIPackage.CreateObjectFromURL('ui://Main_RunBeardMaJiang/Component1')
fzitem:RemoveChildren(0, -1, true)
end
if fz_list[i].type == RB_FZTypeFLS.Chi or fz_list[i].type == RB_FZTypeFLS.Bi then
local fzcards = UIPackage.CreateObjectFromURL('ui://Main_RunBeardMaJiang/Fz_0_3')
fzcards:GetChild('card_' .. 1).icon = self:getCardItem('ui://Main_RunBeardMaJiang/202_', fz_list[i].active_card)
fzcards:GetController('c2').selectedIndex = 1
fzcards:GetChild('card_' .. 2).icon = self:getCardItem('ui://Main_RunBeardMaJiang/202_', fz_list[i].opcard[1])
fzcards:GetChild('card_' .. 3).icon = self:getCardItem('ui://Main_RunBeardMaJiang/202_', fz_list[i].opcard[2])
fzcards.x, fzcards.y = 0, 0
fzitem:AddChildAt(fzcards, 0)
self._area_fz_list:AddChild(fzitem)
elseif fz_list[i].type == RB_FZTypeFLS.Peng then
local fzcards = UIPackage.CreateObjectFromURL('ui://Main_RunBeardMaJiang/Fz_0_3')
for j = 1, 3 do
fzcards:GetChild('card_' .. j).icon = self:getCardItem('ui://Main_RunBeardMaJiang/202_', fz_list[i].card)
end
fzcards.x, fzcards.y = 0, 0
fzitem:AddChildAt(fzcards, 0)
self._area_fz_list:AddChild(fzitem)
elseif fz_list[i].type == RB_FZTypeFLS.Wei then
local fzcards = UIPackage.CreateObjectFromURL('ui://Main_RunBeardMaJiang/Fz_0_3')
fzcards:GetController('c1').selectedIndex = 1
for j = 1, 3 do
fzcards:GetChild('card_' .. j).icon = self:getCardItem('ui://Main_RunBeardMaJiang/202_', fz_list[i].card)
end
fzcards.x, fzcards.y = 0, 0
fzitem:AddChildAt(fzcards, 0)
self._area_fz_list:AddChild(fzitem)
elseif fz_list[i].type == RB_FZTypeFLS.ChouWei then
local fzcards = UIPackage.CreateObjectFromURL('ui://Main_RunBeardMaJiang/Fz_0_3')
fzcards:GetController('c1').selectedIndex = 1
for j = 1, 3 do
fzcards:GetChild('card_' .. j).icon = self:getCardItem('ui://Main_RunBeardMaJiang/202_', fz_list[i].card)
end
fzcards.x, fzcards.y = 0, 0
fzitem:AddChildAt(fzcards, 0)
self._area_fz_list:AddChild(fzitem)
elseif fz_list[i].type == RB_FZTypeFLS.Zhao or fz_list[i].type == RB_FZTypeFLS.SZhao or fz_list[i].type == RB_FZTypeFLS.Gang or fz_list[i].type == RB_FZTypeFLS.SGang then
local fzcards = UIPackage.CreateObjectFromURL('ui://Main_RunBeardMaJiang/Fz_0_4')
for j = 1, 4 do
fzcards:GetChild('card_' .. j).icon = self:getCardItem('ui://Main_RunBeardMaJiang/202_', fz_list[i].card)
end
fzcards.x, fzcards.y = 0, 0
fzitem:AddChildAt(fzcards, 0)
self._area_fz_list:AddChild(fzitem)
--[[elseif fz_list[i].type == RB_FZTypeFLS.Gang or fz_list[i].type == RB_FZTypeFLS.SGang then
local fzcards = UIPackage.CreateObjectFromURL('ui://Main_RunBeardMaJiang/Fz_0_4')
for j = 1, 4 do
if j == 4 then
fzcards:GetChild('card_' .. j).icon = self:getCardItem('ui://Main_RunBeardMaJiang/202_', fz_list[i].card)
else
fzcards:GetChild('card_' .. j).icon = 'ui://Main_RunBeardMaJiang/202_1_300'
end
end
fzcards.x, fzcards.y = 0, 0
fzitem:AddChildAt(fzcards, 0)
self._area_fz_list:AddChild(fzitem)--]]
end
end
end
function M:ClearOutCard()
self._area_outcard_list:RemoveChildren(0, -1, true)
end
--出牌
function M:UpdateOutCardList(outcard)
self._area_outcard_list:RemoveChildren(0, -1, true)
local outcards = UIPackage.CreateObjectFromURL('ui://Main_RunBeardMaJiang/Gcm_OutCard')
if outcard == 0 then
outcards:GetChild('icon').icon = 'ui://Main_RunBeardMaJiang/202_1_300'
else
outcards:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeardMaJiang/203_', outcard)
end
outcards.x, outcards.y = 0, 0
self._area_outcard_list:AddChild(outcards)
end
--弃牌
function M:UpdateQiPai(qi_list)
self._area_qipai_list:RemoveChildren(0, -1, true)
for i = 1, #qi_list do
local qicards = UIPackage.CreateObjectFromURL('ui://Main_RunBeardMaJiang/Qipai')
qicards:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeardMaJiang/202_', qi_list[i])
self._area_qipai_list:AddChild(qicards)
end
end
--摸牌动画
function M:PlayingOutCardAnima(card)
if (self._area_outcard_list ~= nil and self._area_outcard_list.numChildren > 0) then
self._area_outcard_list:GetChildAt(0):GetChild('icon').icon = self:getCardItem('ui://Main_RunBeardMaJiang/202_', card)
self._view:GetTransition('t0'):Play()
end
coroutine.start(
function()
coroutine.wait(0.1)
self:ClearOutCard()
end
)
end
--得到设置的牌字体
function M:getCardItem(card_1, card_2)
--[[if self._room.change_card_display ~= nil then
return card_1 .. self._room.change_card_display .. card_2
else
return card_1 .. '2_' .. card_2
end--]]
return card_1 .. '1_' .. card_2
end
--得到设置的牌大小
function M:getCardSize()
if self._room.change_card_size ~= nil then
return 1.2--self._room.change_card_size
else
return 1.2
end
end
return M