2025-04-22 14:36:02 +08:00
|
|
|
local MJPlayerCardInfoView = import(".MJPlayerCardInfoView_jiangxi")
|
2025-04-22 14:14:08 +08:00
|
|
|
|
|
|
|
|
local CardView = {
|
|
|
|
|
card = nil,
|
|
|
|
|
-- 牌序号
|
|
|
|
|
card_item = 0,
|
|
|
|
|
-- 索引
|
|
|
|
|
index = 0,
|
|
|
|
|
-- 原始位置
|
|
|
|
|
old_postion = Vector2.zero
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local function NewCardView(card, cardItem)
|
|
|
|
|
local self = {}
|
|
|
|
|
setmetatable(self, { __index = CardView })
|
|
|
|
|
self.card = card
|
|
|
|
|
self.card_item = cardItem
|
|
|
|
|
return self
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local PlayerSelfView = {
|
|
|
|
|
_dragCom = nil,
|
|
|
|
|
_carViewList = {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local M = PlayerSelfView
|
|
|
|
|
|
|
|
|
|
function PlayerSelfView.new(view, mainView)
|
|
|
|
|
setmetatable(M, { __index = MJPlayerCardInfoView })
|
|
|
|
|
local self = setmetatable({}, { __index = M })
|
|
|
|
|
self._view = view
|
|
|
|
|
self._mainView = mainView
|
|
|
|
|
self:init()
|
|
|
|
|
return self
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:init()
|
|
|
|
|
MJPlayerCardInfoView.init(self)
|
2025-04-24 20:33:09 +08:00
|
|
|
|
|
|
|
|
self._view_getCard = self._view:GetChild('Btn_HandCard')
|
2025-04-25 15:09:34 +08:00
|
|
|
self._view_FZTips = self._view:GetChild('Comp_FZTips')
|
|
|
|
|
|
2025-04-24 20:33:09 +08:00
|
|
|
self._ctr_seletedGet = self._view:GetController('seletedGetCard')
|
2025-04-25 15:09:34 +08:00
|
|
|
self._ctr_tip = self._view:GetController('tip')
|
2025-04-24 20:33:09 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:ShowHuTip(card_list)
|
|
|
|
|
printlog("ShowHuTip")
|
|
|
|
|
local tingList = CardCheck.MuiltiplteCaculateTingPai(card_list, true, DataManager.CurrenRoom.room_config.Qidui,
|
|
|
|
|
DataManager.CurrenRoom.room_config.Laizi)
|
|
|
|
|
pt(tingList)
|
|
|
|
|
if #tingList > 0 then
|
|
|
|
|
if DataManager.CurrenRoom.laiziInfo and #DataManager.CurrenRoom.laiziInfo > 0 then
|
|
|
|
|
for i = 1, #DataManager.CurrenRoom.laiziInfo do
|
|
|
|
|
if IsHasDictionary(DataManager.CurrenRoom.laiziInfo[i], tingList) == false then
|
|
|
|
|
table.insert(tingList, DataManager.CurrenRoom.laiziInfo[i])
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
self._mainView._hu_tip:FillData(tingList)
|
2025-04-22 14:14:08 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:UpdateHandCard(getcard, mp)
|
2025-04-24 17:10:13 +08:00
|
|
|
local _carViewList = self._carViewList
|
|
|
|
|
local card_list = DataManager.CurrenRoom.self_player.card_list
|
|
|
|
|
|
2025-04-22 14:14:08 +08:00
|
|
|
getcard = getcard or false
|
|
|
|
|
mp = mp or false
|
|
|
|
|
|
2025-04-24 17:10:13 +08:00
|
|
|
local handCardName = self._viewText_cardInfo['Hand_Card']
|
|
|
|
|
|
|
|
|
|
if self._view_handCardList.numItems > 0 then
|
|
|
|
|
self._view_handCardList:RemoveChildren()
|
2025-04-22 14:14:08 +08:00
|
|
|
end
|
2025-04-24 17:41:31 +08:00
|
|
|
if self._view_getCard.numItems > 0 then
|
2025-04-24 17:10:13 +08:00
|
|
|
self._view_getCard:RemoveChildren()
|
2025-04-22 14:14:08 +08:00
|
|
|
end
|
|
|
|
|
|
2025-04-24 17:10:13 +08:00
|
|
|
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._view_getCard:AddItemFromPool()
|
|
|
|
|
btn_card.onClick:Add(function(context)
|
|
|
|
|
self:__OnClickGetCard(context)
|
|
|
|
|
end)
|
|
|
|
|
else
|
|
|
|
|
btn_card = self._view_handCardList:AddItemFromPool()
|
|
|
|
|
end
|
|
|
|
|
self:fillCard2(btn_card, handCardName, tem_card)
|
|
|
|
|
local c_v = NewCardView(btn_card, tem_card)
|
|
|
|
|
c_v.index = i
|
|
|
|
|
c_v.old_postion = btn_card.xy
|
|
|
|
|
btn_card.data = c_v
|
|
|
|
|
btn_card.onTouchBegin:Set(handler(self, self.onTouchBegin))
|
|
|
|
|
btn_card.onTouchMove:Set(handler(self, self.onTouchMove))
|
|
|
|
|
btn_card.onTouchEnd:Set(handler(self, self.__OnDragEnd))
|
2025-04-24 20:33:09 +08:00
|
|
|
-- btn_card.onClick:Set(handler(self, self.__OnClickHandCard))
|
2025-04-22 14:14:08 +08:00
|
|
|
end
|
|
|
|
|
|
2025-04-24 17:10:13 +08:00
|
|
|
if getcard then
|
|
|
|
|
self._ctr_getCard.selectedIndex = 1
|
2025-04-22 14:14:08 +08:00
|
|
|
else
|
2025-04-24 17:10:13 +08:00
|
|
|
self._ctr_getCard.selectedIndex = 0
|
2025-04-22 14:14:08 +08:00
|
|
|
end
|
2025-04-24 17:10:13 +08:00
|
|
|
self._view_handCardList.onClickItem:Set(function(context)
|
|
|
|
|
self:__OnClickHandCard(context)
|
|
|
|
|
end)
|
2025-04-22 14:14:08 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:onTouchBegin(context)
|
|
|
|
|
local button = context.sender
|
2025-04-24 17:10:13 +08:00
|
|
|
self._touchPos = button.xy
|
2025-04-22 14:14:08 +08:00
|
|
|
local card = button.data
|
2025-04-24 17:10:13 +08:00
|
|
|
self._touchIndex = card.index
|
|
|
|
|
local xy = self._view_handCardList:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y))
|
2025-04-22 14:14:08 +08:00
|
|
|
card.touch_pos = xy - button.xy
|
|
|
|
|
if self.__OnDragStart then
|
|
|
|
|
self:__OnDragStart(card.card_item)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:onTouchMove(context)
|
|
|
|
|
local button = context.sender
|
2025-04-24 17:10:13 +08:00
|
|
|
|
2025-04-22 14:14:08 +08:00
|
|
|
local card = button.data
|
2025-04-24 17:10:13 +08:00
|
|
|
local xy = self._view_handCardList:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y))
|
2025-04-22 14:14:08 +08:00
|
|
|
button.xy = xy - card.touch_pos
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:__OnDragEnd(context)
|
|
|
|
|
local button = context.sender
|
2025-04-24 17:10:13 +08:00
|
|
|
|
2025-04-22 14:14:08 +08:00
|
|
|
local card = button.data
|
|
|
|
|
local _room = DataManager.CurrenRoom
|
|
|
|
|
if not _room or _room:GetReloadStatus() then return end
|
|
|
|
|
|
|
|
|
|
if (button.y < -150 and _room.curren_outcard_seat == _room.self_player.seat) then
|
|
|
|
|
self._mainView:OutCard(card.card_item)
|
|
|
|
|
button.touchable = false
|
2025-04-24 17:10:13 +08:00
|
|
|
self.outcard_button = button
|
|
|
|
|
button.xy = self._touchPos
|
2025-04-22 14:14:08 +08:00
|
|
|
else
|
2025-04-24 17:10:13 +08:00
|
|
|
if self._touchIndex ~= card.index then
|
|
|
|
|
-- local tempPos = self._touchPos
|
|
|
|
|
-- self._touchPos = button.xy
|
|
|
|
|
-- button:TweenMove(tempPos, 0.2)
|
|
|
|
|
else
|
|
|
|
|
button:TweenMove(self._touchPos, 0.2)
|
|
|
|
|
self._touchPos = -1
|
|
|
|
|
self._touchIndex = -1
|
|
|
|
|
end
|
2025-04-22 14:14:08 +08:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:__OnClickHandCard(context)
|
2025-04-24 17:10:13 +08:00
|
|
|
self._ctr_seletedGet.selectedIndex = 1
|
|
|
|
|
local button = context.data
|
|
|
|
|
|
|
|
|
|
local _room = DataManager.CurrenRoom
|
|
|
|
|
if ((Utils.IsDoubleClick(context) or self._click_index == self._view_handCardList.selectedIndex) and _room.curren_outcard_seat == _room.self_player.seat) then
|
|
|
|
|
local card = button.data
|
|
|
|
|
self._mainView:OutCard(card.card_item)
|
|
|
|
|
self._view_handCardList.selectedIndex = -1
|
|
|
|
|
self._click_index = self._view_handCardList.selectedIndex
|
|
|
|
|
self._ctr_seletedGet.selectedIndex = 0
|
2025-04-22 14:14:08 +08:00
|
|
|
end
|
2025-04-24 17:10:13 +08:00
|
|
|
self._click_index = self._view_handCardList.selectedIndex
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:__OnClickGetCard(context)
|
|
|
|
|
self._view_handCardList.selectedIndex = -1
|
|
|
|
|
local button = context.sender
|
2025-04-22 14:14:08 +08:00
|
|
|
local _room = DataManager.CurrenRoom
|
|
|
|
|
if (Utils.IsDoubleClick(context) and _room.curren_outcard_seat == _room.self_player.seat) then
|
|
|
|
|
local card = button.data
|
|
|
|
|
self._mainView:OutCard(card.card_item)
|
2025-04-24 17:10:13 +08:00
|
|
|
self._view_handCardList.selectedIndex = -1
|
|
|
|
|
self._click_index = self._view_handCardList.selectedIndex
|
|
|
|
|
self._ctr_seletedGet.selectedIndex = 0
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-04-25 11:11:29 +08:00
|
|
|
-- function M:UpdateFzList(fz, index, show_card)
|
|
|
|
|
-- -- local FZame = self._viewText_cardInfo['FZ_Card']
|
|
|
|
|
-- local FZame = "202_"
|
|
|
|
|
-- index = index or 0
|
|
|
|
|
-- show_card = show_card or nil
|
|
|
|
|
|
|
|
|
|
-- local outCard
|
|
|
|
|
|
|
|
|
|
-- outCard = self._view_FZList:AddItemFromPool()
|
|
|
|
|
|
|
|
|
|
-- if fz.type == FZType.Chi then
|
|
|
|
|
-- for i = 1, 3 do
|
|
|
|
|
-- local FZCard = outCard:GetChild(string.format("Comp_Card%d", i))
|
|
|
|
|
-- self:fillCard2(FZCard, FZame, fz.opcard[i])
|
|
|
|
|
-- end
|
|
|
|
|
-- else
|
|
|
|
|
-- local ctr_Four = outCard:GetController("isFour")
|
|
|
|
|
-- for i = 1, 3 do
|
|
|
|
|
-- local FZCard = outCard:GetChild(string.format("Comp_Card%d", i))
|
|
|
|
|
-- self:fillCard2(FZCard, FZame, fz.card)
|
|
|
|
|
-- end
|
|
|
|
|
-- if fz.type == FZType.Peng then
|
|
|
|
|
-- ctr_Four.selectedIndex = 0
|
|
|
|
|
-- else
|
|
|
|
|
-- ctr_Four.selectedIndex = 1
|
|
|
|
|
-- local FZCard = outCard:GetChild(string.format("Comp_Card%d", 4))
|
|
|
|
|
-- self:fillCard2(FZCard, FZame, fz.card)
|
|
|
|
|
-- if fz.type == FZType.Gang_An then
|
|
|
|
|
-- self:fillCard2(FZCard, FZame, '00')
|
|
|
|
|
-- elseif fz.type == FZType.Gang_Peng then
|
|
|
|
|
-- self._view_FZList:RemoveChildAt(self._view_FZList.numItems - 2)
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
|
|
|
|
-- end
|
2025-04-22 14:14:08 +08:00
|
|
|
|
|
|
|
|
-- 获取手牌资源位置,可以在扩展中复写
|
|
|
|
|
function M:GetCardObjPack()
|
|
|
|
|
return "Main_Majiang"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:Clear()
|
|
|
|
|
MJPlayerCardInfoView.Clear(self)
|
2025-04-24 20:33:09 +08:00
|
|
|
|
2025-04-25 15:09:34 +08:00
|
|
|
self._view_FZTips:RemoveChildren(0, -1, true)
|
|
|
|
|
|
2025-04-24 20:33:09 +08:00
|
|
|
self._ctr_seletedGet.selectedIndex = 0
|
2025-04-22 14:14:08 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return M
|