|
- 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 ChangPaiRoomCard=ZPFramework.ZPImport("zp_changpai.luaScript.Views.Room.changpaiRoomCard")
- local changpaiRoomXiaoJuChaPaiView = class("changpaiRoomXiaoJuChaPaiView", ZPRoomXiaoJuChaPaiView)
- local ChangpaiCard = ZPFramework.ZPImport("zp_changpai.luaScript.Views.Room.changpaiCard")
-
- function changpaiRoomXiaoJuChaPaiView:ctor(colorType)
- changpaiRoomXiaoJuChaPaiView.super.ctor(self)
- self.colorType = colorType or ZPDef.ColorType.White
- end
-
- function changpaiRoomXiaoJuChaPaiView:onEnter()
- changpaiRoomXiaoJuChaPaiView.super.onEnter(self)
- end
-
- function changpaiRoomXiaoJuChaPaiView:loadUI()
- local ui = loadUI("zp_changpai/res/ui/ui_fangjian/changpai_ui_xiaoju_chapai.ui");
- self.ui = ui;
- self:addChild(ui);
- end
-
- function changpaiRoomXiaoJuChaPaiView:liangShouPai(isRecontect)
-
- --胡牌类型
- local huType = ZPDef.ReconnectHuType.NO_HU
- --房间信息
- local roomInfo = app.room.roomInfo
-
- --正常结束取值
- local tt = roomInfo.playList
- --重连取值
- if isRecontect then
- tt = roomInfo.arrayTableInfo
- end
-
- local enterCardHu = roomInfo.isEnterCardHu
-
- 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,v in pairs(roomInfo.hupaiInfo) do
- local nUserId = v.huPaiUid
- local viewId = app.room:getViewIdByUserId(nUserId)
-
- if isRecontect and roomInfo.isZiMoHu and roomInfo.isZiMoHu ~= 1 and roomInfo.isQiangBaHu and roomInfo.isQiangBaHu ~= 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
-
- 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))
- self:createHandCard(nUserId)
- end
- end
-
- app.room.roomInfo.huCardType = huType
-
- return huType
- end
-
-
- function changpaiRoomXiaoJuChaPaiView:setCardColorType(colorType)
- self.colorType = colorType or ZPDef.ColorType.White
- end
-
- function changpaiRoomXiaoJuChaPaiView:showDiPai()
- local roomInfo = app.room.roomInfo
- self.ui.Items.Layout_dipai:removeAllChildren()
- --显示剩余底牌
- 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 = 0.9--self.littleCardScale + 0.03
- if self.colorType == ZPDef.ColorType.YELLOW then
- scale = 0.75
- end
- 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_QUIT,self.colorType)
- cardImg:loadTextureFromPlist(fileName);
- cardImg:setScale(scale)
- local showColNum = 10
- 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 changpaiRoomXiaoJuChaPaiView:initLiangPaiPos()
- self.boxPosList1 = {}
- local weaveCardPos1 = self.ui.Items.Layout_LiangPai_1:getPosition()
- local tempY = 28
- local tempX = 34
- if self.colorType == ZPDef.ColorType.YELLOW then
- tempX = 30
- tempY = 30
- end
- for i = 1, 16 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, 16 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.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, 16 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 changpaiRoomXiaoJuChaPaiView: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)
- if (not viewId) and app.room:getActualPlayerNum() == 2 then
- viewId = 1;
- 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 changpai = ChangpaiCard:new(v,ZPDef.CardType.CARD_TYPE_QUIT,viewId,self.colorType)
-
- if self.colorType == ZPDef.ColorType.White then
- changpai:setScale(0.9)
- else
- changpai:setScale(0.7)
- end
-
- local pos = self.boxPosList1[k]
- changpai:setPosition(pos)
- self.ui.Items.Layout_HandCard:addChild(changpai,1)
- end
-
- elseif viewId == 2 then
- for k,v in pairs(handcardlist) do
- local changpai = ChangpaiCard:new(v,ZPDef.CardType.CARD_TYPE_QUIT,viewId,self.colorType)
- if self.colorType == ZPDef.ColorType.White then
- changpai:setScale(0.9)
- else
- changpai:setScale(0.7)
- end
- local pos = self.boxPosList2[k]
- changpai:setPosition(pos)
- self.ui.Items.Layout_HandCard:addChild(changpai,1)
- end
- elseif viewId == 3 then
- for k,v in pairs(handcardlist) do
- local changpai = ChangpaiCard:new(v,ZPDef.CardType.CARD_TYPE_QUIT,viewId,self.colorType)
-
- if self.colorType == ZPDef.ColorType.White then
- changpai:setScale(0.9)
- else
- changpai:setScale(0.7)
- end
-
- local pos = self.boxPosList3[k]
- changpai:setPosition(pos)
- self.ui.Items.Layout_HandCard:addChild(changpai,1)
- end
- end
-
- end
-
- --判断列数是否是砍牌
- function changpaiRoomXiaoJuChaPaiView:getCurrentColIsKan(list)
- local isKan = false
- return isKan
- end
-
-
- function changpaiRoomXiaoJuChaPaiView: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 changpaiRoomXiaoJuChaPaiView
|