黎川四人手牌四人同步

master
罗家炜 2025-04-21 15:48:59 +08:00
parent 904f761f7c
commit b071af8324
4 changed files with 36 additions and 13 deletions

View File

@ -212,6 +212,7 @@ function M:InitPlayerInfoView()
end
function M:NewMJPlayerCardInfoView(view, index)
print("===============================NewMJPlayerCardInfoView")
if index == 1 then
return MJPlayerSelfCardInfoView.new(view, self)
end

View File

@ -116,21 +116,27 @@ end
function M:UpdateHandCard(getcard, mp)
print("==============================UpdateHandCardlingmeng", self._player.hand_left_count)
MJPlayerCardInfoView.UpdateHandCard(self, getcard, mp)
-- MJPlayerCardInfoView.UpdateHandCard(self, getcard, mp)
getcard = getcard or false
mp = mp or false
if self._view_handCardList.numItems > self._player.hand_left_count - 1 then
for i = 1, self._view_handCardList.numItems - self._player.hand_left_count + 1 do
self._view_handCardList:RemoveChildrenToPool()
end
end
for i = 0, self._player.hand_left_count - 1 do
-- local tempCard = UIPackage.CreateObjectFromURL("ui://v0j9abjygi9910w")
-- self._view_handCardList:AddChild(tempCard)
if getcard and i == self._player.hand_left_count - 1 then
self._ctr_getCard.selectedIndex = 1
else
if i >= self._view_handCardList.numItems then
self._view_handCardList:AddItemFromPool()
end
end
end
end
-- 获取麻将图片资源位置,可以在扩展中复写
function M:GetCardPicPack()

View File

@ -68,9 +68,10 @@ function M:ShowHuTip(card_list)
end
function M:UpdateHandCard(getcard, mp)
MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp)
-- MJPlayerSelfCardInfoView.UpdateHandCard(self, getcard, mp)
local _carViewList = self._carViewList
local card_list = DataManager.CurrenRoom.self_player.card_list
--[[
if DataManager.CurrenRoom.laiziInfo and #self._carViewList > 0 then
for i = 1, #self._carViewList do
local obj = self._carViewList[i]
@ -92,7 +93,7 @@ function M:UpdateHandCard(getcard, mp)
end
end
local card_list = DataManager.CurrenRoom.self_player.card_list
-- self:ShowHuTip(card_list)
if getcard then
self._out_card = true
@ -141,29 +142,36 @@ function M:UpdateHandCard(getcard, mp)
end
self._out_card = false
end
]]
-----------------------lingmeng---------------------------
getcard = getcard or false
mp = mp or false
local handCardName = self._viewText_cardInfo['Hand_Card']
if self._view_handCardList.numItems > #card_list - 1 then
for i = 1, self._view_handCardList.numItems - #card_list + 1 do
self._view_handCardList:RemoveChildrenToPool()
end
end
for i = 0, (#card_list) - 1 do
local tem_card = card_list[i + 1]
local btn_card
if getcard and i == (#card_list) - 1 then
btn_card = self._viewBtn_getCard
self._ctr_getCard.selectedIndex = 1
btn_card.onClick:Set(function(context)
self:__OnClickGetCard(context)
end)
else
if i >= self._view_handCardList.numItems then
btn_card = self._view_handCardList:AddItemFromPool()
self._ctr_getCard.selectedIndex = 0
else
btn_card = self._view_handCardList:GetChildAt(i)
end
end
self:fillCard2(btn_card, handCardName, tem_card)
local c_v = NewCardView(btn_card, tem_card)
c_v.index = i
@ -175,6 +183,13 @@ function M:UpdateHandCard(getcard, mp)
btn_card.onTouchMove:Set(handler(self, self.onTouchMove))
btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd))
end
if getcard then
self._ctr_getCard.selectedIndex = 1
else
self._ctr_getCard.selectedIndex = 0
end
print("lingmengself1", self._ctr_getCard.selectedIndex)
self._view_handCardList.onClickItem:Set(function(context)
self:__OnClickHandCard(context)
end)

View File

@ -65,6 +65,7 @@ function M:setHandCardPos(btn_card, i, getcard)
end
function M:UpdateHandCard(getcard, mp)
print("==========================UpdateHandCardold", getcard, mp)
if self.outcard_button then
self.outcard_button:Dispose()
self.outcard_button = nil