间距调小

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 self = {}
setmetatable(self, {__index = CardView})
setmetatable(self, { __index = CardView })
self.btn_card = card
self.card_item = cardItem
self.index_X = index_X
@ -42,7 +42,7 @@ local PlayerSelfCardInfoView = {
local M = PlayerSelfCardInfoView
function M.new(view, mainView)
local self = {}
setmetatable(self, {__index = M})
setmetatable(self, { __index = M })
self._view = view
self._mainView = mainView
self:init()
@ -52,7 +52,7 @@ end
function M:init()
local view = self._view
self._isDrg = false
self.card_list = {} -- 牌的btn code type pos 等等
self.card_list = {} -- 牌的btn code type pos 等等
self.cards_count = 0 -- 牌的总列数
self.card_width = 87
self.card_hight = 110
@ -60,18 +60,17 @@ function M:init()
self._room = DataManager.CurrenRoom
self._area_handcard_list = view:GetChild('area_handcard_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_qipai_list = view:GetChild('windcard_list')
self._mask_liangpai = view:GetChild('mask_liangpai')
UIPackage.AddPackage('base/main_zipai/ui/Main_RunBeard')
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:BtnEvent()
self:BtnEvent()
end
function M:ShwoDaNiao(niao)
self.ctr_niao.selectedIndex = 1
end
@ -81,50 +80,45 @@ function M:HideDaNiao(niao)
end
function M:ShowPiao(piao)
self:UpdateIsOnClick(true)
self:UpdateIsOnClick(true)
self.ctr_niao.selectedIndex = piao
-- self:EnableAllPiaoTouch()
-- self:EnableAllPiaoTouch()
end
function M:HidePiao()
self.ctr_niao.selectedIndex = 0
end
function M:BtnEvent()
self.btn_tips = self._view:GetChild('btn_tips')
local function click_niao1(vaule)
local closeNiaoTipsFunc=function ()
self.ctr_niao.selectedIndex = 0
end
ControllerManager.GetController(GameController):SendNiao(1,closeNiaoTipsFunc)
local closeNiaoTipsFunc = function()
self.ctr_niao.selectedIndex = 0
end
ControllerManager.GetController(GameController):SendNiao(1, closeNiaoTipsFunc)
end
local function click_niao0(vaule)
local closeNiaoTipsFunc=function ()
self.ctr_niao.selectedIndex = 0
end
ControllerManager.GetController(GameController):SendNiao(0,closeNiaoTipsFunc)
local closeNiaoTipsFunc = function()
self.ctr_niao.selectedIndex = 0
end
ControllerManager.GetController(GameController):SendNiao(0, closeNiaoTipsFunc)
end
local btn_budaniao = self._view:GetChild("budaniao")
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)
end
function M:EnableAllPiaoTouch()
for i=1,#self.PiaoList do
self.PiaoList[i].touchable=true
end
for i = 1, #self.PiaoList do
self.PiaoList[i].touchable = true
end
end
function M:SetPlayer(p)
self._player = p
end
@ -135,7 +129,7 @@ end
function M:Clear()
self.outcard_button = nil
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_handcard_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)
end
function M:ShowHuTip(card)
if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then
local x = {}
@ -173,14 +168,13 @@ function M:ShowHuTip(card)
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
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
--手牌
@ -207,58 +201,58 @@ function M:InitHandCard(isPlayAni, index)
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 = 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))
function()
self._mainView._popEvent = false
if self._mainView._rightPanelView._settingView ~= nil then
self._mainView._rightPanelView._settingView:SetBtnUpdateCardEnable(false)
end
for j = #self.card_list, 1, -1 do
coroutine.wait(0.005)
if pokerListNum == #pokerList[i] then
break
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
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)
for j = #self.card_list, 1, -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
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
@ -296,11 +290,9 @@ function M:InitHandCard(isPlayAni, index)
self:UpdateHandCardsPos()
end
self:SetNotPutCard()
self:SetNotPutCard()
end
--更新手牌
function M:UpdateHandCards(list)
self.card_list = {}
@ -341,7 +333,7 @@ function M:UpdateHandCards(list)
end
end
end
self:SetNotPutCard()
self:SetNotPutCard()
end
-- 禁所有手牌
@ -399,6 +391,7 @@ function M:ChuPaiTiShi()
self._view:GetController('chupai').selectedIndex = 0
end
end
-- 删手牌
function M:DeleteHandCard(carditem)
local card = nil
@ -441,6 +434,7 @@ function M:DeleteHandCard(carditem)
end
self:UpdateHandCardsPos()
end
--更新手牌的坎
function M:UpdateKan(card)
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)
end
end
--更新手牌大小
function M:UpdateCardSize()
local CountCards = {}
@ -618,8 +613,8 @@ function M:__OnDragEnd(context)
if card_view ~= nil then
if
button.x + button.width / 2 > card_view.old_postion.x and
button.x + button.width / 2 < (card_view.old_postion.x + button.width)
then
button.x + button.width / 2 < (card_view.old_postion.x + button.width)
then
if card ~= card_view and #CountCards[i] < 4 and card.index_X ~= card_view.index_X then
MoveCardPos = i
MoveCardY = #CountCards[i] + 1
@ -633,16 +628,16 @@ function M:__OnDragEnd(context)
-- local MoveCardY = 0
if
button.x + button.width / 2 > card.old_postion.x and
button.x + button.width / 2 < (card.old_postion.x + button.width)
then
button.x + button.width / 2 < (card.old_postion.x + button.width)
then
if #CountCards[card.index_X] > 1 then
for i = 1, #CountCards[card.index_X] do
local _cv = CountCards[card.index_X][i]
if _cv ~= card then
if
button.y + button.height / 2 > _cv.btn_card.y and
button.y + button.height / 2 < (_cv.btn_card.y + button.height)
then
button.y + button.height / 2 < (_cv.btn_card.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)
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 start_x = middle_x - (cards / 2 * (card_width))
x = start_x + (card_width) * (cards_view.index_X - 1)
@ -856,8 +851,9 @@ end
function M:ClearOutCard()
self._area_outcard_list:RemoveChildren(0, -1, true)
-- self._bgview.selectedIndex = 0
-- self._bgview.selectedIndex = 0
end
--出牌
function M:UpdateOutCardList(outcard)
self._area_outcard_list:RemoveChildren(0, -1, true)
@ -869,7 +865,7 @@ function M:UpdateOutCardList(outcard)
end
outcards.x, outcards.y = 0, 0
self._area_outcard_list:AddChild(outcards)
-- self._bgview.selectedIndex = 1
-- self._bgview.selectedIndex = 1
end
--弃牌
@ -887,12 +883,11 @@ 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_RunBeard/202_', card)
self._view:GetTransition('t0'):Play()
end
coroutine.start(
function()
coroutine.wait(0.1)
-- self._bgview.selectedIndex = 1
-- self._bgview.selectedIndex = 1
self:ClearOutCard()
end
)
@ -906,6 +901,7 @@ function M:getCardItem(card_1, card_2)
return card_1 .. '6_' .. card_2
end
end
--得到设置的牌大小
function M:getCardSize()
if self._room.change_card_size ~= nil then