local PlayerSelfCardInfoView = require('main.zipai.ZPPlayerSelfCardInfoView') local CardCheck = import('.CardCheck') local checkHuxi = import('.checkHuxi') local PendulumRule = import('.PendulumRule') AreaOderType = { left_right = 'left_right', right_left = 'right_left', up_down = 'up_down', down_up = 'down_up' } local CardView = { btn_card = nil, -- 牌序号 card_item = 0, -- 牌层级 Hierarchy = 0, -- 牌的列数 index_X = 0, -- 每一列第几张牌 index_Y = 0, -- 原始位置 old_postion = Vector2.zero } local function NewCardView(card, cardItem, index_X, index_Y) local self = {} setmetatable(self, {__index = CardView}) self.btn_card = card self.card_item = cardItem self.index_X = index_X self.index_Y = index_Y return self end local PlayerSelfCardInfoView = { _view = nil, _mainView = nil, _mask_liangpai = nil, _area_outcard_list = nil, _area_handcard_list = nil, _dragCom = nil } local M = PlayerSelfCardInfoView function M.new(view, mainView) local self = {} setmetatable(self, {__index = M}) self._view = view self._mainView = mainView self:init() return self end function M:init() local view = self._view self._isDrg = false self.card_list = {} -- 牌的btn code type pos 等等 self.cards_count = 0 -- 牌的总列数 self.card_width = 87 self.card_hight = 110 self.outcard_button = nil self.movecard_button = nil self._room = DataManager.CurrenRoom self._area_handcard_list = view:GetChild('area_handcard_list') self._area_outcard_list = view:GetChild('area_outcard_list') 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') end function M:SetPlayer(p) self._player = p end function M:FillData(begin) end function M:Clear() self.outcard_button = nil self.movecard_button = nil self._area_outcard_list:RemoveChildren(0, -1, true) self._area_fz_list:RemoveChildren(0, -1, true) self._area_handcard_list:RemoveChildren(0, -1, true) self._area_qipai_list:RemoveChildren(0, -1, true) self._mask_liangpai:RemoveChildren(0, -1, true) self.card_list = {} end function M:fillCard(obj, card_type, cards) end function M:ShowHuTip(card, ischupai, showtinglist) print("jefe ShowHuTip") if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then local x = {} self._mainView._hu_tip:FillData(x) return end local tingList = {} if showtinglist == nil then local self_tinglist = DataManager.CurrenRoom.tinglist if card ~= nil and self_tinglist ~= nil and #self_tinglist > 0 then for i = 1, #self_tinglist do local itemCard = self_tinglist[i].card if itemCard ~= nil and itemCard == card then tingList = self_tinglist[i].ting_list end end end else tingList = showtinglist end if tingList == nil then tingList = {} end if ischupai then tingList = {} end if self._mainView._hu_tip ~= nil then self._mainView._hu_tip:FillData(tingList) end print("jefe ShowHuTip end") end function M:InitHandCard(isPlayAni, index, ischeck) if ischeck == nil then ischeck = false end local _dragCom = self._dragCom if (_dragCom == nil) then _dragCom = UIPackage.CreateObject('Common', 'UIPanel') _dragCom.size = Vector2(1, 1) self._view:AddChild(_dragCom) end _dragCom.xy = self._area_handcard_list.xy self._dragCom = _dragCom self._dragCom:RemoveChildren(0, -1, true) self.outcard_button = nil self.movecard_button = nil if self.cor_init_poker ~= nil then coroutine.stop(self.cor_init_poker) end self.cor_init_poker = nil local _room = DataManager.CurrenRoom local pokerList = PendulumRule.GetHandCard(_room.self_player.handcard_list, index) if pokerList == nil or #pokerList == 0 then return end self.cards_count = #pokerList self.card_list = {} if isPlayAni then self._area_handcard_list:SetScale(0, 0) end self._area_handcard_list:RemoveChildren(0, -1, true) for i = 1, #pokerList do 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 = 87 * self:getCardSize() self.card_hight = 110 * self:getCardSize() local x, y = 500, (j * 75) - 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 if not ischeck then 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 --存牌堆 for j = 1, #self.card_list do local card_view = self.card_list[j] card_view.btn_card.xy = self:GetHandCardPos(card_view, self.cards_count) end end end if isPlayAni == true then DSTween.To( 0, 1, 0.2, function(value) self._area_handcard_list:SetScale(value, value) end ) end self:UpdateHandCardsPos() self._mainView._popEvent = true self:UpdateIsOnClick(true) if isPlayAni == true then if self._mainView._rightPanelView._settingView ~= nil then coroutine.start( function() coroutine.wait(1) self._mainView._rightPanelView._settingView:SetBtnUpdateCardEnable(true) end ) end end end function M:UpdateHandCards(list) self.card_list = {} self._area_handcard_list:RemoveChildren(0, -1, true) local _dragCom = self._dragCom if (_dragCom == nil) then _dragCom = UIPackage.CreateObject('Common', 'UIPanel') _dragCom.size = Vector2(1, 1) self._view:AddChild(_dragCom) end _dragCom.xy = self._area_handcard_list.xy self._dragCom = _dragCom self._dragCom:RemoveChildren(0, -1, true) self.outcard_button = nil local CountCards = {} for i = 1, #list do CountCards[list[i].index_X] = CountCards[list[i].index_X] == nil and 1 or CountCards[list[i].index_X] + 1 end for i = 1, #list do local card_code = list[i].card_item 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 = 87 * self:getCardSize() self.card_hight = 110 * self:getCardSize() local card_view = NewCardView(btn_card, card_code, list[i].index_X, list[i].index_Y) --存牌堆 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 local suocard = {} if self._room ~= nil then suocard = self._room.suoCard end for j = #self.card_list, 1, -1 do local card_view = self.card_list[j] if card_view ~= nil then card_view.btn_card:RemoveFromParent() self._area_handcard_list:AddChild(card_view.btn_card) if suocard ~= nil and #suocard > 0 then if list_check(suocard, card_view.card_item) then card_view.btn_card:GetController('Kan').selectedIndex = 1 else card_view.btn_card:GetController('Kan').selectedIndex = 0 end else card_view.btn_card:GetController('Kan').selectedIndex = 0 end card_view.btn_card.xy = self:GetHandCardPos(card_view, #CountCards) end end end function M:onTouchBegin(context) if DataManager.CurrenRoom == nil then return end local button = context.sender local card = button.data if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then self:ShowHuTip(card.card_item) end card.btn_card:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeard/203_', card.card_item) card.btn_card.sortingOrder = 100 local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) card.btn_card.xy = Vector2.New(card.btn_card.x + 20, card.btn_card.y - 50) card.touch_pos = xy - button.xy end function M:onTouchMove(context) local button = context.sender local card = button.data local xy = self._area_handcard_list:GlobalToLocal(Vector2.New(context.inputEvent.x, context.inputEvent.y)) button.xy = xy - card.touch_pos end function M:ChuPaiTiShi(showtinglist) print("jefe ChuPaiTiShi") if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end local mark_ting = {} local self_tinglist = DataManager.CurrenRoom.tinglist if self_tinglist == nil then self_tinglist = {} end if #self_tinglist > 0 then for i = 1, #self_tinglist do local itemCard = self_tinglist[i].card local itemTingList = self_tinglist[i].ting_list if itemTingList ~= nil and #itemTingList > 0 then mark_ting[#mark_ting + 1] = itemCard end end end print("jefe ChuPaiTiShi DataManager.CurrenRoom.self_player.seat") if DataManager.CurrenRoom.curren_outcard_seat == DataManager.CurrenRoom.self_player.seat then self._view:GetController('chupai').selectedIndex = 1 if #mark_ting > 0 then for i = 1, #mark_ting do for k = 1, #self.card_list do local card_view = self.card_list[k] if card_view.card_item == mark_ting[i] then card_view.btn_card:GetController('mark_ting').selectedIndex = 1 end end end end else self._view:GetController('chupai').selectedIndex = 0 for k = 1, #self.card_list do local card_view = self.card_list[k] card_view.btn_card:GetController('mark_ting').selectedIndex = 0 end end if #mark_ting <= 0 and showtinglist ~= nil then self:ShowHuTip(nil, false, showtinglist) end end function M:outcardChuPaiTiShi() self._view:GetController('chupai').selectedIndex = 0 for k = 1, #self.card_list do local card_view = self.card_list[k] card_view.btn_card:GetController('mark_ting').selectedIndex = 0 end end function M:DeleteHandCard(carditem) local card = nil if self.outcard_button ~= nil and carditem == self.outcard_button.card_item then list_remove(self.card_list, self.outcard_button) self._area_handcard_list:RemoveChild(self.outcard_button.btn_card, true) self._dragCom:RemoveChildren(0, -1, true) card = self.outcard_button self.outcard_button = nil if self.movecard_button then self.movecard_button = nil end else for i = 1, #self.card_list do local card_view = self.card_list[i] if carditem == card_view.card_item then card_view.btn_card.touchable = false list_remove(self.card_list, card_view) card = card_view --card_view.btn_card:RemoveFromParent() self._area_handcard_list:RemoveChild(card_view.btn_card, true) break end end end if card ~= nil then local num = 0 for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end if card.index_X == self.card_list[i].index_X then num = num + 1 end end if num == 0 then for i = 1, #self.card_list do if self.card_list[i].index_X > card.index_X then self.card_list[i].index_X = self.card_list[i].index_X - 1 end end end end self:UpdateHandCardsPos() end function M:UpdateHandCardsPos() local CountCards = {} for i = 1, #self.card_list do CountCards[self.card_list[i].index_X] = CountCards[self.card_list[i].index_X] == nil and 1 or CountCards[self.card_list[i].index_X] + 1 end local suocard = {} if self._room ~= nil then suocard = self._room.suoCard end print("jefe UpdateHandCardsPos") for i = #self.card_list, 1, -1 do local card_view = self.card_list[i] card_view.btn_card:RemoveFromParent() self._area_handcard_list:AddChild(card_view.btn_card) if suocard ~= nil and #suocard > 0 then if list_check(suocard, card_view.card_item) then card_view.btn_card:GetController('Kan').selectedIndex = 1 else card_view.btn_card:GetController('Kan').selectedIndex = 0 end else card_view.btn_card:GetController('Kan').selectedIndex = 0 end card_view.old_postion = self:GetHandCardPos(card_view, #CountCards) card_view.btn_card:TweenMove(card_view.old_postion, 0.3) end print("jefe UpdateHandCardsPos1") self:ShowHuTip() end function M:UpdateCardDisplay() local CountCards = {} for i = 1, #self.card_list do CountCards[self.card_list[i].index_X] = CountCards[self.card_list[i].index_X] == nil and 1 or CountCards[self.card_list[i].index_X] + 1 end for i = #self.card_list, 1, -1 do local card_view = self.card_list[i] card_view.btn_card:RemoveFromParent() card_view.btn_card:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeard/201_', card_view.card_item) self._area_handcard_list:AddChild(card_view.btn_card) card_view.btn_card:TweenMove(self:GetHandCardPos(card_view, #CountCards), 0.3) end end function M:UpdateCardSize() local CountCards = {} for i = 1, #self.card_list do CountCards[self.card_list[i].index_X] = CountCards[self.card_list[i].index_X] == nil and 1 or CountCards[self.card_list[i].index_X] + 1 end for i = #self.card_list, 1, -1 do local card_view = self.card_list[i] card_view.btn_card:RemoveFromParent() card_view.btn_card:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeard/201_', card_view.card_item) card_view.btn_card:GetChild('icon'):SetScale(self:getCardSize(), self:getCardSize()) card_view.btn_card:GetChild('n6'):SetScale(self:getCardSize(), self:getCardSize()) self.card_width = 87 * self:getCardSize() self.card_hight = 110 * self:getCardSize() self._area_handcard_list:AddChild(card_view.btn_card) card_view.btn_card:TweenMove(self:GetHandCardPos(card_view, #CountCards), 0.3) end end function M:UpdateIsOnClick(isOut) self._view.touchable = isOut end function M:__OnDragEnd(context) if DataManager.CurrenRoom == nil or DataManager.CurrenRoom.self_player == nil then return end if self.outcard_button then self.outcard_button = nil end if self.movecard_button then self.movecard_button = nil end self._isDrg = false local button = context.sender button.onDragEnd:Set(nil) local card = button.data card.btn_card.sortingOrder = 0 if list_check(self.card_list, card) == false then self._dragCom:RemoveChildren(0, -1, true) return end local _room = DataManager.CurrenRoom local isSuo = false local suocard = _room.suoCard if suocard == nil then isSuo = false else if suocard ~= nil and #suocard > 0 then if list_check(suocard, card.card_item) then isSuo = true end end end self.movecard_button = card if (button.y < -400 and _room.curren_outcard_seat == _room.self_player.seat) and not isSuo then button.touchable = false self.outcard_button = card self:UpdateIsOnClick(false) self._mainView:OutCard(card.card_item) else local isChangeCard = false self.outcard_button = nil card.btn_card:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeard/201_', card.card_item) self._area_handcard_list:AddChild(button) if #self.card_list == 1 then isChangeCard = false self:UpdateHandCardsPos() return end local CountCards = {} for i = 1, #self.card_list do local lists = {} if CountCards[self.card_list[i].index_X] == nil then lists[#lists + 1] = self.card_list[i] CountCards[self.card_list[i].index_X] = lists else CountCards[self.card_list[i].index_X][#CountCards[self.card_list[i].index_X] + 1] = self.card_list[i] end end local minmark = 1 local maxmark = #self.card_list if card == self.card_list[1] or card == self.card_list[#self.card_list] then if self.card_list[1].index_X == self.card_list[2].index_X then minmark = 2 end if self.card_list[#self.card_list].index_X == self.card_list[#self.card_list - 1].index_X then maxmark = #self.card_list - 1 end end if button.x + button.width / 2 < self.card_list[minmark].btn_card.x and #CountCards < 10 then list_remove(self.card_list, card) local num = 0 for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end if card.index_X == self.card_list[i].index_X then num = num + 1 end end if num == 0 then for i = 1, #self.card_list do if self.card_list[i].index_X < card.index_X then self.card_list[i].index_X = self.card_list[i].index_X + 1 end end else for i = 1, #self.card_list do self.card_list[i].index_X = self.card_list[i].index_X + 1 end end card.index_X = 1 card.index_Y = 1 table.insert(self.card_list, 1, card) isChangeCard = true elseif button.x + button.width / 2 > (self.card_list[maxmark].btn_card.x + button.width) and #CountCards < 10 then list_remove(self.card_list, card) local num = 0 for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X then num = num + 1 end if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end end if num == 0 then for i = 1, #self.card_list do if self.card_list[i].index_X > card.index_X then self.card_list[i].index_X = self.card_list[i].index_X - 1 end end end card.index_X = self.card_list[#self.card_list].index_X + 1 card.index_Y = 1 self.card_list[#self.card_list + 1] = card isChangeCard = true else local MoveCard = false local MoveCardPos = 0 local MoveCardY = 0 for i = 1, #CountCards do local card_view = CountCards[i][1] 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 if card ~= card_view and #CountCards[i] < 4 and card.index_X ~= card_view.index_X then MoveCardPos = i MoveCardY = #CountCards[i] + 1 MoveCard = true list_remove(self.card_list, card) end end end end local MoveCardindex = 0 -- 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 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 --向下移動 if ((button.y + button.height / 2) + 20) > (card.old_postion.y + button.height) then --向上移動 MoveCardindex = -1 MoveCardPos = card.index_X MoveCardY = _cv.index_Y MoveCard = true list_remove(self.card_list, card) elseif ((button.y + button.height / 2) - 20) < card.old_postion.y then MoveCardindex = 1 MoveCardPos = card.index_X MoveCardY = _cv.index_Y MoveCard = true list_remove(self.card_list, card) end elseif i == #CountCards[card.index_X] and button.y + button.height / 2 < _cv.btn_card.y then MoveCardindex = 1 MoveCardPos = card.index_X MoveCardY = _cv.index_Y MoveCard = true list_remove(self.card_list, card) elseif i == 1 and button.y + button.height / 2 > (_cv.btn_card.y + button.width) then MoveCardindex = -1 MoveCardPos = card.index_X MoveCardY = _cv.index_Y MoveCard = true list_remove(self.card_list, card) end end end end end if MoveCard == true and MoveCardindex == 0 then --上下移动 local num = 0 for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X and card.index_Y < self.card_list[i].index_Y then self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end if card.index_X == self.card_list[i].index_X then num = num + 1 end end if num == 0 then for i = 1, #self.card_list do if self.card_list[i].index_X > card.index_X then self.card_list[i].index_X = self.card_list[i].index_X - 1 end end if MoveCardPos > card.index_X then MoveCardPos = MoveCardPos - 1 end end card.index_X = MoveCardPos card.index_Y = MoveCardY for i = #self.card_list, 1, -1 do if MoveCardPos == self.card_list[i].index_X then table.insert(self.card_list, (i + 1), card) break end end isChangeCard = true elseif MoveCard == true and MoveCardindex ~= 0 then for i = 1, #self.card_list do if card.index_X == self.card_list[i].index_X then --向下移动 if MoveCardindex == -1 then --向上移动 if self.card_list[i].index_Y < card.index_Y and self.card_list[i].index_Y >= MoveCardY then self.card_list[i].index_Y = self.card_list[i].index_Y + 1 end else if self.card_list[i].index_Y > card.index_Y and self.card_list[i].index_Y <= MoveCardY then self.card_list[i].index_Y = self.card_list[i].index_Y - 1 end end end end card.index_X = MoveCardPos card.index_Y = MoveCardY for i = #self.card_list, 1, -1 do if MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY - 1) then table.insert(self.card_list, (i + 1), card) break elseif MoveCardPos == self.card_list[i].index_X and self.card_list[i].index_Y == (MoveCardY + 1) then table.insert(self.card_list, i, card) break end end isChangeCard = true else isChangeCard = false self._area_handcard_list:AddChild(button) end end self:UpdateHandCardsPos() if isChangeCard == true and self._mainView ~= nil then self._mainView:ResetHandHuXi() self:SendChangeCard() end end end function M:SendChangeCard(...) local list = {} for i = 1, #self.card_list do local data = {} data.card = self.card_list[i].card_item data.X = self.card_list[i].index_X data.Y = self.card_list[i].index_Y list[#list + 1] = data end self._mainView:ChangeCards(list) end function M:GetHandCardPos(cards_view, cards) local x, y = 0, 0 local card_width = self.card_width -- 牌的宽度 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) if self:getCardSize() == 1 then y = 90 - (85 * cards_view.index_Y) elseif self:getCardSize() == 1.2 then y = 70 - (100 * cards_view.index_Y) elseif self:getCardSize() == 0.8 then y = 100 - (65 * cards_view.index_Y) end return Vector2.New(x, y) end function M:UpdateFzList(fz_list, ispaly) self._area_fz_list:RemoveChildren(0, -1, true) for i = 1, #fz_list do local fzitem = nil if fz_list[i].type ~= RB_FZType.Kan then fzitem = UIPackage.CreateObjectFromURL('ui://Main_RunBeard/ComponentNew') if (ispaly == false) then fzitem:RemoveChildren(0, -1, true) end end if fz_list[i].type == RB_FZType.Chi or fz_list[i].type == RB_FZType.Bi then local fzcards = UIPackage.CreateObjectFromURL('ui://Main_RunBeard/Fz_0_3') fzcards:GetChild('card_' .. 1).icon = self:getCardItem('ui://Main_RunBeard/202_', fz_list[i].active_card) fzcards:GetController('c2').selectedIndex = 1 fzcards:GetChild('card_' .. 2).icon = self:getCardItem('ui://Main_RunBeard/202_', fz_list[i].opcard[1]) fzcards:GetChild('card_' .. 3).icon = self:getCardItem('ui://Main_RunBeard/202_', fz_list[i].opcard[2]) fzcards.x, fzcards.y = 0, 0 self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Peng then local fzcards = UIPackage.CreateObjectFromURL('ui://Main_RunBeard/Fz_0_3') for j = 1, 3 do fzcards:GetChild('card_' .. j).icon = self:getCardItem('ui://Main_RunBeard/202_', fz_list[i].card) end fzcards.x, fzcards.y = 0, 0 self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) elseif fz_list[i].type == RB_FZType.Wei then local fzcards = UIPackage.CreateObjectFromURL('ui://Main_RunBeard/Fz_0_3') for j = 1, 3 do if j == 3 then fzcards:GetChild('card_' .. j).icon = self:getCardItem('ui://Main_RunBeard/202_', fz_list[i].card) else fzcards:GetChild('card_' .. j).icon = 'ui://Main_RunBeard/202_1_300' end end fzcards.x, fzcards.y = 0, 0 self:playAnim(fzitem, fzcards, #fz_list, i, ispaly) end end end function M:playAnim(fzitem, fzcards, size, i, ispaly) if (ispaly == nil) then ispaly = false end if (ispaly and i == size) then local faArray = fzitem:GetChild('chiwei') if (faArray ~= nil) then faArray:AddChild(fzcards) else fzitem:AddChild(fzcards) end else fzitem:AddChild(fzcards) end self._area_fz_list:AddChild(fzitem) end -- function M:TestTing() -- local player = {} -- player.fz_list = {} -- player.hu_xi = 13 -- player.handcard_list = {101, 102, 103, 105, 106, 107, 207, 207, 207, 209, 209, 208, 210} -- -- for i=1,3,1 do -- local fz = {} -- fz.active_card = 101 -- fz.card = 101 -- fz.type = 2 -- fz.opcard = {101, 101} -- player.fz_list[1] = fz -- local fz2 = {} -- fz2.active_card = 210 -- fz2.card = 210 -- fz2.type = 2 -- fz2.opcard = {210, 210} -- player.fz_list[2] = fz2 -- local fz3 = {} -- fz3.active_card = 201 -- fz3.card = 201 -- fz3.type = 4 -- fz3.opcard = {201, 201} -- player.fz_list[3] = fz3 -- local fz4 = {} -- fz4.active_card = 109 -- fz4.card = 109 -- fz4.type = 4 -- fz4.opcard = {109, 109} -- player.fz_list[4] = fz4 -- -- end -- local cards = {102, 102, 104, 104, 204, 107, 207, 207} -- -- for i, v in ipairs(cards) do -- -- list_remove(player.handcard_list, v) -- local tingList = CardCheck.tingPai(player, DataManager.CurrenRoom) -- for k, v in ipairs(tingList) do -- print('------------------------------:' .. v .. ' ') -- end -- -- table.insert(player.handcard_list, v) -- -- end -- end function M:ClearOutCard() self._area_outcard_list:RemoveChildren(0, -1, true) end function M:UpdateOutCardList(outcard, isShow, isMopai, seat) if (isShow == nil) then isShow = false end if (isMopai == nil) then isMopai = false end self._area_outcard_list:RemoveChildren(0, -1, true) local outcards = UIPackage.CreateObjectFromURL('ui://Main_RunBeard/Gcm_OutCard') if outcard == 0 then outcards:GetChild('icon').icon = 'ui://Main_RunBeard/202_1_300' else outcards:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeard/203_', outcard) end outcards.x, outcards.y = 0, 0 local show_di_bg = outcards:GetChild('show_di_bg') --show_di_bg.visible = true if (isShow) then if outcard == 0 then show_di_bg.visible = false end if (seat ~= nil and outcards ~= nil) then if (isMopai) then if outcard ~= 0 then outcards:GetTransition('mopai' .. seat):Play( function() --show_di_bg.visible = true end ) end else show_di_bg.visible = false outcards:GetTransition('cpai' .. seat):Play() end else --show_di_bg.visible = true end else show_di_bg.visible = false end self._area_outcard_list:AddChild(outcards) end function M:UpdateQiPai(qi_list, isplay) self._area_qipai_list:RemoveChildren(0, -1, true) for i = 1, #qi_list do local t = qi_list[i] local qicards = UIPackage.CreateObjectFromURL('ui://Main_RunBeard/Qipai') -- qicards:GetController("ischu").selectedIndex = t.ischu qicards:GetChild('icon').icon = self:getCardItem('ui://Main_RunBeard/202_', t.card) if (isplay) then if (i == #qi_list) then qicards:GetTransition('t0'):Play() end end self._area_qipai_list:AddChild(qicards) end end function M:PlayingOutCardAnima(card) coroutine.start( function() coroutine.wait(0.1) self:ClearOutCard() end ) end -- lua table 深拷贝 function M:deepcopy(object) local lookup_table = {} local function _copy(object) if type(object) ~= 'table' then return object elseif lookup_table[object] then return lookup_table[object] end local new_table = {} lookup_table[object] = new_table for index, value in pairs(object) do new_table[_copy(index)] = _copy(value) end return setmetatable(new_table, getmetatable(object)) end return _copy(object) end function M:getCardItem(card_1, card_2) if self._room.change_card_display ~= nil then return card_1 .. self._room.change_card_display .. card_2 else return card_1 .. '2_' .. card_2 end end function M:getCardSize() if self._room.change_card_size ~= nil then return self._room.change_card_size else return 1 end end function M:getSelfHuXi() local CountCards = {} for i = 1, #self.card_list do CountCards[self.card_list[i].index_X] = CountCards[self.card_list[i].index_X] == nil and 1 or CountCards[self.card_list[i].index_X] + 1 end local allcards = {} for k, v in pairs(CountCards) do local cards = {} for i = 1, #self.card_list do if self.card_list[i].index_X == k then cards[#cards + 1] = self.card_list[i].card_item end end table.sort(cards) allcards[#allcards + 1] = cards end local index_x = 1 if self.movecard_button then index_x = self.movecard_button.index_X end local handHuXi = checkHuxi.getHuxi(allcards, index_x) return handHuXi end function M:clearCardList() if self.card_list ~= nil and #self.card_list > 0 then for i = 1, #self.card_list do local card_view = self.card_list[i] if card_view ~= nil and card_view.btn_card ~= nil then card_view.btn_card.onTouchBegin:Clear() card_view.btn_card.onTouchMove:Clear() card_view.btn_card.onTouchEnd:Clear() end end end end return M