--- --- Created by 谌建军. --- DateTime: 2017/12/13 16:35 --- local TwoDouDiZhu_PlayerPokerInfoView = { _view = nil, _mainView = nil, _mask_liangpai = nil, } local M = TwoDouDiZhu_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.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.liutip = view:GetChild("liutip") self.liuIcon = self.liutip:GetChild("n0") self.liutip.visible = false end function M:ChangeJiao(a) printlog("changejiao aaaaaaaaaaaaa",a) if (a == -1) then self.liutip.visible = false return end if (a == 0) then self.liuIcon.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_two_icon_buchu" elseif (a==1) then self.liuIcon.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_two_icon_bujiao" elseif (a==2) then self.liuIcon.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_two_icon_buqiang" elseif (a==3) then self.liuIcon.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_two_icon_jiaodizhu" elseif (a==4) then self.liuIcon.icon = "ui://Extend_Poker_TwoDouDiZhu/ddz_two_icon_qiangdizhu" end self.liutip.visible = true end function M:SetOutCardInfo(cardlist,isPass,isAnim) self.outpoker_list:RemoveChildren(0,-1,true) if cardlist == nil then if isPass == true then self.ctr_outpoker.selectedIndex = 2 else self.ctr_outpoker.selectedIndex = 0 end else if isAnim then if self.move_cor then coroutine.stop(self.move_cor) self.move_cor = nil end local time = 0.1 for i = 1, #cardlist do local poker_item = UIPackage.CreateObject("Extend_Poker_TwoDouDiZhu", "poker7") local code = self:ChangeCodeByTo(cardlist[i]) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code) -- local card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2") local card_code_obj -- if DataManager.CurrenRoom.pai==0 then -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code) -- else -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2") -- end -- if code==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- -- body -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code.."_1") -- end -- if DataManager.CurrenRoom.pai==0 then -- if code==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- -- body -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code.."_1") -- else -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code) -- end -- else -- if code==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- -- body -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code.."_2") -- else -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2") -- end -- end card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code) if card_code_obj == nil then card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/00") end --card_code_obj:SetScale(1,1) poker_item:AddChild(card_code_obj) --local poker = self:CreatPoker(cardlist[i],0.7) self.outpoker_list:AddChild(poker_item) poker_item.xy = Vector2.New(self.out_card_data["start_x"],self.out_card_data["start_y"]) poker_item:TweenMove(self:GetOutCardEndPokerPos(i,#cardlist,self.outpoker_list,poker_item,self.out_card_data["maxcount_x"],1),time) --card_code_obj -- self.tween = TweenUtils.TweenFloat(1,0.7,time,function(x) -- card_code_obj:SetScale(x,x) -- end) card_code_obj:SetScale(0.7,0.7) end self.move_cor = coroutine.start(function() coroutine.wait(0.1) ViewUtil.PlaySound("TwoDouDiZhu_PK", "extend/poker/TwoDouDiZhu/sound/chupai.mp3") end) else for i = 1, #cardlist do local poker_item = UIPackage.CreateObject("Extend_Poker_TwoDouDiZhu", "poker7") local code = self:ChangeCodeByTo(cardlist[i]) local card_code_obj -- if DataManager.CurrenRoom.pai==0 then -- if code==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- -- body -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code.."_1") -- else -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code) -- end -- else -- if code==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- -- body -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code.."_2") -- else -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2") -- end -- end card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code) if card_code_obj == nil then card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/00") end card_code_obj:SetScale(0.7,0.7) poker_item:AddChild(card_code_obj) --local poker = self:CreatPoker(cardlist[i],0.7) self.outpoker_list:AddChild(poker_item) poker_item.xy = self:GetOutCardEndPokerPos(i,#cardlist,self.outpoker_list,poker_item,self.out_card_data["maxcount_x"],1) end end --self.ctr_outpoker.selectedIndex = 1 end 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:GetOutCardEndFirstPokerPos(count,parent_com,poker_obj,max_count,scale) local parent_width,parent_height = parent_com.width,parent_com.height local poker_width,poker_height = poker_obj.width * scale,poker_obj.height * scale local offset = self:GetOffSet(count) local x,y = 0,0 --local length = (count - 1) * (poker_width + offset) + poker_width --if length <= parent_width then -- x = (parent_width - length) / 2 -- y = (parent_height - poker_height) / 2 --end if count <= max_count then local length = (count - 1) * offset + poker_width x = (parent_width - length) / 2 y = ((parent_height - poker_height) / 2) end return Vector2.New(x,y) end function M:GetOutCardEndPokerPos(index,count,parent_com,poker_obj,max_count,scale) local offset_x,offset_y = self:GetOffSet(count),-50 local start_pos = self:GetOutCardEndFirstPokerPos(count,parent_com,poker_obj,max_count,scale) local poker_width,poker_height = poker_obj.width * scale,poker_obj.height * scale local parent_width,parent_height = parent_com.width,parent_com.height local pos_x,pos_y = start_pos.x + (index - 1) * offset_x,start_pos.y if index > max_count then pos_x = (index - max_count - 1) * offset_x pos_y = pos_y + poker_height + offset_y end return Vector2.New(pos_x,pos_y) end -- function M:PlayCardTypeEff(type1) -- if type1 < 7 and type1 ~= 4 then return end -- local eff_code = 0 -- if type1 == 10 then -- eff_code = 2 -- elseif type1 == 11 then -- eff_code = 3 -- elseif type1 == 4 then -- eff_code = 4 -- else -- eff_code = 1 -- end -- if self.cro_type_eff ~= nil then -- coroutine.stop(self.cro_type_eff) -- end -- self.cro_type_eff = nil -- self.cro_type_eff = coroutine.start(function() -- self.type_eff_view = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/eff_"..eff_code) -- if self.type_eff_view == nil then return end -- self._view:AddChild(self.type_eff_view) -- self.type_eff_view:SetXY((self._view.width - self.type_eff_view.width) / 2,self.outpoker_list.y) -- self.type_eff_view:GetTransition("t0"):Play() -- coroutine.wait(1.5) -- if self.type_eff_view ~= nil then -- self.type_eff_view:Dispose() -- self.type_eff_view = nil -- end -- 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) if self.cor_init_poker ~= nil then coroutine.stop(self.cor_init_poker) end self.cor_init_poker = nil self.card_list = {} self.hand_card_list:RemoveChildren(0,-1,true) local card_length local new_card_list if isMing == true then new_card_list = self._gameCtr:ChangeCodeByFrom(cardList,true) card_length = #cardList else card_length = cardList end if isPlayAni == true then self.cor_init_poker = coroutine.start(function() for i = card_length, 1,-1 do local code = isMing == true and new_card_list[i] or 0 coroutine.wait(0.01) local poker = self:CreatPoker1(code,0.4) self.hand_card_list:AddChild(poker) end end) else for i = card_length, 1,-1 do local code = isMing == true and new_card_list[i] or 0 local poker = self:CreatPoker1(code,0.4) self.hand_card_list:AddChild(poker) end end 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 --if self.card_number then -- self.card_number.visible = show -- self.card_number.text = string.format("剩余:%d",number) --end end function M:CreatPoker1(poker,scale,bank) local poker_item = UIPackage.CreateObject("Extend_Poker_TwoDouDiZhu", "poker"..scale * 10) local code = self:ChangeCodeByTo(poker) local card_code_obj -- if DataManager.CurrenRoom.pai==0 then -- if code==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- -- body -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code.."_1") -- else -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code) -- end -- else -- if code==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- -- body -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code.."_2") -- else -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2") -- end -- end card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code) if card_code_obj == nil or bank==1 then card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/00") end card_code_obj:SetScale(scale,scale) poker_item:AddChild(card_code_obj) return poker_item end function M:CreatPoker(poker,scale,bank) local poker_item = UIPackage.CreateObject("Extend_Poker_TwoDouDiZhu", "poker"..12.5) local code = self:ChangeCodeByTo(poker) local card_code_obj --printlog("========+++++++++++++++codecodecodecode ",code) -- if DataManager.CurrenRoom.pai==0 then -- if code==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- -- body -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code.."_1") -- else -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code) -- end -- else -- if code==310 and DataManager.CurrenRoom.room_config.Heart10 == 1 then -- -- body -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code.."_2") -- else -- card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/" .. code .. "_2") -- end -- end card_code_obj = UIPackage.CreateObjectFromURL("ui://Extend_Poker_TwoDouDiZhu/"..code) if card_code_obj == nil or bank==1 then card_code_obj = UIPackage.CreateObjectFromURL("ui://Main_Poker/00") end card_code_obj:SetScale(scale,scale) poker_item:AddChild(card_code_obj) return poker_item 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) end function M:Destroy() end return M