--- --- Created by 谌建军. --- DateTime: 2017/12/13 16:35 --- local MuShi_CardType = import(".MuShi_CardType") local MuShi_PlayerPokerInfoView = { _view = nil, _mainView = nil, _mask_liangpai = nil, } local M = MuShi_PlayerPokerInfoView 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._gameCtr = ControllerManager.GetController(GameController) self.item_data = json.decode(self._view:GetChild("area_mask").text) self.out_card_data = self.item_data["outcard_list"] self._mask_liangpai = view:GetChild("mask_liangpai") self.ctr_outpoker = view:GetController("output") self.outpoker_list = view:GetChild(self.out_card_data["parent"]) self.hand_card_list = view:GetChild("hand_card_list") self.cards_view = self._view:GetChild('hand_poker_c') self.ctr_one_card = view:GetController("one_card") self.eff_one_card = view:GetChild("one_card_eff"):GetTransition("t0") self.text_bomb_score = view:GetChild("Score") self.ani_bomb_score = view:GetTransition("score") self.ani_result_score = view:GetTransition("score_1") self.carType = self._view:GetChild("iconType") self.carIcon = self.carType:GetChild("n0") self.carType.visible = false self.carText = self.carType:GetChild("n1") self.carText.text = "" self.tianGong = false self.cardopen = false end function M:InitPoker(pokerList,cardtype,cardopen) self.cardopen = cardopen if cardtype == MuShi_CardType.TYPE_TIANGONG and cardopen then self.carIcon.icon = "ui://Extend_Poker_MuShi/ms_tian_8" self.carType.visible = false self:OpenCard(pokerList) self.tianGong = true elseif cardtype == MuShi_CardType.TYPE_DOUBLE_TIANGONG and cardopen then self.carIcon.icon = "ui://Extend_Poker_MuShi/ms_tian_9" self.carType.visible = false self:OpenCard(pokerList) self.tianGong = true else self:OpenCard({0,0}) self.tianGong = false end end function M:InitPoker2(pokerList) self.cards_view:RemoveChildren(0, -1, true) for i = 1, #pokerList do local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) local card_flower_code = pokerList[i] local btn_card = self:CreatPoker(pokerList[i], 1, 0) --btn_card.xy = self:GetHandCardPos(i) self.cards_view:AddChild(btn_card) end self._view.visible = true end function M:OpenCard(pokerList) for i = 1, #pokerList do local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) local card_flower_code = pokerList[i] local btn_card = self:CreatPoker(pokerList[i], 1, 0) --btn_card.xy = self:GetHandCardPos(i) self.cards_view:AddChild(btn_card) btn_card.visible = false end self._view.visible = true end function M:InitPoker1(pokerList) self.cards_view:RemoveChildren(0,-1,true) for i = 1, #pokerList do local card_number_code = self:ChangeOneCodeByFrom(pokerList[i]) local card_flower_code = pokerList[i] local btn_card = self:CreatPoker(pokerList[i], 1, 0) -- btn_card.xy = self:GetHandCardPos(i) self.cards_view:AddChild(btn_card) end self._view.visible = true end -- function M:InitPokerReconect(pokerList,cardtype,cardopen) -- self.cardopen = cardopen -- if cardtype == MuShi_CardType.TYPE_TIANGONG and cardopen then -- self.carIcon.icon = "ui://Extend_Poker_MuShi/ms_tian_8" -- self.carType.visible = false -- self:OpenCard(pokerList) -- self.tianGong = true -- elseif cardtype == MuShi_CardType.TYPE_DOUBLE_TIANGONG and cardopen then -- self.carIcon.icon = "ui://Extend_Poker_MuShi/ms_tian_9" -- self.carType.visible = false -- self:OpenCard(pokerList) -- self.tianGong = true -- else -- self:OpenCard({0,0}) -- self.tianGong = false -- end -- end function M:AddPoker(pokerList,back) if not self.tianGong and back==nil then pokerList = 0 end local btn_card = self:CreatPoker(pokerList,1, 0) self.cards_view:AddChild(btn_card) -- btn_card.xy = self:GetHandCardPos(3) end function M:ShowCard(index) self.cards_view:GetChildAt(index).visible = true if self.cardopen == true then self.carType.visible = true end end function M:SetCarType(card_type,point,bei) if card_type == MuShi_CardType.TYPE_SHUANGGUI then self.carIcon.icon = "ui://Extend_Poker_MuShi/ms_type_10" elseif card_type == MuShi_CardType.TYPE_SANGUI then self.carIcon.icon = "ui://Extend_Poker_MuShi/ms_type_20" elseif card_type == MuShi_CardType.TYPE_TIANGONG then self.carIcon.icon = "ui://Extend_Poker_MuShi/ms_tian_8" elseif card_type == MuShi_CardType.TYPE_DOUBLE_TIANGONG then self.carIcon.icon = "ui://Extend_Poker_MuShi/ms_tian_9" elseif card_type == MuShi_CardType.TYPE_NORMAL then self.carIcon.icon = "ui://Extend_Poker_MuShi/ms_point_"..point--"普通牌型" elseif card_type == MuShi_CardType.TYPE_MUSHI then self.carIcon.icon = "ui://Extend_Poker_MuShi/ms_point_0" elseif card_type == MuShi_CardType.TYPE_TONGHUASHUN then self.carIcon.icon = "ui://Extend_Poker_MuShi/ms_type_8" elseif card_type == MuShi_CardType.TYPE_SANTIAO then self.carIcon.icon = "ui://Extend_Poker_MuShi/ms_type_5" elseif card_type == MuShi_CardType.TYPE_SHUNZI then self.carIcon.icon = "ui://Extend_Poker_MuShi/ms_type_4" elseif card_type == MuShi_CardType.None then end if bei~=nil and tonumber(bei) > 1 then self.carText.text = bei.."倍" else self.carText.text = "" end if card_type ~= MuShi_CardType.None then self.carType.visible = true else self.carType.visible = false end end function M:ChangeOneCodeByFrom(card) if(card > 500) then return card end local flower = math.floor(card / 100) local number = card % 100 if number == 2 then number = 15 end return number * 10 + flower end function M:GetHandCardPos(index) local x, y = 0, -18 local offset = 40 x = offset*index return Vector2.New(x, y) end function M:SetOutCardBlack() for i = 0, self.outpoker_list.numChildren - 1 do self.outpoker_list:GetChildAt(i):GetChildAt(0):GetChildAt(0):GetChildAt(0).color = Color(0.7,0.7,0.7) end end -- 12 -61 --11 58 --10 55 --46 function M:GetOffSet(cardLength) -- 15 -70 if cardLength > 8 then return 40 else return - cardLength * 5 + 80 end end function M:PlayScore(score,isBomb,isWin) if score == nil then self.text_bomb_score.alpha = 0 return end if isBomb then self.text_bomb_score.text = score >= 0 and "+"..score or tostring(score) self.text_bomb_score.grayed = score < 0 self.ani_bomb_score:Play() else if score < 0 then self.text_bomb_score.text = tostring(score) self.text_bomb_score.grayed = true elseif score > 0 then self.text_bomb_score.text = "+"..score self.text_bomb_score.grayed = false else local str = isWin and "+" or "-" self.text_bomb_score.text = str..score self.text_bomb_score.grayed = not isWin end self.ani_result_score:Play() end end function M:UpdateHandPoker(cardList,isPlayAni,isMing) self.cards_view:RemoveChildren(0,-1,true) for i = 1, #cardList do local card_number_code = self:ChangeOneCodeByFrom(cardList[i]) local card_flower_code = cardList[i] local btn_card = self:CreatPoker(cardList[i], 1, 0) --btn_card.xy = self:GetHandCardPos(i) self.cards_view:AddChild(btn_card) end self._view.visible = true end function M:SetRemainCardNumber(isPlay) if isPlay then self.ctr_one_card.selectedIndex = 1 self.eff_one_card:Play(-1,0,nil) else self.ctr_one_card.selectedIndex = 0 end end function M:CreatPoker(poker,scale,bank) local card_code_obj --printlog("cccccccccccccwwwwwwwwwwwwwwwwwwwwwwww ",ControllerManager.GetController(GameController)==nil) if (DataManager.CurrenRoom.room_config.config.laizi == 1 and ControllerManager.GetController(GameController)~=nil and ControllerManager.GetController(GameController).guiCard ~=nil and ControllerManager.GetController(GameController).guiCard %100==poker%100) then poker = 500+poker%100 card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_MuShi/"..poker) else card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_MuShi/"..poker) end if card_code_obj == nil or bank==1 then card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_MuShi/00") end card_code_obj:SetScale(scale,scale) return card_code_obj end function M:ChangeCodeByTo( card ) if(card > 500) then return card end local flower = card % 10 local number = math.floor(card / 10) if number == 15 then number = 2 end return flower * 100 + number end function M:Clear() self:PlayScore(nil) self:SetRemainCardNumber(false) --self:SetOutCardInfo(nil,false) self.hand_card_list:RemoveChildren(0,-1,true) self._mask_liangpai:RemoveChildren(0,-1,true) self.cards_view:RemoveChildren(0,-1,true) self.carType.visible = false self.carText.text = "" self.tianGong = false end function M:Destroy() end return M