228 lines
8.0 KiB
Lua
228 lines
8.0 KiB
Lua
local PlayerCardInfoView = require("main.zipai.ZPPlayerCardInfoView")
|
|
|
|
local M = {}
|
|
function M.new(view,mainView)
|
|
|
|
setmetatable(M, {__index = PlayerCardInfoView})
|
|
local self = setmetatable({},{__index = M})
|
|
self.class = "PlayerCardInfoView"
|
|
self._view = view
|
|
self._mainView = mainView
|
|
self:init()
|
|
return self
|
|
end
|
|
|
|
|
|
|
|
function M:UpdateFzList(fz_list, ispaly, seat)
|
|
self._area_fz_list:RemoveChildren(0,-1,true)
|
|
for i = 1,#fz_list do
|
|
local fzitem = nil
|
|
if fz_list[i].type ~= RB_FZType.Kan then
|
|
fzitem =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/ComponentNew")
|
|
if (ispaly == false) then
|
|
fzitem:RemoveChildren(0, -1, true)
|
|
end
|
|
end
|
|
if fz_list[i].type == RB_FZType.Chi or fz_list[i].type == RB_FZType.Bi then
|
|
local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3")
|
|
fzcards:GetController("c2").selectedIndex =1
|
|
fzcards:GetChild("card_"..1).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].active_card)
|
|
fzcards:GetChild("card_"..2).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].opcard[1])
|
|
fzcards:GetChild("card_"..3).icon = self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].opcard[2])
|
|
fzcards.x,fzcards.y = 0,0
|
|
self:playAnim(fzitem, fzcards, #fz_list, i, ispaly, seat)
|
|
elseif fz_list[i].type == RB_FZType.Peng then
|
|
local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3")
|
|
for j=1,3 do
|
|
fzcards:GetChild("card_"..j).icon =self:getCardItem("ui://Main_RunBeard/202_",fz_list[i].card)
|
|
end
|
|
fzcards.x,fzcards.y = 0,0
|
|
self:playAnim(fzitem, fzcards, #fz_list, i, ispaly, seat)
|
|
elseif fz_list[i].type == RB_FZType.Wei then
|
|
local fzcards =UIPackage.CreateObjectFromURL("ui://Main_RunBeard/Fz_0_3")
|
|
for j=1,3 do
|
|
fzcards:GetChild("card_"..j).icon ="ui://Main_RunBeard/202_1_300"
|
|
end
|
|
fzcards.x,fzcards.y = 0,0
|
|
self:playAnim(fzitem, fzcards, #fz_list, i, ispaly, seat)
|
|
end
|
|
end
|
|
end
|
|
|
|
function M:playAnim(fzitem, fzcards, size, i, ispaly, seat)
|
|
if (ispaly == nil) then
|
|
ispaly = false
|
|
end
|
|
|
|
local isaddLast = false
|
|
if (ispaly and i == size) then --匹配最后一个牌
|
|
local faArray = fzitem:GetChild('chiwei1')
|
|
|
|
if (DataManager.CurrenRoom.room_config.people_num == 3) then
|
|
if (DataManager.CurrenRoom.self_player.seat == 1) then
|
|
if (seat == 2) then
|
|
faArray = fzitem:GetChild('chiwei1')
|
|
else
|
|
faArray = fzitem:GetChild('chiwei')
|
|
end
|
|
elseif (DataManager.CurrenRoom.self_player.seat == 2) then
|
|
if (seat == 3) then
|
|
faArray = fzitem:GetChild('chiwei1')
|
|
else
|
|
faArray = fzitem:GetChild('chiwei')
|
|
end
|
|
elseif (DataManager.CurrenRoom.self_player.seat == 3) then
|
|
if (seat == 1) then
|
|
faArray = fzitem:GetChild('chiwei1')
|
|
else
|
|
faArray = fzitem:GetChild('chiwei')
|
|
end
|
|
end
|
|
end
|
|
|
|
if (faArray ~= nil) then
|
|
faArray:AddChild(fzcards)
|
|
else
|
|
fzitem:AddChild(fzcards)
|
|
end
|
|
else
|
|
fzitem:AddChild(fzcards)
|
|
end
|
|
if (seat ~= nil) then
|
|
isaddLast = self:isAddFirst(seat)
|
|
end
|
|
if (isaddLast) then
|
|
local index_postion = 0
|
|
self._area_fz_list:AddChildAt(fzitem, index_postion)
|
|
else
|
|
self._area_fz_list:AddChild(fzitem)
|
|
end
|
|
end
|
|
|
|
function M:isAddFirst(seat)
|
|
local isaddLast = false
|
|
if (DataManager.CurrenRoom.room_config.people_num == 3) then
|
|
if (DataManager.CurrenRoom.self_player.seat == 1) then
|
|
if (seat == 2) then
|
|
isaddLast = true
|
|
end
|
|
elseif (DataManager.CurrenRoom.self_player.seat == 2) then
|
|
if (seat == 3) then
|
|
isaddLast = true
|
|
end
|
|
elseif (DataManager.CurrenRoom.self_player.seat == 3) then
|
|
if (seat == 1) then
|
|
isaddLast = true
|
|
end
|
|
end
|
|
elseif DataManager.CurrenRoom.room_config.people_num == 2 then
|
|
isaddLast = true
|
|
end
|
|
return isaddLast
|
|
end
|
|
|
|
function M:PlayingOutCardAnima(card)
|
|
coroutine.start(
|
|
function()
|
|
coroutine.wait(0.1)
|
|
self:ClearOutCard()
|
|
end
|
|
)
|
|
end
|
|
|
|
function M:UpdateOutCardList(outcard, isShow, isMopai, seat)
|
|
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_RunBeard/Gcm_OutCard')
|
|
if outcard == 0 then
|
|
outcards:GetChild('icon').icon = 'ui://Main_RunBeard/202_1_300'
|
|
else
|
|
outcards:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeard/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 (DataManager.CurrenRoom.room_config.people_num == 3) then
|
|
if (seat == 2) then
|
|
seat = 3
|
|
elseif (seat == 3) then
|
|
seat = 2
|
|
end
|
|
elseif DataManager.CurrenRoom.room_config.people_num == 2 then
|
|
seat = 3
|
|
end
|
|
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, ispaly, seat)
|
|
self._area_qipai_list:RemoveChildren(0, -1, true)
|
|
for i = 1, #qi_list do
|
|
local t = qi_list[i]
|
|
local qicards = UIPackage.CreateObjectFromURL('ui://Main_RunBeard/Qipai')
|
|
--qicards:GetController("ischu").selectedIndex = t.ischu
|
|
qicards:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeard/202_', t.card)
|
|
if (ispaly) then
|
|
if (i == #qi_list) then
|
|
if (DataManager.CurrenRoom.room_config.people_num == 2) then
|
|
qicards:GetTransition('t0'):Play()
|
|
else
|
|
if (DataManager.CurrenRoom.self_player.seat == 1) then
|
|
if (seat == 2) then
|
|
qicards:GetTransition('t0'):Play()
|
|
else
|
|
qicards:GetTransition('t1'):Play()
|
|
end
|
|
elseif (DataManager.CurrenRoom.self_player.seat == 2) then
|
|
if (seat == 3) then
|
|
qicards:GetTransition('t0'):Play()
|
|
else
|
|
qicards:GetTransition('t1'):Play()
|
|
end
|
|
elseif (DataManager.CurrenRoom.self_player.seat == 3) then
|
|
if (seat == 1) then
|
|
qicards:GetTransition('t0'):Play()
|
|
else
|
|
qicards:GetTransition('t1'):Play()
|
|
end
|
|
else
|
|
qicards:GetTransition('t0'):Play()
|
|
end
|
|
end
|
|
end
|
|
end
|
|
self._area_qipai_list:AddChild(qicards)
|
|
end
|
|
end
|
|
|
|
return M |