黎川二人,四人自动布局正式完成

master
罗家炜 2025-04-22 20:30:41 +08:00
parent 7bf51f5168
commit b86601898b
4 changed files with 36 additions and 13 deletions

View File

@ -129,15 +129,13 @@ function M:UpdateHandCard(getcard, mp)
getcard = getcard or false getcard = getcard or false
mp = mp or false mp = mp or false
self._view_handCardList:RemoveChildren()
for i = 0, self._player.hand_left_count - 1 do for i = 0, self._player.hand_left_count - 1 do
if getcard and i == self._player.hand_left_count - 1 then -- if i >= self._view_handCardList.numItems then
self._ctr_getCard.selectedIndex = 1 self._view_handCardList:AddItemFromPool()
else -- end
if i >= self._view_handCardList.numItems then
self._view_handCardList:AddItemFromPool()
end
end
end end
self._ctr_getCard.selectedIndex = getcard and 1 or 0
end end
-- 获取麻将图片资源位置,可以在扩展中复写 -- 获取麻将图片资源位置,可以在扩展中复写

View File

@ -36,6 +36,7 @@ function M.new(view, mainView)
end end
function M:init() function M:init()
print("lingmenginithand")
MJPlayerSelfCardInfoView.init(self) MJPlayerSelfCardInfoView.init(self)
local CardInfo = self._view:GetChild('Text_CardInfo') local CardInfo = self._view:GetChild('Text_CardInfo')
@ -44,7 +45,7 @@ function M:init()
self._view_handCardList = self._view:GetChild('List_HandCard') self._view_handCardList = self._view:GetChild('List_HandCard')
self._view_FZList = self._view:GetChild('List_FZ') self._view_FZList = self._view:GetChild('List_FZ')
self._view_outCardList = self._view:GetChild('List_OutCard') self._view_outCardList = self._view:GetChild('List_OutCard')
self._viewBtn_getCard = self._view:GetChild('Btn_HandCard') self._view_getCard = self._view:GetChild('Btn_HandCard')
self._ctr_getCard = self._view:GetController('getCard') self._ctr_getCard = self._view:GetController('getCard')
self._ctr_seletedGet = self._view:GetController('seletedGetCard') self._ctr_seletedGet = self._view:GetController('seletedGetCard')
@ -147,41 +148,60 @@ function M:UpdateHandCard(getcard, mp)
-----------------------lingmeng--------------------------- -----------------------lingmeng---------------------------
print("lingmenghand", getcard)
getcard = getcard or false getcard = getcard or false
mp = mp or false mp = mp or false
local handCardName = self._viewText_cardInfo['Hand_Card'] local handCardName = self._viewText_cardInfo['Hand_Card']
-- if self._view_handCardList.numItems > #card_list - 1 then -- if self._view_handCardList.numItems > #card_list - 1 then
self._view_handCardList:RemoveChildren() self._view_handCardList:RemoveChildren()
self._view_getCard:RemoveChildren()
-- end -- end
print("lingmenghand1", #card_list)
pt(card_list)
for i = 0, (#card_list) - 1 do for i = 0, (#card_list) - 1 do
local tem_card = card_list[i + 1] local tem_card = card_list[i + 1]
local btn_card local btn_card
print("lingmenghand2", i)
if getcard and i == (#card_list) - 1 then if getcard and i == (#card_list) - 1 then
btn_card = self._viewBtn_getCard btn_card = self._view_getCard:AddItemFromPool()
btn_card.onClick:Set(function(context) print("lingmenghand2-1-1")
-- btn_card = self._view:GetChild('Btn_HandCard')
btn_card.onClick:Add(function(context)
self:__OnClickGetCard(context) self:__OnClickGetCard(context)
end) end)
print("lingmenghand2-1-2")
print("===================lingmengcuowulail==============")
else else
print("lingmenghand2-2-1")
-- if i >= self._view_handCardList.numItems then -- if i >= self._view_handCardList.numItems then
btn_card = self._view_handCardList:AddItemFromPool() btn_card = self._view_handCardList:AddItemFromPool()
-- else -- else
-- btn_card = self._view_handCardList:GetChildAt(i) -- btn_card = self._view_handCardList:GetChildAt(i)
-- end -- end
print("lingmenghand2-2-2")
end end
self:fillCard2(btn_card, handCardName, tem_card) print("lingmenghandbuchong", btn_card, handCardName, tem_card)
print("lingmenghandbuchong2", btn_card:GetChild("icon"), btn_card:GetChild("icon").url)
btn_card.icon = 'ui://Main_Majiang/' .. handCardName .. tem_card
-- self:fillCard2(btn_card, handCardName, tem_card)
print("lingmenghand2-3")
local c_v = NewCardView(btn_card, tem_card) local c_v = NewCardView(btn_card, tem_card)
c_v.index = i c_v.index = i
c_v.old_postion = btn_card.xy c_v.old_postion = btn_card.xy
_carViewList[#_carViewList + 1] = c_v _carViewList[#_carViewList + 1] = c_v
btn_card.data = c_v btn_card.data = c_v
print("lingmenghand2-4")
btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin)) btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin))
btn_card.onTouchMove:Set(handler(self, self.onTouchMove)) btn_card.onTouchMove:Set(handler(self, self.onTouchMove))
btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd)) btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd))
-- btn_card.onClick:Set(handler(self, self.__OnClickHandCard)) -- btn_card.onClick:Set(handler(self, self.__OnClickHandCard))
print("lingmenghand2-5")
end end
print("lingmenghand3", getcard, self._ctr_getCard)
if getcard then if getcard then
self._ctr_getCard.selectedIndex = 1 self._ctr_getCard.selectedIndex = 1
@ -191,7 +211,7 @@ function M:UpdateHandCard(getcard, mp)
self._view_handCardList.onClickItem:Set(function(context) self._view_handCardList.onClickItem:Set(function(context)
self:__OnClickHandCard(context) self:__OnClickHandCard(context)
end) end)
print("lingmenghand4")
---------------------------------------------------------- ----------------------------------------------------------
end end
@ -281,7 +301,7 @@ end
function M:__OnClickHandCard(context) function M:__OnClickHandCard(context)
print("=======================lingmengclickhand") print("=======================lingmengclickhand")
self._ctr_seletedGet.selectedIndex = 0 self._ctr_seletedGet.selectedIndex = 1
local button = context.data local button = context.data
-- local _carViewList = self._carViewList -- local _carViewList = self._carViewList
-- for i = 1, #_carViewList do -- for i = 1, #_carViewList do
@ -403,10 +423,12 @@ function M:Clear(bskip)
self._view_handCardList:RemoveChildren(0, -1, true) self._view_handCardList:RemoveChildren(0, -1, true)
self._view_outCardList:RemoveChildren(0, -1, true) self._view_outCardList:RemoveChildren(0, -1, true)
self._view_FZList:RemoveChildren(0, -1, true) self._view_FZList:RemoveChildren(0, -1, true)
self._view_getCard:RemoveChildren(0, -1, true)
self._view_handCardList.selectedIndex = -1 self._view_handCardList.selectedIndex = -1
self._click_index = self._view_handCardList.selectedIndex self._click_index = self._view_handCardList.selectedIndex
self._ctr_seletedGet.selectedIndex = 0 self._ctr_seletedGet.selectedIndex = 0
if bskip == nil or bskip == false then if bskip == nil or bskip == false then
self._mask_liangpai:RemoveChildren(0, -1, true) self._mask_liangpai:RemoveChildren(0, -1, true)
end end

View File

@ -131,7 +131,10 @@ function M:fillCard2(obj, pos_str, card)
if DataManager.CurrenRoom.jing and card == DataManager.CurrenRoom.jing and obj:GetController('jing') then if DataManager.CurrenRoom.jing and card == DataManager.CurrenRoom.jing and obj:GetController('jing') then
obj:GetController('jing').selectedIndex = 1 obj:GetController('jing').selectedIndex = 1
end end
print("lingmenghandfill1")
obj:GetChild("icon").url = 'ui://Main_Majiang/' .. pos_str .. card obj:GetChild("icon").url = 'ui://Main_Majiang/' .. pos_str .. card
print("lingmenghandfill2")
end end
function M:getBackCard(card) function M:getBackCard(card)