间距调小

master
罗家炜 2025-06-20 21:01:40 +08:00
parent f3046eb536
commit 4ecc3ce48e
1 changed files with 99 additions and 103 deletions

View File

@ -23,7 +23,7 @@ local CardView = {
local function NewCardView(card, cardItem, index_X, index_Y) local function NewCardView(card, cardItem, index_X, index_Y)
local self = {} local self = {}
setmetatable(self, {__index = CardView}) setmetatable(self, { __index = CardView })
self.btn_card = card self.btn_card = card
self.card_item = cardItem self.card_item = cardItem
self.index_X = index_X self.index_X = index_X
@ -42,7 +42,7 @@ local PlayerSelfCardInfoView = {
local M = PlayerSelfCardInfoView local M = PlayerSelfCardInfoView
function M.new(view, mainView) function M.new(view, mainView)
local self = {} local self = {}
setmetatable(self, {__index = M}) setmetatable(self, { __index = M })
self._view = view self._view = view
self._mainView = mainView self._mainView = mainView
self:init() self:init()
@ -52,7 +52,7 @@ end
function M:init() function M:init()
local view = self._view local view = self._view
self._isDrg = false self._isDrg = false
self.card_list = {} -- 牌的btn code type pos 等等 self.card_list = {} -- 牌的btn code type pos 等等
self.cards_count = 0 -- 牌的总列数 self.cards_count = 0 -- 牌的总列数
self.card_width = 87 self.card_width = 87
self.card_hight = 110 self.card_hight = 110
@ -60,18 +60,17 @@ function M:init()
self._room = DataManager.CurrenRoom self._room = DataManager.CurrenRoom
self._area_handcard_list = view:GetChild('area_handcard_list') self._area_handcard_list = view:GetChild('area_handcard_list')
self._area_outcard_list = view:GetChild('area_outcard_list') self._area_outcard_list = view:GetChild('area_outcard_list')
-- self._bgview = view:GetController("bgview") -- self._bgview = view:GetController("bgview")
self._area_fz_list = view:GetChild('area_fz_list') self._area_fz_list = view:GetChild('area_fz_list')
self._area_qipai_list = view:GetChild('windcard_list') self._area_qipai_list = view:GetChild('windcard_list')
self._mask_liangpai = view:GetChild('mask_liangpai') self._mask_liangpai = view:GetChild('mask_liangpai')
UIPackage.AddPackage('base/main_zipai/ui/Main_RunBeard') UIPackage.AddPackage('base/main_zipai/ui/Main_RunBeard')
self.ctr_piao = self._view:GetController('piao') self.ctr_piao = self._view:GetController('piao')
self.ctr_niao = self._view:GetController('niao') self.ctr_niao = self._view:GetController('niao')
self.ctr_piao_value = self._view:GetController('piaovalue') self.ctr_piao_value = self._view:GetController('piaovalue')
self:BtnEvent() self:BtnEvent()
end end
function M:ShwoDaNiao(niao) function M:ShwoDaNiao(niao)
self.ctr_niao.selectedIndex = 1 self.ctr_niao.selectedIndex = 1
end end
@ -81,50 +80,45 @@ function M:HideDaNiao(niao)
end end
function M:ShowPiao(piao) function M:ShowPiao(piao)
self:UpdateIsOnClick(true) self:UpdateIsOnClick(true)
self.ctr_niao.selectedIndex = piao self.ctr_niao.selectedIndex = piao
-- self:EnableAllPiaoTouch() -- self:EnableAllPiaoTouch()
end end
function M:HidePiao() function M:HidePiao()
self.ctr_niao.selectedIndex = 0 self.ctr_niao.selectedIndex = 0
end end
function M:BtnEvent() function M:BtnEvent()
self.btn_tips = self._view:GetChild('btn_tips') self.btn_tips = self._view:GetChild('btn_tips')
local function click_niao1(vaule) local function click_niao1(vaule)
local closeNiaoTipsFunc=function () local closeNiaoTipsFunc = function()
self.ctr_niao.selectedIndex = 0 self.ctr_niao.selectedIndex = 0
end end
ControllerManager.GetController(GameController):SendNiao(1,closeNiaoTipsFunc) ControllerManager.GetController(GameController):SendNiao(1, closeNiaoTipsFunc)
end end
local function click_niao0(vaule) local function click_niao0(vaule)
local closeNiaoTipsFunc=function () local closeNiaoTipsFunc = function()
self.ctr_niao.selectedIndex = 0 self.ctr_niao.selectedIndex = 0
end end
ControllerManager.GetController(GameController):SendNiao(0,closeNiaoTipsFunc) ControllerManager.GetController(GameController):SendNiao(0, closeNiaoTipsFunc)
end end
local btn_budaniao = self._view:GetChild("budaniao") local btn_budaniao = self._view:GetChild("budaniao")
btn_budaniao.onClick:Set(click_niao0) btn_budaniao.onClick:Set(click_niao0)
local btn_daniao = self._view:GetChild("daniao") local btn_daniao = self._view:GetChild("daniao")
btn_daniao.onClick:Set(click_niao1) btn_daniao.onClick:Set(click_niao1)
end end
function M:EnableAllPiaoTouch() function M:EnableAllPiaoTouch()
for i=1,#self.PiaoList do for i = 1, #self.PiaoList do
self.PiaoList[i].touchable=true self.PiaoList[i].touchable = true
end end
end end
function M:SetPlayer(p) function M:SetPlayer(p)
self._player = p self._player = p
end end
@ -135,7 +129,7 @@ end
function M:Clear() function M:Clear()
self.outcard_button = nil self.outcard_button = nil
self._area_outcard_list:RemoveChildren(0, -1, true) self._area_outcard_list:RemoveChildren(0, -1, true)
-- self._bgview.selectedIndex = 0 -- self._bgview.selectedIndex = 0
self._area_fz_list:RemoveChildren(0, -1, true) self._area_fz_list:RemoveChildren(0, -1, true)
self._area_handcard_list:RemoveChildren(0, -1, true) self._area_handcard_list:RemoveChildren(0, -1, true)
self._area_qipai_list:RemoveChildren(0, -1, true) self._area_qipai_list:RemoveChildren(0, -1, true)
@ -145,6 +139,7 @@ end
function M:fillCard(obj, card_type, cards) function M:fillCard(obj, card_type, cards)
end end
function M:ShowHuTip(card) function M:ShowHuTip(card)
if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then
local x = {} local x = {}
@ -173,14 +168,13 @@ function M:ShowHuTip(card)
end end
end end
function M:SetNotPutCard() function M:SetNotPutCard()
local tempNotPutList=DataManager.CurrenRoom.self_player.currentNotPutCardList local tempNotPutList = DataManager.CurrenRoom.self_player.currentNotPutCardList
if tempNotPutList and #tempNotPutList>0 then if tempNotPutList and #tempNotPutList > 0 then
for i=1,#tempNotPutList do for i = 1, #tempNotPutList do
self:UpdateKan(tempNotPutList[i]) self:UpdateKan(tempNotPutList[i])
end end
end end
end end
--手牌 --手牌
@ -207,58 +201,58 @@ function M:InitHandCard(isPlayAni, index)
if isPlayAni == true then if isPlayAni == true then
self.cor_init_poker = self.cor_init_poker =
coroutine.start( coroutine.start(
function() function()
self._mainView._popEvent = false self._mainView._popEvent = false
if self._mainView._rightPanelView._settingView ~= nil then if self._mainView._rightPanelView._settingView ~= nil then
self._mainView._rightPanelView._settingView:SetBtnUpdateCardEnable(false) self._mainView._rightPanelView._settingView:SetBtnUpdateCardEnable(false)
end
for i = 1, #pokerList do
local pokerListNum = 0
for j = 1, #pokerList[i] do
local card_code = pokerList[i][j]
local btn_card = UIPackage.CreateObjectFromURL('ui://Main_RunBeard/Btn_Card')
btn_card:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeard/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 = 123 * self:getCardSize()
local x, y = 500, (j * 85) - 500
btn_card:SetXY(x, y)
self._area_handcard_list:AddChild(btn_card)
self._area_handcard_list:SetChildIndex(btn_card, 5 - j)
local card_view = NewCardView(btn_card, card_code, i, j)
--存牌堆
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 end
for j = #self.card_list, 1, -1 do for i = 1, #pokerList do
coroutine.wait(0.005) local pokerListNum = 0
if pokerListNum == #pokerList[i] then for j = 1, #pokerList[i] do
break local card_code = pokerList[i][j]
local btn_card = UIPackage.CreateObjectFromURL('ui://Main_RunBeard/Btn_Card')
btn_card:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeard/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 = 123 * self:getCardSize()
local x, y = 500, (j * 85) - 500
btn_card:SetXY(x, y)
self._area_handcard_list:AddChild(btn_card)
self._area_handcard_list:SetChildIndex(btn_card, 5 - j)
local card_view = NewCardView(btn_card, card_code, i, j)
--存牌堆
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 end
pokerListNum = pokerListNum + 1 for j = #self.card_list, 1, -1 do
local card_view = self.card_list[j] coroutine.wait(0.005)
card_view.btn_card:RemoveFromParent() if pokerListNum == #pokerList[i] then
self._area_handcard_list:AddChild(card_view.btn_card) break
card_view.btn_card:TweenMove(self:GetHandCardPos(card_view, self.cards_count), 0.08) 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
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 else
--没有发牌动画 --没有发牌动画
for i = 1, #pokerList do for i = 1, #pokerList do
@ -296,11 +290,9 @@ function M:InitHandCard(isPlayAni, index)
self:UpdateHandCardsPos() self:UpdateHandCardsPos()
end end
self:SetNotPutCard() self:SetNotPutCard()
end end
--更新手牌 --更新手牌
function M:UpdateHandCards(list) function M:UpdateHandCards(list)
self.card_list = {} self.card_list = {}
@ -341,7 +333,7 @@ function M:UpdateHandCards(list)
end end
end end
end end
self:SetNotPutCard() self:SetNotPutCard()
end end
-- 禁所有手牌 -- 禁所有手牌
@ -399,6 +391,7 @@ function M:ChuPaiTiShi()
self._view:GetController('chupai').selectedIndex = 0 self._view:GetController('chupai').selectedIndex = 0
end end
end end
-- 删手牌 -- 删手牌
function M:DeleteHandCard(carditem) function M:DeleteHandCard(carditem)
local card = nil local card = nil
@ -441,6 +434,7 @@ function M:DeleteHandCard(carditem)
end end
self:UpdateHandCardsPos() self:UpdateHandCardsPos()
end end
--更新手牌的坎 --更新手牌的坎
function M:UpdateKan(card) function M:UpdateKan(card)
for i = 1, #self.card_list do for i = 1, #self.card_list do
@ -485,6 +479,7 @@ function M:UpdateCardDisplay()
card_view.btn_card:TweenMove(self:GetHandCardPos(card_view, #CountCards), 0.3) card_view.btn_card:TweenMove(self:GetHandCardPos(card_view, #CountCards), 0.3)
end end
end end
--更新手牌大小 --更新手牌大小
function M:UpdateCardSize() function M:UpdateCardSize()
local CountCards = {} local CountCards = {}
@ -618,8 +613,8 @@ function M:__OnDragEnd(context)
if card_view ~= nil then if card_view ~= nil then
if if
button.x + button.width / 2 > card_view.old_postion.x and button.x + button.width / 2 > card_view.old_postion.x and
button.x + button.width / 2 < (card_view.old_postion.x + button.width) button.x + button.width / 2 < (card_view.old_postion.x + button.width)
then then
if card ~= card_view and #CountCards[i] < 4 and card.index_X ~= card_view.index_X then if card ~= card_view and #CountCards[i] < 4 and card.index_X ~= card_view.index_X then
MoveCardPos = i MoveCardPos = i
MoveCardY = #CountCards[i] + 1 MoveCardY = #CountCards[i] + 1
@ -633,16 +628,16 @@ function M:__OnDragEnd(context)
-- local MoveCardY = 0 -- local MoveCardY = 0
if if
button.x + button.width / 2 > card.old_postion.x and button.x + button.width / 2 > card.old_postion.x and
button.x + button.width / 2 < (card.old_postion.x + button.width) button.x + button.width / 2 < (card.old_postion.x + button.width)
then then
if #CountCards[card.index_X] > 1 then if #CountCards[card.index_X] > 1 then
for i = 1, #CountCards[card.index_X] do for i = 1, #CountCards[card.index_X] do
local _cv = CountCards[card.index_X][i] local _cv = CountCards[card.index_X][i]
if _cv ~= card then if _cv ~= card then
if if
button.y + button.height / 2 > _cv.btn_card.y and button.y + button.height / 2 > _cv.btn_card.y and
button.y + button.height / 2 < (_cv.btn_card.y + button.height) button.y + button.height / 2 < (_cv.btn_card.y + button.height)
then then
--向下移動 --向下移動
if ((button.y + button.height / 2) + 20) > (card.old_postion.y + button.height) then if ((button.y + button.height / 2) + 20) > (card.old_postion.y + button.height) then
--向上移動 --向上移動
@ -762,7 +757,7 @@ end
--计算手牌位置 --计算手牌位置
function M:GetHandCardPos(cards_view, cards) function M:GetHandCardPos(cards_view, cards)
local x, y = 0, 0 local x, y = 0, 0
local card_width = self.card_width -- 牌的宽度 local card_width = self.card_width - 5 -- 牌的宽度
local middle_x = self._area_handcard_list.width / 2 local middle_x = self._area_handcard_list.width / 2
local start_x = middle_x - (cards / 2 * (card_width)) local start_x = middle_x - (cards / 2 * (card_width))
x = start_x + (card_width) * (cards_view.index_X - 1) x = start_x + (card_width) * (cards_view.index_X - 1)
@ -856,8 +851,9 @@ end
function M:ClearOutCard() function M:ClearOutCard()
self._area_outcard_list:RemoveChildren(0, -1, true) self._area_outcard_list:RemoveChildren(0, -1, true)
-- self._bgview.selectedIndex = 0 -- self._bgview.selectedIndex = 0
end end
--出牌 --出牌
function M:UpdateOutCardList(outcard) function M:UpdateOutCardList(outcard)
self._area_outcard_list:RemoveChildren(0, -1, true) self._area_outcard_list:RemoveChildren(0, -1, true)
@ -869,7 +865,7 @@ function M:UpdateOutCardList(outcard)
end end
outcards.x, outcards.y = 0, 0 outcards.x, outcards.y = 0, 0
self._area_outcard_list:AddChild(outcards) self._area_outcard_list:AddChild(outcards)
-- self._bgview.selectedIndex = 1 -- self._bgview.selectedIndex = 1
end end
--弃牌 --弃牌
@ -887,12 +883,11 @@ function M:PlayingOutCardAnima(card)
if (self._area_outcard_list ~= nil and self._area_outcard_list.numChildren > 0) then 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_RunBeard/202_', card) self._area_outcard_list:GetChildAt(0):GetChild('icon').icon = self:getCardItem('ui://Main_RunBeard/202_', card)
self._view:GetTransition('t0'):Play() self._view:GetTransition('t0'):Play()
end end
coroutine.start( coroutine.start(
function() function()
coroutine.wait(0.1) coroutine.wait(0.1)
-- self._bgview.selectedIndex = 1 -- self._bgview.selectedIndex = 1
self:ClearOutCard() self:ClearOutCard()
end end
) )
@ -906,6 +901,7 @@ function M:getCardItem(card_1, card_2)
return card_1 .. '6_' .. card_2 return card_1 .. '6_' .. card_2
end end
end end
--得到设置的牌大小 --得到设置的牌大小
function M:getCardSize() function M:getCardSize()
if self._room.change_card_size ~= nil then if self._room.change_card_size ~= nil then