|
- local MJDefine = MJFramework.MJImport("mj.luaScript.MJDefine")
- local MJ = MJFramework.MJImport("mj.luaScript.Views.Game.MJ")
- local MJWanFa=MJFramework.ImportWanFa("luaScript.SubGameDefine.MaJiang.MJWanFa")
- local MJRoomXiaoJuView = MJFramework.MJFrameworkClassImprot("mj.luaScript.Views.Room.MJRoomXiaoJuView")
-
- -- 房间设置界面
- local zigong7zRoomXiaoJuView = class("zigong7zRoomXiaoJuView", MJRoomXiaoJuView)
-
- local MJ_WIDTH=47
- --起始位置
- local MJ_HAND_CARD_INIT_X=130+180
- local MJ_HAND_CARD_INIT_Y=40+15+11
- local MJ_GROUP_CARD_INIT_X=100
- --麻将组间隔
- local MJ_GROUP_PADDING_X=16
- --麻将直接间隔
- local MJ_PADDING_X=-3
- --胡牌麻将间隔
- local MJ_HU_X=8
- --暗杠上面的牌Y轴偏移量
- local GANG_OFFSET_Y=13
-
- -- 最多人数
- local MAX_PLAYER_COUNT = 6
-
- function zigong7zRoomXiaoJuView:ctor(...)
- zigong7zRoomXiaoJuView.super.ctor(self,...)
- if self.desktopType == MJDefine.DesktopType.ThreeD then
- self.desktopType = MJDefine.DesktopType.TwoD
- end
- end
-
- function zigong7zRoomXiaoJuView:loadUI()
- local ui = loadUI("mj_zigong7z/res/ui_fangjian/mj_zigong_xiaoju_jiesuan.ui")
- self.ui = ui
- self:addChild(ui)
- end
-
- function zigong7zRoomXiaoJuView:onEnter()
- zigong7zRoomXiaoJuView.super.onEnter(self)
-
- self:createLuoBo()
- --local vSize = getVisibleSize()
- local pos = self.ui.Items.Button_Next:getPosition()
- self.ui.Items.Text_Tip_1:setPositionX(pos.x + 140)
- self.ui.Items.Text_Tip_2:setPositionX(pos.x + 140)
- self:setListViewTip()
-
- self.ui.Items.Button_XiPai:setVisible(false);
- end
-
- function zigong7zRoomXiaoJuView:initPlayerView()
- local roomInfo=app.room.roomInfo
- -- self.ui.Items.Layout_Player:removeAllChildren()
- self.ui.Items.ScrollView_Player:removeAllChildren()
-
- self.items={}
- local totalInnerSize = cc.size(0, 0)
-
- for k,v in pairs(roomInfo.memberList) do
- --local i = v.nSeatId+1
- local userId = app.room:getViewIdByUserId(v.nUserId)
- local nSeatId = app.room:getSeatIdByViewId(userId)
- local i = nSeatId+1
- local item=self:createPlayerItem()
- --self.ui.Items.Layout_Player:addChild(item)
- self:setPlayerItemInfo(item,v)
- self.items[i]=item
- -- table.insert(self.items,)
- end
- for i=1,MAX_PLAYER_COUNT do
- if self.items[i] then
- self.ui.Items.ScrollView_Player:addChild(self.items[i])
- totalInnerSize.width = totalInnerSize.width + self.items[i]:getContentSize().width
- totalInnerSize.height = totalInnerSize.height + self.items[i]:getContentSize().height
- end
- end
-
- -- 刷新listview大小
- self.ui.Items.ScrollView_Player:setInnerContainerSize(totalInnerSize)
- end
-
- function zigong7zRoomXiaoJuView:createPlayerItem()
- local ui=loadUI("mj_zigong7z/res/ui_fangjian/mj_zigong_xiaoju_item.ui")
- autoAdapt(ui)
- return ui
- end
-
- function zigong7zRoomXiaoJuView:setPlayerItemInfo(ui,player)
- local roomInfo=app.room.roomInfo
- local nSeatId = app.room:getSeatIdByUserId(player.nUserId)
- local resultInfo=roomInfo.memberList
- local bg = "ImageView_ItemBg"--"ImageView_Win_"..i..""
- -- local bg2 = "ImageView_ItemBg_2"
- -- local lose = "ImageView_Lose_"..i
- local head = "ImageView_Head"
- local name = "Text_Name"
- local benJuScore = "Text_ZongFen"--"TextBMFont_Score"
- local benJuScore1 = "Text_Score"
- local hu = "ImageView_Hu"
- local info = "Button_Info"
- local result="Text_ResultInfo"
- local gangfen = "Text_GangFen"
- local hufen = "Text_HuFen"
-
- ui.Items.TextBMFont_Score:setVisible(false)
- local nodeBg = ui.Items[bg]
- -- local nodeBg2 = ui.Items[bg2]
- -- local nodeLose = self.ui.Items[lose]
- local nodeHead = ui.Items[head]
- local nodeName = ui.Items[name]
- local nodeBenJu = ui.Items[benJuScore]
- local bmFontScore = true
- if not nodeBenJu then
- nodeBenJu = ui.Items[benJuScore1]
- bmFontScore = false
- end
- local nodeHu = ui.Items[hu]
- local nodeBanker= ui.Items.ImageView_Banker
- local nodeResult= ui.Items[result]
- local nodeGangfen = ui.Items[gangfen]
- local nodeHufen = ui.Items[hufen]
- --[[local huType = {
- [1] = "自摸(",
- [2] = "接炮(",
- [3] = "抢杠胡(",
- }--]]
- --[[local infoTab = {
- ["agang"] = "暗杠(x",
- ["bgang"] = "补杠(x",
- ["diangang_cnt"] = "点杠(x",
- ["mgang"] = "明杠(x",
- }--]]
- local infoStr = self:setHuType(player.nUserId)
- nodeResult:setText(infoStr)
-
-
- local userInfo = app.room:getUserInfo(player.nUserId)
-
- --先设置默认头像
- local width = nodeHead:getContentSize().width
-
- local nickname = ""
- if userInfo and userInfo.nickname then
- nickname = getSubStringNickname(userInfo.nickname)
- self:updateUserHead(nodeHead,player.nUserId, userInfo.sex, userInfo.headimgurl);
- end
-
- nodeName:setText(nickname)
-
- nodeHu:setVisible(false)
- if player.result>0 then
- nodeHu:setVisible(true)
- local temp = {
- [1] = "mj/res/ui/zy_fangjian/operate/mj_effect_num1.png",
- [2] = "mj/res/ui/zy_fangjian/operate/mj_effect_num2.png",
- [3] = "mj/res/ui/zy_fangjian/operate/mj_effect_num3.png",
- [4] = "mj_zigong7z/res/zy_fangjian/zigong_num_4.png",
- [5] = "mj_zigong7z/res/zy_fangjian/zigong_num_5.png",
- }
-
- local orderNum = cc.Sprite:create(temp[player.huOrder])
- if player.result == MJDefine.MJGameHuType.HU_ZIMO then--自摸 huOrder
- nodeHu:loadTexture("mj/res/ui/zy_fangjian/operate/mj_effect_zimo.png")
- orderNum:setPosition(cc.p(260,65))
- if player.huOrder == 1 then -- 第一个自摸胡的玩家
- local posSpr = self:createFromPos(nil,nSeatId+1)
- local tPos = nodeHu:getPosition()
- tPos.x = tPos.x - 16 * 3
- tPos.y = tPos.y - 51
- posSpr:setPosition(tPos)
- nodeHu:getParent():addChild(posSpr)
- else
- local formIdTable = {}
- for k,v in pairs(roomInfo.memberList) do
- if v.result <= 0 or player.huOrder < v.huOrder then
- table.insert(formIdTable, v.nUserId)
- end
- end
- local posSpr = self:createFromPos(formIdTable, nSeatId+1)
- -- local formUid = v.nUserId
- local tPos = nodeHu:getPosition()
- tPos.x = tPos.x - 16 * (#formIdTable - 2)
- tPos.y = tPos.y - 51
- posSpr:setPosition(tPos)
- nodeHu:getParent():addChild(posSpr)
- end
- elseif player.result == MJDefine.MJGameHuType.HU_DIANPAO or player.result == MJDefine.MJGameHuType.HU_QIANGGANG then --点炮胡
- nodeHu:loadTexture("mj/res/ui/zy_fangjian/operate/mj_effect_jiepao.png")
- orderNum:setPosition(cc.p(300,65))
- local formUid = app.room:getUserIdBySeatId(player.dpSeatId)
- local posSpr = self:createFromPos(formUid,nSeatId+1)
- local tPos = nodeHu:getPosition()
- tPos.x = tPos.x + 8
- tPos.y = tPos.y - 51
- posSpr:setPosition(tPos)
- nodeHu:getParent():addChild(posSpr)
- end
- nodeHu:addChild(orderNum)
- end
-
- --黄庄才会查叫和查花猪
- if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_HUANG_ZHUANG
- or roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_DISBAND_GAME then
- if player.result <= 0 and player.isDj == 1 then
- nodeHu:loadTexture("mj/res/ui/zy_fangjian/operate/mj_effect_chajiao.png")
- nodeHu:setVisible(true)
- nodeHu:setScale(0.3)
-
- local noTingNum = 0--没有胡牌和听牌的玩家数
- for k,v in pairs(roomInfo.memberList) do
- if v.result <= 0 and v.isDj ~= 1 then
- noTingNum = noTingNum + 1
- end
- end
-
- local fromTable = {}
- for k,v in pairs(roomInfo.memberList) do
- local index = 1
- if v.result <= 0 and v.isDj ~= 1 then
- local formUid = v.nUserId
- table.insert(fromTable, formUid)
- end
- end
- local posSpr = self:createFromPos(fromTable,nSeatId+1)
- local tPos = nodeHu:getPosition()
- tPos.y = tPos.y - 51
- -- if noTingNum > 1 then
- tPos.x = tPos.x - 10 * (#fromTable - 2)
- -- if #fromTable == 1 then
- -- tPos.x = tPos.x - 20
- -- elseif #fromTable == 2 then
- -- tPos.x = tPos.x + 20
- -- end
- -- end
- posSpr:setPosition(tPos)
- nodeHu:getParent():addChild(posSpr)
- end
-
- if player.result <= 0 and player.isHz == 1 then --花猪
- nodeHu:loadTexture("mj/res/ui/zy_fangjian/operate/mj_effect_chahuazhu.png")
- nodeHu:setScale(0.3)
- nodeHu:setVisible(true)
- end
- end
-
- if app.room:getUserIdBySeatId(app.room.roomInfo.nBankSeatId)~=player.nUserId then
- nodeBanker:setVisible(false)
- end
-
- if app.room:getMyUserId() == player.nUserId then
- nodeBg:loadTexture("xj_my_bg.png",cc.TextureResType.plistType)
- --[[else
- nodeBg:loadTexture("xj_other_bg.png",cc.TextureResType.plistType)--]]
- end
-
- if tonumber(player.nTurnScore) > 0 then
- nodeBenJu:setText("+"..player.nTurnScore)
- else
- nodeBenJu:setText(player.nTurnScore)
- --if player.nTurnScore<0 and bmFontScore == true then
- -- nodeBenJu:setFntFile("res/fonts/dt_jian_num.fnt")
- --end
- end
-
- --番数
- ui.Items.Text_FanShu:setText(player.fanshu)--.."番")
-
- local ganginfo = json.decode(player.ganginfo)
- if ganginfo then
- nodeGangfen:setText(ganginfo.gangScore or 0)
- nodeHufen:setText(ganginfo.huScore or 0)
- else
- nodeGangfen:setText(0)
- nodeHufen:setText(0)
- end
-
- --[[ local viewId = app.room:getViewIdByUserId(player.nUserId)
- if viewId and viewId>0 and viewId<=4 then
- if viewId == 4 then
- ui.Items.ImageView_Pos:loadTexture("result_pos_0.png",1)
- else
- ui.Items.ImageView_Pos:loadTexture(string.format("result_pos_%d.png", viewId), 1)
- end
-
- else
- ui.Items.ImageView_Pos:setVisible(false)
- end--]]
- --现在是飘
- ui.Items.ImageView_Piao:setVisible(player.isPiao==1)
-
- ui.Items.ImageView_Pos:loadTexture(string.format("zg_xj_Pos_%d.png", nSeatId+1), 1)
- end
-
- function zigong7zRoomXiaoJuView:setHuType(userId)
- local roomInfo = app.room.roomInfo
- local strGameInfo = json.decode(roomInfo.strGameInfo)
- local str = ""
- local huType1 = {
- [1] = "自摸(",
- [2] = "接炮(",
- [3] = "抢杠胡(",
- }
- local huOrder1 = 0
- local player = roomInfo.memberList[userId]
- if player then
-
- huOrder1 = player.huOrder
- --胡牌顺序
- if player.result == MJDefine.MJGameHuType.HU_ZIMO then
- local huNum = 0
- --快速成局时,strGameInfo.playnum默认传来的是4人
- if strGameInfo.isfaststart == 1 then
- huNum = roomInfo.nMaxPlayCount - player.huOrder
- else
- huNum = strGameInfo.playnum - player.huOrder
- end
- --str = str..huType1[player.result]..huNum.."家) "
- elseif player.result == MJDefine.MJGameHuType.HU_DIANPAO or player.result == MJDefine.MJGameHuType.HU_QIANGGANG then
- local viewId = app.room:getViewIdBySeatId(player.dpSeatId)
- local userInfo = app.room:getUserInfoByViewId(viewId)
- local nickname = getSubStringNickname(userInfo.nickname)
- --str = str..huType1[player.result]..nickname..") "
- end
- --牌型
- -- for k,v in pairs(MJDefine.MJGamePaiType) do
- -- local newType = self:_and(player.huType,v)
- -- if self:_and(player.huType,v) ~= 0 then
- -- local newType = self:_and(player.huType,v)
- -- str = str..MJDefine.MJGameHuStr[newType].." "
- -- end
- -- end
- str = str .. self:getPaiTypeStr(player)
- if player.result > 0 or player.huType > 0 then
- if player.isPiao == 1 then
- str = str.."飘".." "
- end
- if player.luoboNum > 0 then
- str = str.."萝卜x"..player.luoboNum.." "
- end
- else
- if player.isPiao == 1 then
- str = str.."飘".." "
- end
- if player.isBaoPai == 1 then
- str = str.."报叫".." "
- elseif player.isBaoPai == 2 then
- str = str.."博自摸".." "
- end
- end
- local ganginfo = json.decode(player.ganginfo)
- if ganginfo then
- --[[if ganginfo.agang then
- str = str.."暗杠x"..ganginfo.agang.." "
- end
- if ganginfo.mgang then
- str = str.."明杠x"..ganginfo.mgang.." "
- end
- if ganginfo.bgang then
- str = str.."巴杠x"..ganginfo.bgang.." "
- end
- if ganginfo.dgang then
- str = str.."点杠x"..ganginfo.dgang.." "
- end
- if ganginfo.guogang then
- str = str.."过手杠x"..ganginfo.guogang.." "
- end--]]
- if ganginfo.gangCnt and ganginfo.gangCnt > 0 then
- str = str..ganginfo.gangCnt.."杠".." "
- end
- end
- end
- return str
- end
-
- --合并牌型得到最终的字符串
- function zigong7zRoomXiaoJuView:getPaiTypeStr(player)
- local strTab = {}
- for k,v in pairs(MJDefine.MJGamePaiType) do
- local newType = self:_and(player.huType,v)
- if newType ~= 0 then
- table.insert(strTab,MJDefine.MJGameHuStr[newType] or "")
- end
- end
-
- if player.result > 0 or player.huType > 0 then
- if player.genCount > 0 then
- table.insert(strTab,player.genCount.."归")
- end
- end
- dump(strTab)
- --logD(table.toString(strTab))
- for _,v in pairs(MJDefine.MJGameHuMargeTab) do
- local list = v.tab
- local str = v.name
- dump(list)
- local indexs= {}
- for _,v in pairs(list) do
- local index = table.indexOf(strTab, v)
- if index~= -1 then
- table.insert(indexs,index)
- end
- end
- if #indexs == #list then --如果都找到则合并
- for k,v in pairs(list) do
- table.removeItem(strTab,v)
- end
- -- logD(str)
- table.insert(strTab,str)
- end
- end
-
- local info = ""
- for k,v in pairs(strTab) do
- info = info..v.." "
- end
- return info
- end
-
- function zigong7zRoomXiaoJuView:createHandCards(layer,arg,seatId)
- for k,v in pairs(arg) do
- local mj=MJ:new(v.card,MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType)
- layer:addChild(mj)
- self:checkIsLuoBo(mj)
- mj:setPosition(cc.p(self.initX[seatId],MJ_HAND_CARD_INIT_Y))
- self.initX[seatId]=self.initX[seatId]+mj:getContentSize().width+MJ_PADDING_X
- end
- end
-
- function zigong7zRoomXiaoJuView:createHuCard(layer,card,seatId)
- local mj=MJ:new(card,MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType)
- self:checkIsLuoBo(mj)
- layer:addChild(mj)
- mj:setPosition(cc.p(self.initX[seatId],MJ_HAND_CARD_INIT_Y))
- self.initX[seatId]=self.initX[seatId]+mj:getContentSize().width+MJ_PADDING_X
-
- local flag = cc.Sprite:create("mj/res/ui/zy_fangjian/mj_hu_flag.png")
- mj:addChild(flag)
- if self.desktopType == MJDefine.DesktopType.TwoDGold then
- flag:setPosition(cc.p(16,40))
- else
- flag:setPosition(cc.p(16,55))
- end
- end
-
-
- function zigong7zRoomXiaoJuView:createChi(values,redNum)
- local node=cc.Layer:create()--Color:create(cc.c4b(255,0,0,255))
- node:setAnchorPoint(cc.p(0.5,0.5))
- node:ignoreAnchorPointForPosition(false)
- local width=0
- local height=0
-
- for i=1,3 do
- if values[i] then
- local mj
- if redNum > 0 and i <= redNum then
- mj=MJ:new(65,MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType)
- else
- mj=MJ:new(values[i],MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType)
- end
- self:checkIsLuoBo(mj)
-
- node:addChild(mj)
- local mjWidth=mj:getContentSize().width
- local mjHeight=mj:getContentSize().height
- local x=mjWidth/2+(i-1)*(mjWidth+MJ_PADDING_X)
- local y=mjHeight/2
- width=width+mjWidth
- height=mjHeight
- mj:setPosition(x,y)
- end
- end
- node:setContentSize(cc.size(width,height))
- return node
- end
-
- function zigong7zRoomXiaoJuView:createGang(values,redNum,isBaGang)
- local node=cc.Layer:create()--Color:create(cc.c4b(255,0,0,255))
- node:setAnchorPoint(cc.p(0.5,0.5))
- node:ignoreAnchorPointForPosition(false)
- local width=0
- local height=0
- for i=1,4 do
- if values[i] then
- local mj
- if isBaGang and i == 4 then
- mj=MJ:new(values[i],MJDefine.MJType.OutBlack,MJDefine.MyViewId,self.desktopType)
- if self.desktopType == MJDefine.DesktopType.TwoDGold then
- mj:setAutoSize(false)
- mj:setSize(cc.size(36,55))
- elseif self.desktopType == MJDefine.DesktopType.TwoD then
- mj:setAutoSize(false)
- mj:setSize(cc.size(47,67))
- end
- else
- mj=MJ:new(values[i],MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType)
- end
- self:checkIsLuoBo(mj)
- node:addChild(mj)
- local mjWidth=mj:getContentSize().width
- local mjHeight=mj:getContentSize().height
- local x=mjWidth/2+(i-1)*(mjWidth+MJ_PADDING_X)
- local y=mjHeight/2
- --width=width+mjWidth
- if i == 4 then
- mj:setLocalZOrder(2)
- y = mjHeight/2 + GANG_OFFSET_Y
- x = mjWidth/2 + (mjWidth+MJ_PADDING_X)
- else
- width = width + mjWidth
- end
- height=mjHeight
- mj:setPosition(x,y)
- end
- end
- node:setContentSize(cc.size(width,height))
- return node
- end
-
- function zigong7zRoomXiaoJuView:createAnGang(values,redNum)
- local node=cc.Layer:create()--Color:create(cc.c4b(255,0,0,255))
- node:setAnchorPoint(cc.p(0.5,0.5))
- node:ignoreAnchorPointForPosition(false)
- local width=0
- local height=0
- for i=1,4 do
- if values[i] then
- local mj
- if i <= 3 then
- mj=MJ:new(values[i],MJDefine.MJType.OutBlack,MJDefine.MyViewId,self.desktopType)
- if self.desktopType == MJDefine.DesktopType.TwoDGold then
- mj:setAutoSize(false)
- mj:setSize(cc.size(36,55))
- elseif self.desktopType == MJDefine.DesktopType.TwoD then
- mj:setAutoSize(false)
- mj:setSize(cc.size(47,72))
- end
- else
- --[[if redNum > 0 then
- mj=MJ:new(65,MJDefine.MJType.Out,MJDefine.MyViewId)
- else
- mj=MJ:new(values[i],MJDefine.MJType.Out,MJDefine.MyViewId)
- end--]]
- mj=MJ:new(values[i],MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType)
- end
- self:checkIsLuoBo(mj)
- node:addChild(mj)
- local mjWidth=mj:getContentSize().width
- local mjHeight=mj:getContentSize().height
- local x=mjWidth/2+(i-1)*(mjWidth+MJ_PADDING_X)
- local y=mjHeight/2
- --width=width+mjWidth
- if i == 4 then
- mj:setLocalZOrder(2)
- y = mjHeight/2 + GANG_OFFSET_Y
- x = mjWidth/2 + (mjWidth+MJ_PADDING_X)
- else
- width = width + mjWidth
- end
- height=mjHeight
- mj:setPosition(x,y)
- end
- end
- node:setContentSize(cc.size(width,height))
- return node
- end
-
- function zigong7zRoomXiaoJuView:createGroupCards(layer,arg,seatId)
- local handlers={
- [MJDefine.MJGroupType.Chi]=handler(self,self.createChi),
- [MJDefine.MJGroupType.Peng]=handler(self,self.createChi),
- [MJDefine.MJGroupType.Gang]=handler(self,self.createGang),
- [MJDefine.MJGroupType.AnGang]=handler(self,self.createAnGang),
- }
-
- for k,v in pairs(arg) do
- if handlers[v.opType] then
- local group
- if v.orgType == MJDefine.MJOperateType.OPREATE_BAGANG then
- group=handlers[v.opType](v.values,v.redNum,true)
- else
- group=handlers[v.opType](v.values,v.redNum)
- end
- local posSpr
- if v.opType == MJDefine.MJGroupType.Gang then
- if v.fromUserId > 10000 then
- posSpr = self:createFromPos(v.fromUserId,seatId)
- posSpr:setPosition(cc.p(group:getContentSize().width/2-3,-5-8))
- else
- posSpr = self:createFromPos(nil,seatId)
- posSpr:setPosition(cc.p(group:getContentSize().width/2-20 * 3,-5-8))
- end
-
- elseif v.opType == MJDefine.MJGroupType.AnGang then
- posSpr = self:createFromPos(nil,seatId)
- posSpr:setPosition(cc.p(group:getContentSize().width/2-20 * 3,-5-8))
- end
- if posSpr then
- group:addChild(posSpr)
- end
-
- local w=(group:getContentSize().width-MJ_WIDTH)/2
- group:setPosition(cc.p(self.initX[seatId]+w,MJ_HAND_CARD_INIT_Y))
- if k<#arg then
- self.initX[seatId]=self.initX[seatId]+group:getContentSize().width+MJ_GROUP_PADDING_X
- else
- self.initX[seatId]=self.initX[seatId]+group:getContentSize().width+MJ_GROUP_PADDING_X
- end
- layer:addChild(group)
- end
- end
- end
-
- function zigong7zRoomXiaoJuView:createFromPos(formUid,seatId,posY)-- 来源uid 自己的seatId
-
- local mLayout = cc.Layout:createNode()
-
- if formUid and type(formUid) == 'number' then
- local nSeatId = app.room:getSeatIdByUserId(formUid)--app.room:getSeatIdByViewId(formUid)
- local spr = cc.ImageView:createNode()
- local posName = string.format("zg_xj_Pos_%d.png", nSeatId+1)
- spr:loadTextureFromPlist(posName)
- local tSize = spr:getContentSize()
- mLayout:setSize(tSize)
- mLayout:addChild(spr)
- elseif formUid and type(formUid) == 'table' then
- local index = 1
- -- 先排序
- table.sort(formUid, function(a, b)
- return app.room:getSeatIdByUserId(a) < app.room:getSeatIdByUserId(b)
- end)
-
- for k, v in pairs(formUid) do
- local nSeatId = app.room:getSeatIdByUserId(v)
- local spr = cc.ImageView:createNode()
- local posName = string.format("zg_xj_Pos_%d.png", nSeatId+1)
- spr:loadTextureFromPlist(posName)
- local tSize = spr:getContentSize()
- mLayout:setSize(tSize)
- mLayout:addChild(spr)
- local tPos = cc.p(0 + (index-1)*30,0)
- spr:setPosition(tPos)
- index = index + 1
- end
- else
- local index = 1
- local maxNum = app.room.roomInfo.nMaxPlayCount or 3
- for i=1,maxNum do
- if i~=seatId then
- local spr = cc.ImageView:createNode()
- local posName = string.format("zg_xj_Pos_%d.png", i)
- spr:loadTextureFromPlist(posName)
- local contenSize = spr:getContentSize()
- local offsetX = index == 1 and -20 or 20
- local tPos = cc.p(0 + (index-1)*30,0)
- if maxNum == 2 then--2人玩事,数字标识居中
- tPos = cc.p(20,0)
- end
- spr:setPosition(tPos)
- mLayout:addChild(spr)
- index = index + 1
- end
- end
- end
- return mLayout
- end
-
- -- 获取组合牌组
- function zigong7zRoomXiaoJuView:getChangeGruopDatas(g,redNum)
- -- dump(g, "getChangeGruopDatas")
- local opType=MJDefine.MJOperateToGroupType[g.opType]
- local showType=MJDefine.MJOperateToGroupType[g.opType]
- local opCard=g.opCard
- local redNum = g.redNum
- local fromViewId = nil
- local targetSeatId = g.targetSeatId--操作位置座位号
- local fromUserId = g.opUserId or g.fromUserId --触发操作玩家
- if fromUserId<=0 or targetSeatId==nil then
- else
- fromViewId = app.room:transPos( targetSeatId, app.room:getSeatIdByUserId(fromUserId))
- --判断是否是对面玩家,对面玩家的话要做一次翻转
- local opViewId = app.room:getViewIdBySeatId(targetSeatId)
- if opViewId == 2 then --对面
- if fromViewId==1 then fromViewId = 3
- elseif fromViewId==3 then fromViewId = 1 end
- end
- --三人玩只有上下家
- if app.room:getMaxPlayerCount()==3 and fromViewId==2 then fromViewId = 3 end
- if app.room:getMaxPlayerCount()==2 and fromViewId~=0 then
- if showType == MJDefine.MJGroupType.Peng then
- fromViewId = 2
- else
- fromViewId = 4
- end
- end
- end
- --组合一下牌
- local group={
- opType=opType,
- showType=showType,
- values={},
- opCard = opCard,
- redNum = redNum,
- orgType = g.opType,--原始的类型,如巴杠会归结为杠 但是他原始操作是巴杠
- fromViewId = fromViewId,
- fromUserId = fromUserId,
- }
- if MJDefine.MJGroupType.Chi==showType then
- elseif MJDefine.MJGroupType.Peng==showType then
- group.values={opCard,opCard,opCard}
- else
- group.values={opCard,opCard,opCard,opCard}
- end
-
- return group
- end
-
-
- function zigong7zRoomXiaoJuView:initWeaveCard()
- local roomInfo=app.room.roomInfo
- self.initX={}
- for k,v in pairs(roomInfo.memberList) do
- local userId = app.room:getViewIdByUserId(v.nUserId)
- local nSeatId = app.room:getSeatIdByViewId(userId)
- local i = nSeatId+1
- local groups={}
- for _,group in pairs(v.gruoupCards) do
- table.insert(groups,self:getChangeGruopDatas(group))
- end
- self.initX[i]=MJ_HAND_CARD_INIT_X
- self:createGroupCards(self.items[i].Items.Layout_Player,groups,i)
- self.initX[i] = self.initX[i] + 10
- self:createHandCards(self.items[i].Items.Layout_Player,v.handCards,i)
- --创建胡的牌
- if v.huCard and v.huCard ~= 0 then
- self.initX[i]=self.initX[i]+MJ_HU_X
- self:createHuCard(self.items[i].Items.Layout_Player,v.huCard,i)
- -- self:createHandCards(self.items[i].Items.Layout_Player,{{card=v.huCard}},i)
- end
- end
- end
-
- function zigong7zRoomXiaoJuView:initOther()
- local roomInfo = app.room.roomInfo
- -- local winUserId = app.room.roomInfo.winUserId
-
- self.ui.Items.Text_Round:setText("局数:"..roomInfo.nGameStartCount..'/'..roomInfo.nTotalGameNum)
-
- --规则
- local ruleAll = MJWanFa.getWanFaInfo(roomInfo.strGameInfo)
- -- self.ui.Items.Text_Rule:setText(ruleAll)
-
- local item = self.ui.Items.Text_Rule:getCopied()
- item:setVisible(true)
- item:setText(ruleAll)
-
- self.ui.Items.ListView:addChild(item)
- self.ui.Items.ListView:hideAllBar()
- self.ui.Items.ListView:getInnerContainer():setAutoSize(true)
- self.ui.Items.ListView:requestDoLayout();
- self.ui.Items.ListView:doLayout();
-
- --时间
- self.ui.Items.Text_Time:setText(os.date("%m-%d %X"))--(getTimeString())
- --房号
- self.ui.Items.Text_RoomNum:setText("房号:"..roomInfo.nShowTableId)
-
- if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_HUANG_ZHUANG then
- self.ui.Items.ImageView_Title:loadTexture("xj_liuju.png",cc.TextureResType.plistType)
- end
- end
-
- function zigong7zRoomXiaoJuView:d2b(arg)
- self.data32={}
- for i=1,32 do
- self.data32[i]=2^(32-i)
- end
- local tr={}
- for i=1,32 do
- if arg >= self.data32[i] then
- tr[i]=1
- arg=arg-self.data32[i]
- else
- tr[i]=0
- end
- end
- return tr
- end
-
- function zigong7zRoomXiaoJuView:b2d(arg)
- local nr=0
- for i=1,32 do
- if arg[i] ==1 then
- nr=nr+2^(32-i)
- end
- end
- return nr
- end
-
- function zigong7zRoomXiaoJuView:_and(a,b)
- local op1=self:d2b(a)
- local op2=self:d2b(b)
- local r={}
-
- for i=1,32 do
- if op1[i]==1 and op2[i]==1 then
- r[i]=1
- else
- r[i]=0
- end
- end
- local c = self:b2d(r)
- return c
-
- end
-
- function zigong7zRoomXiaoJuView:createLuoBo()
- local roomInfo=app.room.roomInfo
- local luoboCards = roomInfo.luoboCards
- if luoboCards and #luoboCards>0 then
- local luoboPos = {
- [1] = {[1] = cc.p(72,46)},
- [2] = {[1] = cc.p(42,46),[2] = cc.p(102,46)},
- }
- local ui=loadUI("mj_zigong7z/res/ui_fangjian/mj_zigong_xiaoju_piao.ui")
- ui:setPosition(cc.p(145,65))
- self.ui.Items.Layout_Content:addChild(ui)
- local luoNum = #luoboCards
- for i,v in pairs(luoboCards) do
- local mj=MJ:new(v,MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType)
- if luoboPos[luoNum] and luoboPos[luoNum][i] then
- mj:setPosition(luoboPos[luoNum][i])
- ui.Items.Layout_luobo:addChild(mj)
- mj:setScale(1.1)
- end
- end
- end
- end
-
- function zigong7zRoomXiaoJuView:checkIsLuoBo(mj)
- if not mj then return end
- local roomInfo=app.room.roomInfo
- local luoboCards = roomInfo.luoboCards
- if luoboCards and #luoboCards>0 then
- for i,v in pairs(luoboCards) do
- if mj.value == v then--是萝卜
- mj:setColor(cc.c4b(250,250,0,255))
- break
- end
- end
- end
- end
-
- --黄色麻将小局改成跟绿色麻将一样大
- function zigong7zRoomXiaoJuView:changeMjSize(mj)
- if not mj then return end
- mj:setAutoSize(false)
- mj:setSize(cc.size(47,72))
- end
-
- -- 下拉列表提示
- function zigong7zRoomXiaoJuView:setListViewTip()
- local playerCount = table.nums(self.items)
- if playerCount < 4 then
- self.ui.Items.ScrollView_Player:setTouchEnabled(false)
- self.ui.Items.ImageView_Arrow:setVisible(false)
- return
- end
-
- local moveDown = cc.MoveBy:create(0.5, cc.p(0, -50))
- local moveUp = cc.MoveBy:create(0.5, cc.p(0, 50))
- local seq = cc.Sequence:create(moveDown, moveUp)
- local rep = cc.RepeatForever:create(seq)
-
- self.ui.Items.ImageView_Arrow:runAction(rep)
-
- -- 添加滚动检测事件
- local lv = self.ui.Items.ScrollView_Player
- local function onScrooll(sender, eventType)
- if eventType == cc.ScrollviewEventType.scrolling then
- self:refreshArrowImage()
- end
- end
- lv:addEventListener(onScrooll)
- end
-
- -- 刷新下拉图
- function zigong7zRoomXiaoJuView:refreshArrowImage()
- local inner = self.ui.Items.ScrollView_Player:getInnerContainer()
- local pos = inner:getPosition()
- if pos.y >= -30 then
- self.ui.Items.ImageView_Arrow:setVisible(false)
- else
- self.ui.Items.ImageView_Arrow:setVisible(true)
- end
- end
-
- return zigong7zRoomXiaoJuView
|