423 lines
14 KiB
Lua
423 lines
14 KiB
Lua
|
|
local PlayerSelfCardInfoView = import(".main.ZPPlayerSelfCardInfoView")
|
||
|
|
local CardCheck = import(".main.CardCheck")
|
||
|
|
local SanPaiInfoView=import(".SanPaiInfoView")
|
||
|
|
local M = {}
|
||
|
|
--
|
||
|
|
function M.new(view,mainView)
|
||
|
|
setmetatable(M, {__index = PlayerSelfCardInfoView})
|
||
|
|
local self = setmetatable({},{__index = M})
|
||
|
|
self.class = "PlayerSelfCardInfoView"
|
||
|
|
self._view = view
|
||
|
|
self._mainView = mainView
|
||
|
|
self._full = true
|
||
|
|
self:init()
|
||
|
|
self.onclickNum=0
|
||
|
|
return self
|
||
|
|
end
|
||
|
|
|
||
|
|
|
||
|
|
function M:onTouchBegin(context)
|
||
|
|
if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then
|
||
|
|
return
|
||
|
|
end
|
||
|
|
--printlog("点击卡牌=============================>>>")
|
||
|
|
self.onclickNum=self.onclickNum+1
|
||
|
|
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=Vector2.New(card.btn_card.x,card.btn_card.y)
|
||
|
|
local tempOrder=card.btn_card.sortingOrder or 1
|
||
|
|
card.order=tonumber(tempOrder)
|
||
|
|
|
||
|
|
card.btn_card:GetController('cardnum').selectedIndex=0
|
||
|
|
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:__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
|
||
|
|
--printlog("点击结束卡牌============================>>>")
|
||
|
|
local button = context.sender
|
||
|
|
|
||
|
|
local card = button.data
|
||
|
|
|
||
|
|
local _room = DataManager.CurrenRoom
|
||
|
|
if (button.y < -480 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
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
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
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
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:UpdateOutCardList(outcard,isShow,isMopai,seat)
|
||
|
|
self:HidePiao()
|
||
|
|
if(isShow == nil) then
|
||
|
|
isShow = false
|
||
|
|
end
|
||
|
|
if(isMopai == nil) then
|
||
|
|
isMopai = false
|
||
|
|
end
|
||
|
|
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
|
||
|
|
local show_di_bg = outcards:GetChild("show_di_bg")
|
||
|
|
-- show_di_bg.visible = true
|
||
|
|
if(isShow)then
|
||
|
|
if outcard == 0 then
|
||
|
|
show_di_bg.visible = false
|
||
|
|
end
|
||
|
|
if(seat ~= nil and outcards~=nil)then
|
||
|
|
if(isMopai)then
|
||
|
|
if outcard ~= 0 then
|
||
|
|
outcards:GetTransition("mopai"..seat):Play(function( )
|
||
|
|
-- show_di_bg.visible = true
|
||
|
|
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
else
|
||
|
|
show_di_bg.visible = false
|
||
|
|
outcards:GetTransition("cpai"..seat):Play()
|
||
|
|
end
|
||
|
|
else
|
||
|
|
--show_di_bg.visible = true
|
||
|
|
end
|
||
|
|
else
|
||
|
|
show_di_bg.visible = false
|
||
|
|
end
|
||
|
|
self._area_outcard_list:AddChild(outcards)
|
||
|
|
end
|
||
|
|
|
||
|
|
--弃牌
|
||
|
|
function M:UpdateQiPai( qi_list,isplay)
|
||
|
|
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])
|
||
|
|
if(isplay)then
|
||
|
|
if(i == #qi_list) then
|
||
|
|
qicards:GetTransition("t1"):Play()
|
||
|
|
end
|
||
|
|
end
|
||
|
|
self._area_qipai_list:AddChild(qicards)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
--摸牌动画
|
||
|
|
function M:PlayingOutCardAnima( card)
|
||
|
|
coroutine.start(function()
|
||
|
|
coroutine.wait(0.1)
|
||
|
|
self:ClearOutCard()
|
||
|
|
end)
|
||
|
|
end
|
||
|
|
|
||
|
|
function M:UpdateFzList( fz_list ,ispaly)
|
||
|
|
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/ComponentNew")
|
||
|
|
if(ispaly == false)then
|
||
|
|
fzitem:RemoveChildren(0,-1,true)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
if fz_list[i].type == RB_FZTypeFLS.Chi 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])
|
||
|
|
for j=1,#fz_list[i].active_card do
|
||
|
|
fzcards:GetChild("card_"..j).icon = self:getCardItem("ui://Main_RunBeardMaJiang/202_",fz_list[i].active_card[j])
|
||
|
|
end
|
||
|
|
fzcards.x,fzcards.y = 0,0
|
||
|
|
self:playAnim(fzitem,fzcards,#fz_list,i,ispaly)
|
||
|
|
|
||
|
|
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].active_card[j])
|
||
|
|
end
|
||
|
|
fzcards.x,fzcards.y = 0,0
|
||
|
|
self:playAnim(fzitem,fzcards,#fz_list,i,ispaly)
|
||
|
|
|
||
|
|
elseif fz_list[i].type == RB_FZTypeFLS.Gang or fz_list[i].type == RB_FZTypeFLS.Zhao 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].active_card[j])
|
||
|
|
end
|
||
|
|
fzcards.x,fzcards.y = 0,0
|
||
|
|
self:playAnim(fzitem,fzcards,#fz_list,i,ispaly)
|
||
|
|
|
||
|
|
elseif fz_list[i].type == RB_FZTypeFLS.SGang or fz_list[i].type == RB_FZTypeFLS.SZhao 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].active_card[j])
|
||
|
|
else
|
||
|
|
fzcards:GetChild('card_' .. j).icon = 'ui://Main_RunBeardMaJiang/202_1_300'
|
||
|
|
end
|
||
|
|
|
||
|
|
end
|
||
|
|
fzcards.x,fzcards.y = 0,0
|
||
|
|
self:playAnim(fzitem,fzcards,#fz_list,i,ispaly)
|
||
|
|
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
|
||
|
|
function M:playAnim( fzitem,fzcards, size,i,ispaly )
|
||
|
|
if(ispaly == nil)then
|
||
|
|
ispaly =false
|
||
|
|
end
|
||
|
|
if(ispaly and i == size)then
|
||
|
|
local faArray= fzitem:GetChild("chiwei")
|
||
|
|
if(faArray~=nil)then
|
||
|
|
faArray:AddChild(fzcards)
|
||
|
|
else
|
||
|
|
fzitem:AddChild(fzcards)
|
||
|
|
end
|
||
|
|
else
|
||
|
|
fzitem:AddChild(fzcards)
|
||
|
|
end
|
||
|
|
self._area_fz_list:AddChild(fzitem)
|
||
|
|
end
|
||
|
|
|
||
|
|
|
||
|
|
--出牌提示动画
|
||
|
|
function M:ChuPaiTiShi()
|
||
|
|
if DataManager.CurrenRoom ==nil or DataManager.CurrenRoom.self_player ==nil then
|
||
|
|
return
|
||
|
|
end
|
||
|
|
--[[local chu_player = DataManager.CurrenRoom.self_player
|
||
|
|
local selfplayeTable = {}
|
||
|
|
selfplayeTable.handcard_list = chu_player.handcard_list
|
||
|
|
selfplayeTable.fz_list = chu_player.fz_list
|
||
|
|
selfplayeTable.tiCount = chu_player.tiCount
|
||
|
|
selfplayeTable.paoCount = chu_player.paoCount
|
||
|
|
selfplayeTable.hu_xi = chu_player.hu_xi
|
||
|
|
local player = membe_deep_clone(selfplayeTable)
|
||
|
|
local mark_ting= {}
|
||
|
|
for i=1,#DataManager.CurrenRoom.self_player.handcard_list do
|
||
|
|
local card = DataManager.CurrenRoom.self_player.handcard_list[i]
|
||
|
|
list_remove(player.handcard_list, card)
|
||
|
|
local _player = membe_deep_clone(player)
|
||
|
|
local tingList = CardCheck.tingPai(_player,DataManager.CurrenRoom)
|
||
|
|
local isKan = false
|
||
|
|
for j=1,#player.fz_list do
|
||
|
|
if card == player.fz_list[j].card and player.fz_list[j].type == RB_FZTypeFLS.Kan then
|
||
|
|
isKan =true
|
||
|
|
end
|
||
|
|
end
|
||
|
|
if #tingList > 0 and isKan == false then
|
||
|
|
|
||
|
|
mark_ting[#mark_ting+1] = card
|
||
|
|
end
|
||
|
|
table.insert(player.handcard_list, card)
|
||
|
|
table.sort( player.handcard_list, ViewUtil.HandCardSort)
|
||
|
|
end--]]
|
||
|
|
-- print("ChuPaiTiShi",#mark_ting,vardump(player))
|
||
|
|
|
||
|
|
|
||
|
|
----------------
|
||
|
|
|
||
|
|
if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then
|
||
|
|
self._view :GetController("chupai").selectedIndex =1
|
||
|
|
--[[if #mark_ting>0 then
|
||
|
|
for i=1,#mark_ting do
|
||
|
|
for k=1,#self.card_list do
|
||
|
|
local card_view= self.card_list[k]
|
||
|
|
if card_view.card_item == mark_ting[i] then
|
||
|
|
card_view.btn_card:GetController("mark_ting").selectedIndex = 1
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end--]]
|
||
|
|
|
||
|
|
----------------------
|
||
|
|
if DataManager.CurrenRoom.self_player.tingPaiList and #DataManager.CurrenRoom.self_player.tingPaiList>0 then
|
||
|
|
for k=1,#self.card_list do
|
||
|
|
local card_view= self.card_list[k]
|
||
|
|
local isTing,curIndex=CheckDictionaryFromContent(card_view.card_item,DataManager.CurrenRoom.self_player.tingPaiList)
|
||
|
|
if isTing then
|
||
|
|
--printlog("听牌提示===》》》",curIndex)
|
||
|
|
--pt(DataManager.CurrenRoom.self_player.tingPaiList[curIndex])
|
||
|
|
local value=#DataManager.CurrenRoom.self_player.tingPaiList[curIndex].value
|
||
|
|
if tonumber(value)>0 then
|
||
|
|
card_view.btn_card:GetController("mark_ting").selectedIndex = 1
|
||
|
|
end
|
||
|
|
|
||
|
|
end
|
||
|
|
|
||
|
|
end
|
||
|
|
|
||
|
|
end
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
else
|
||
|
|
self._view :GetController("chupai").selectedIndex =0
|
||
|
|
for k=1,#self.card_list do
|
||
|
|
local card_view= self.card_list[k]
|
||
|
|
card_view.btn_card:GetController("mark_ting").selectedIndex = 0
|
||
|
|
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
return M
|