|
- local ZPDef = ZPFramework.ZPImport("zp_base.luaScript.ZPDef")
- local ZPFuc = ZPFramework.ZPImport("zp_base.luaScript.ZPFunctions")
- local ZPSound = ZPFramework.ZPImport("zp_base.luaScript.ZPSound")
- local ZPRoomCard=ZPFramework.ZPImport("zp_base.luaScript.Views.Room.ZPRoomCard")
- local ZPRoomXiaoJuChaPaiView = ZPFramework.ZPFrameworkClassImprot("zp_base.luaScript.Views.Room.ZPRoomXiaoJuChaPaiView")
- local XichongRoomCard=ZPFramework.ZPImport("zp_xichong.luaScript.Views.Room.xichongRoomCard")
- local xichongRoomXiaoJuChaPaiView = class("xichongRoomXiaoJuChaPaiView", ZPRoomXiaoJuChaPaiView)
-
- function xichongRoomXiaoJuChaPaiView:ctor(desktopType)
- xichongRoomXiaoJuChaPaiView.super.ctor(self)
- self.desktopType = desktopType or ZPDef.GameStyleType.XIANDAI
- end
-
- function xichongRoomXiaoJuChaPaiView:onEnter()
- xichongRoomXiaoJuChaPaiView.super.onEnter(self)
- self:initJDLiangPaiPos()
- self:setDeskTopType(self.desktopType)
- end
-
- function xichongRoomXiaoJuChaPaiView:loadUI()
- local ui = loadUI("zp_xichong/res/ui/ui_fangjian/xichong_ui_xiaoju_chapai.ui");
- self.ui = ui;
- self:addChild(ui);
- end
-
- function xichongRoomXiaoJuChaPaiView:setDeskTopType(desktopType)
- self.desktopType = desktopType or ZPDef.GameStyleType.XIANDAI
-
- if self.desktopType == ZPDef.GameStyleType.XIANDAI then
- self.ui.Items.Layout_DiPai_JD_1:setVisible(false)
- self.ui.Items.Layout_DiPai_JD_2:setVisible(false)
- self.ui.Items.Layout_DiPai_JD_3:setVisible(false)
- self.ui.Items.Layout_DiPai_1:setVisible(true)
- self.ui.Items.Layout_DiPai_2:setVisible(true)
- self.ui.Items.Layout_DiPai_3:setVisible(true)
- else
- self.ui.Items.Layout_DiPai_JD_1:setVisible(true)
- self.ui.Items.Layout_DiPai_JD_2:setVisible(true)
- self.ui.Items.Layout_DiPai_JD_3:setVisible(true)
- self.ui.Items.Layout_DiPai_1:setVisible(false)
- self.ui.Items.Layout_DiPai_2:setVisible(false)
- self.ui.Items.Layout_DiPai_3:setVisible(false)
- end
- end
-
- function xichongRoomXiaoJuChaPaiView:liangShouPai(isRecontect)
-
- --胡牌类型
- local huType = ZPDef.ReconnectHuType.NO_HU
- --房间信息
- local roomInfo = app.room.roomInfo
-
- --正常结束取值
- local tt = roomInfo.playList
- --重连取值
- if isRecontect then
- tt = roomInfo.arrayTableInfo
- end
-
-
- if (roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_NORMAL) then
- --胡的牌
- local huCard = roomInfo.huCard
-
- --出牌者ID或者点炮的ID,自摸这个是nil,有人点炮这个是有值的
- local showViewId = nil
-
- local dianPaoViewId = app.room:getViewIdByUserId(roomInfo.dianPaoUserId)
-
- --重连
- if isRecontect then
- showViewId = app.room:getViewIdBySeatId(roomInfo.showCardSeatId)
- else
- --小局结算
- showViewId = dianPaoViewId
- end
-
- for k,huinfo in pairs(roomInfo.hupaiInfo) do
- huCard = huinfo.huCard
- local nUserId = huinfo.huPaiUid
- local viewId = app.room:getViewIdByUserId(nUserId)
-
- --显示胡的那个牌
- if isRecontect and roomInfo.isZiMoHu and roomInfo.isZiMoHu ~= 1 then
- if self.showHuCardCallBack then
- self.showHuCardCallBack(showViewId,huCard)
- end
- end
-
- --赢家手牌
- local cardList = {}
-
- cardList = roomInfo.memberList[nUserId].cardList
-
- if roomInfo.isZiMoHu and roomInfo.isZiMoHu ~= 1 then
- local isFind = false
- if table.nums(cardList) > 0 then
- for i = 1,self.lieShuMax do
- local cardColList = cardList[i] or {}
- for idx,value in pairs(cardColList) do
- if value == huCard then
- table.remove(cardColList,idx)
- isFind = true
- break
- end
- end
- if isFind then
- break
- end
- end
- end
- end
-
- end
- end
- --[[
-
-
- if roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_HUANG_ZHUANG and not isRecontect then
- --胡的牌
- local huCard = roomInfo.huCard
- --出牌者ID或者点炮的ID,自摸这个是nil,有人点炮这个是有值的
- local showViewId = nil
- local dianPaoViewId = app.room:getViewIdByUserId(roomInfo.dianPaoUserId)
- --重连
- if isRecontect then
- showViewId = app.room:getViewIdBySeatId(roomInfo.showCardSeatId)
- else
- --小局结算
- showViewId = dianPaoViewId
- end
- for k,huinfo in pairs(roomInfo.hupaiInfo) do
- huCard = huinfo.huCard
- local nUserId = huinfo.huPaiUid
- local viewId = app.room:getViewIdByUserId(nUserId)
- --显示胡的那个牌
- if isRecontect then
- if self.showHuCardCallBack then
- self.showHuCardCallBack(showViewId,huCard)
- end
- end
- --赢家手牌
- local cardList = {}
- cardList = roomInfo.memberList[nUserId].cardList
-
- local paoTiHU = false
-
- for k,v in pairs(tt) do
- if k == nUserId then
- if v.tableWeaveCard and #v.tableWeaveCard > 0 then
- local lastWeaveCard = v.tableWeaveCard[#v.tableWeaveCard]
- if (lastWeaveCard.type == ZPDef.SendCardType.KAN_THREE_SAME or lastWeaveCard.type == ZPDef.SendCardType.DIRTY_THREE_SAME
- or lastWeaveCard.type == ZPDef.SendCardType.DUI_THREE_SAME) and huCard == lastWeaveCard.card then
- local tcardlst = {huCard,huCard,huCard}
- table.insert(cardList,tcardlst)
- elseif (lastWeaveCard.type == ZPDef.SendCardType.GUN_ZI_FOUR_SAME or lastWeaveCard.type == ZPDef.SendCardType.KUAI_SHUI_FOUR_SAME
- or lastWeaveCard.type == ZPDef.SendCardType.CHI_PAI_TI or lastWeaveCard.type == ZPDef.SendCardType.CHI_PAI_SHAO_PAO
- or lastWeaveCard.type == ZPDef.SendCardType.CHI_PAI_PENG_PAO) and huCard == lastWeaveCard.card then
- local tcardlst = {huCard,huCard,huCard,huCard}
- table.insert(cardList,tcardlst)
- end
- end
- end
- end
- end
- end
-
- if roomInfo.stopFlag == ZPDef.XiaoJuEndType.STOP_FLAG_HUANG_ZHUANG then
- for k,huinfo in pairs(roomInfo.hupaiInfo) do
- local huCard = huinfo.huCard
- local nUserId = huinfo.huPaiUid
- local cardList = roomInfo.memberList[nUserId].cardList
- if cardList and #cardList > 0 then
- local isfindJiaoPai = false
- for i=#cardList,1,-1 do
- local cardLie = cardList[i]
- for j=1,4 do
- if cardLie[j] and cardLie[j] == huCard then
- cardLie.jiaopaiIdx = j
- isfindJiaoPai = true
- break
- end
- end
- if isfindJiaoPai then
- break
- end
- end
- end
- end
- end
- ]]
-
- for k,v in pairsByKeys(tt) do
- local myUserID = app.room:getMyUserId()
- local nUserId = v.nUserId
-
- if myUserID ~= nUserId then
- local cardList = roomInfo.memberList[nUserId].cardList
- logE("cardList:"..table.tostring(cardList))
- if self.desktopType == ZPDef.GameStyleType.JINGDIAN then
- self:createHandCardInJDType(nUserId)
- else
- self:createHandCard(nUserId)
- end
-
- end
- end
-
- app.room.roomInfo.huCardType = huType
-
- return huType
- end
-
- function xichongRoomXiaoJuChaPaiView:showDiPai()
- local roomInfo = app.room.roomInfo
- self.ui.Items.Layout_dipai:removeAllChildren()
- self.ui.Items.Layout_dipai:setVisible(false)
- self.ui.Items.ImageView_DiPai:setVisible(false)
- if true then
- return
- end
- --显示剩余底牌
- local jiantouImg = cc.ImageView:createNode();
- jiantouImg:setAnchorPoint(cc.p(0,0));
- jiantouImg:loadTextureFromPlist("zipai_arrow.png");
-
- local dipaiSize = table.nums(roomInfo.dipaiList);
- local nodeDipai = self.ui.Items.Layout_dipai
- --没有底牌不显示底牌背景
- if dipaiSize <= 0 then
- self.ui.Items.ImageView_DiPai:setVisible(false)
- else
- self.ui.Items.ImageView_DiPai:setVisible(true)
- end
- local scale = 1--self.littleCardScale + 0.03
- local tmp = {}
- local max = table.nums(roomInfo.dipaiList)
- for i = max,1,-1 do
- local card = roomInfo.dipaiList[i]
- table.insert(tmp,card)
- end
- for dipaiK,dipaiV in pairsByKeys(tmp) do
- local cardImg = cc.ImageView:createNode();
- cardImg:setAnchorPoint(cc.p(0,0));
- local fileName = ZPFuc.getZPCardImgByValue(dipaiV.chessCards,ZPDef.CardType.CARD_TYPE_TABLE)
- cardImg:loadTextureFromPlist(fileName);
- cardImg:setScale(scale)
- local showColNum = 8
- local getHeightCount = function (count)
- if count >= showColNum then
- return math.floor(count/showColNum)
- else
- return 0
- end
- end
- local x = (dipaiK - 1) % showColNum
- local width = cardImg:getContentSize().width * scale + 3;
- local height = cardImg:getContentSize().height * scale;
- local adjustPos = cc.p(width * x,height * getHeightCount(dipaiK - 1))
- local tarPos = cc.p(width * (showColNum - 1) - adjustPos.x,0 + adjustPos.y)
- cardImg:setPosition(tarPos);
- nodeDipai:addChild(cardImg);
- if dipaiK == dipaiSize then
- local x = (dipaiK) % showColNum
- local adjustPos = cc.p(width * x,height * getHeightCount(dipaiK))
- local tarPos = cc.p(width * (showColNum - 1) - adjustPos.x,0 + adjustPos.y)
- jiantouImg:setPosition(tarPos)
- if dipaiK == showColNum or dipaiK == showColNum * 2 then
- x = (dipaiK - 1) % showColNum
- adjustPos = cc.p(width * x,height * getHeightCount(dipaiK - 1))
- tarPos = cc.p(width * (showColNum - 1) - adjustPos.x - width,0 + adjustPos.y)
- jiantouImg:setPosition(tarPos)
- end
- nodeDipai:addChild(jiantouImg);
- end
- end
- end
-
-
- --初始化小局查牌界面亮手牌的位置
- function xichongRoomXiaoJuChaPaiView:initLiangPaiPos()
- self.boxPosList1 = {}
- local weaveCardPos1 = self.ui.Items.Layout_LiangPai_1:getPosition()
- local tempY = 42
- local tempX = 38
- for i = 1, 18 do
- --矩形3
- local indexX = i
- local indexY = 1
- if i >= 7 and i < 13 then
- indexY = 2
- indexX = i - 6
- elseif i >= 13 then
- indexY = 3
- indexX = i - 12
- end
- self.boxPosList1[i] = cc.p(weaveCardPos1.x + tempX * (indexX - 1),weaveCardPos1.y - tempY * (indexY- 1))
- end
-
- self.boxPosList2 = {}
- local weaveCardPos2 = self.ui.Items.Layout_LiangPai_2:getPosition()
- for i = 1, 18 do
- --矩形3
- local indexX = i
- local indexY = 1
- if i >= 10 and i < 20 then
- indexY = 2
- indexX = i - 9
- end
- self.boxPosList2[i] = cc.p(weaveCardPos2.x + tempX * (indexX - 1),weaveCardPos2.y - tempY * (indexY- 1))
- end
-
- self.boxPosList3 = {}
- local weaveCardPos3 = self.ui.Items.Layout_LiangPai_3:getPosition()
- for i = 1, 18 do
- --矩形3
- local indexX = i
- local indexY = 1
- if i >= 7 and i < 13 then
- indexY = 2
- indexX = i - 6
- elseif i >= 13 then
- indexY = 3
- indexX = i - 12
- end
- self.boxPosList3[i] = cc.p(weaveCardPos3.x + tempX * (indexX - 1),weaveCardPos3.y - tempY * (indexY- 1))
- end
- end
-
-
- --初始化经典模式下小局查牌界面亮手牌的位置
- function xichongRoomXiaoJuChaPaiView:initJDLiangPaiPos()
- self.boxJDPosList1 = {}
- local weaveCardPos1 = self.ui.Items.Layout_LiangPai_JD_1:getPosition()
- local tempY = 30
- local tempX = 30
- for i = 1, 18 do
- --矩形3
- local indexX = 1
- local indexY = i
- if i >= 10 then
- indexX = 2
- indexY = i - 9
- end
- self.boxJDPosList1[i] = cc.p(weaveCardPos1.x + 45 * (indexX - 1),weaveCardPos1.y + tempY * (indexY- 1))
- end
-
- self.boxJDPosList2 = {}
- local weaveCardPos2 = self.ui.Items.Layout_LiangPai_JD_2:getPosition()
- for i = 1, 18 do
- --矩形3
- local indexX = i
- local indexY = 1
- self.boxJDPosList2[i] = cc.p(weaveCardPos2.x - tempX * (indexX - 1),weaveCardPos2.y - tempY * (indexY- 1))
- end
-
- self.boxJDPosList3 = {}
- local weaveCardPos3 = self.ui.Items.Layout_LiangPai_JD_3:getPosition()
- for i = 1, 18 do
- --矩形3
- local indexX = 1
- local indexY = i
- if i >= 10 then
- indexX = 2
- indexY = i - 9
- end
- self.boxJDPosList3[i] = cc.p(weaveCardPos3.x + 45 * (indexX - 1),weaveCardPos3.y - tempY * (indexY- 1))
- end
- end
-
-
- local DI_PAI_TAG = 100
-
- function xichongRoomXiaoJuChaPaiView:createHandCard(nUserId)
- logE("====================changpaiRoomXiaoJuChaPaiView:createHandCard()===================");
-
- local cardList = app.room.roomInfo.memberList[nUserId].cardList
-
- --过滤手牌为空的情况
- if not cardList or table.nums(cardList) <= 0 then
- return
- end
-
- local viewId = app.room:getViewIdByUserId(nUserId)
- local layoutNode = string.format("Layout_DiPai_%d",viewId)
-
- for k,child in pairs(self.ui.Items[layoutNode]:getChildren()) do
- local tag = child:getTag()
- if tag == DI_PAI_TAG then
- child:removeFromParent()
- end
- end
-
- if app.room:getActualPlayerNum() == 3 then --三人的时候对家不用显示
- self.ui.Items.Layout_DiPai_2:setVisible(false)
- end
-
- local handcardlist = {}
-
- for i = 1,self.lieShuMax do
- local value = cardList[i] or {}
- for k,v in pairs(value) do
- table.insert(handcardlist,v)
- end
- end
-
- --不管有无数据,默认创建10列数据
- if viewId == 1 then
- for k,v in pairs(handcardlist) do
- local cardImg = cc.ImageView:createNode();
- cardImg:setAnchorPoint(cc.p(0,0));
- local fileName = ZPFuc.getZPCardImgByValue(v,ZPDef.CardType.CARD_TYPE_TABLE)
- cardImg:loadTextureFromPlist(fileName);
- cardImg:setTag(DI_PAI_TAG)
- local pos = self.boxPosList1[k]
- cardImg:setPosition(pos)
- self.ui.Items[layoutNode]:addChild(cardImg,1)
- end
-
- elseif viewId == 2 then
- for k,v in pairs(handcardlist) do
- local cardImg = cc.ImageView:createNode();
- cardImg:setAnchorPoint(cc.p(0,0));
- local fileName = ZPFuc.getZPCardImgByValue(v,ZPDef.CardType.CARD_TYPE_TABLE)
- cardImg:loadTextureFromPlist(fileName);
- local pos = self.boxPosList2[k]
- cardImg:setTag(DI_PAI_TAG)
- cardImg:setPosition(pos)
- self.ui.Items[layoutNode]:addChild(cardImg,1)
- end
- elseif viewId == 3 then
- for k,v in pairs(handcardlist) do
- local cardImg = cc.ImageView:createNode();
- cardImg:setAnchorPoint(cc.p(0,0));
- local fileName = ZPFuc.getZPCardImgByValue(v,ZPDef.CardType.CARD_TYPE_TABLE)
- cardImg:loadTextureFromPlist(fileName);
- local pos = self.boxPosList3[k]
- cardImg:setPosition(pos)
- cardImg:setTag(DI_PAI_TAG)
- self.ui.Items[layoutNode]:addChild(cardImg,1)
- end
- end
-
- end
-
-
- function xichongRoomXiaoJuChaPaiView:createHandCardInJDType(nUserId)
- logE("====================changpaiRoomXiaoJuChaPaiView:createHandCard()===================");
-
- local cardList = app.room.roomInfo.memberList[nUserId].cardList
-
- --过滤手牌为空的情况
- if not cardList or table.nums(cardList) <= 0 then
- return
- end
-
- local viewId = app.room:getViewIdByUserId(nUserId)
- local layoutNode = string.format("Layout_DiPai_JD_%d",viewId)
-
- for k,child in pairs(self.ui.Items[layoutNode]:getChildren()) do
- local tag = child:getTag()
- if tag == DI_PAI_TAG then
- child:removeFromParent()
- end
- end
-
- if app.room:getActualPlayerNum() == 3 then --三人的时候对家不用显示
- self.ui.Items.Layout_DiPai_JD_2:setVisible(false)
- end
-
- local handcardlist = {}
-
- for i = 1,self.lieShuMax do
- local value = cardList[i] or {}
- for k,v in pairs(value) do
- table.insert(handcardlist,v)
- end
- end
-
- --不管有无数据,默认创建10列数据
- if viewId == 1 then
- for k,v in pairs(handcardlist) do
- local cardImg = cc.ImageView:createNode();
- cardImg:setAnchorPoint(cc.p(0,0));
- cardImg:setEulerRotation(cc.vec3(0,0,180))
- local fileName = ZPFuc.getZPCardImgByValue(v,ZPDef.CardType.CARD_TYPE_GROUPCARD,ZPDef.GameStyleType.JINGDIAN)
- cardImg:loadTextureFromPlist(fileName);
- cardImg:setTag(DI_PAI_TAG)
- local pos = self.boxJDPosList1[k]
- cardImg:setPosition(pos)
- self.ui.Items[layoutNode]:addChild(cardImg,1)
- end
-
- elseif viewId == 2 then
- for k,v in pairs(handcardlist) do
- local cardImg = cc.ImageView:createNode();
- cardImg:setAnchorPoint(cc.p(0,0));
- cardImg:setEulerRotation(cc.vec3(0,0,-90))
- local fileName = ZPFuc.getZPCardImgByValue(v,ZPDef.CardType.CARD_TYPE_GROUPCARD,ZPDef.GameStyleType.JINGDIAN)
- cardImg:loadTextureFromPlist(fileName);
- local pos = self.boxJDPosList2[k]
- cardImg:setTag(DI_PAI_TAG)
- cardImg:setPosition(pos)
- self.ui.Items[layoutNode]:addChild(cardImg,1)
- end
- elseif viewId == 3 then
- for k,v in pairs(handcardlist) do
- local cardImg = cc.ImageView:createNode();
- cardImg:setAnchorPoint(cc.p(0,0));
- local fileName = ZPFuc.getZPCardImgByValue(v,ZPDef.CardType.CARD_TYPE_GROUPCARD,ZPDef.GameStyleType.JINGDIAN)
- cardImg:loadTextureFromPlist(fileName);
- local pos = self.boxJDPosList3[k]
- cardImg:setPosition(pos)
- cardImg:setTag(DI_PAI_TAG)
- self.ui.Items[layoutNode]:addChild(cardImg,1)
- end
- end
-
- end
-
-
- --判断列数是否是砍牌
- function xichongRoomXiaoJuChaPaiView:getCurrentColIsKan(list)
- local isKan = false
- return isKan
- end
-
-
- function xichongRoomXiaoJuChaPaiView:PlayHuangZhuangAni(bShowAni)
- local nodeDipai = self.ui.Items.Layout_XiaoJu_LiangPai
- --黄庄不显示结算,增加黄庄动画
- local tip = cc.ImageView:createNode();
- tip:setAnchorPoint(cc.p(0.5,0.5));
- tip:loadTextureFromPlist("zp_room_chapai_huangzhuang.png");
- tip:setPosition(cc.p(nodeDipai:getContentSize().width / 2,nodeDipai:getContentSize().height / 2+70))
- tip:setTag(1000)
- nodeDipai:addChild(tip);
- if bShowAni then
- tip:setScale(5.0)
- local seq = cc.Sequence:create(cc.ScaleTo:create(0.2,0.8),cc.ScaleTo:create(0.15,1.2),cc.ScaleTo:create(0.1,1))
- tip:runAction(seq)
- end
- end
-
- return xichongRoomXiaoJuChaPaiView
|