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 CardClass = require(MJDefine.MJConfig_2d.MAHJONG_CARD) -- 麻将牌 local MJRoomXiaoJuView = MJFramework.MJFrameworkClassImprot("mj.luaScript.Views.Room.MJRoomXiaoJuView") local dazhouRoomXiaoJuView = class("dazhouRoomXiaoJuView", MJRoomXiaoJuView) local MJ_WIDTH=47 --起始位置 local MJ_HAND_CARD_INIT_X=130+30 local MJ_HAND_CARD_INIT_Y=40+5 local MJ_GROUP_CARD_INIT_X=100 local MJ_OPERATE_CARD_INIT_Y = 45 -- 操作牌y轴 --麻将组间隔 local MJ_GROUP_PADDING_X=0 --麻将直接间隔 local MJ_HANDCARD_PADDING_X = -38 -- 手牌麻将直接间隔(牌与牌) local MJ_OPERATE_PADDING_X = -3 -- 操作麻将直接间隔(牌与牌) --胡牌麻将间隔 local MJ_HU_X=8 --暗杠上面的牌Y轴偏移量 local GANG_OFFSET_Y=13 --麻将直接间隔 local MJ_PADDING_X=-3 local MJ_HANDCARD_SCALE = 0.6 -- 手牌麻将的缩小值 local MJ_OPERATE_SCALE = 0.75 -- 操作麻将的缩小值 local IS_SHOW_ANGANG_CARD = false -- 暗杠牌是否要显示起来 function dazhouRoomXiaoJuView:ctor(...) dazhouRoomXiaoJuView.super.ctor(self,...) if self.desktopType == MJDefine.DesktopType.ThreeD then self.desktopType = MJDefine.DesktopType.TwoD end end function dazhouRoomXiaoJuView:loadUI() local ui = loadUI("mj_dazhou/res/ui_fangjian/mj_dazhou_xiaoju_jiesuan.ui") self.ui = ui self:addChild(ui) end function dazhouRoomXiaoJuView:onEnter() dazhouRoomXiaoJuView.super.onEnter(self) --self:createLuoBo() --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) end function dazhouRoomXiaoJuView:initPlayerView() local roomInfo=app.room.roomInfo self.ui.Items.Layout_Player:removeAllChildren() self.items={} 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 item=self:createPlayerItem() self:setPlayerItemInfo(item,v) self.items[i]=item -- table.insert(self.items,) end for i=1,4 do if self.items[i] then self.ui.Items.Layout_Player:addChild(self.items[i]) end end end function dazhouRoomXiaoJuView:createPlayerItem() local ui=loadUI("mj_dazhou/res/ui_fangjian/mj_xzdd_xiaoju_item.ui") autoAdapt(ui) return ui end function dazhouRoomXiaoJuView: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 = "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 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) --显示隐藏游戏内选手id(主办人和管理员不限制,只针对海选赛) -- todo lwq -- begin local ClubDefine = require("luaScript.Protocol.Club.ClubDefine") if app.club_php.clubID and app.club_php.clubID ~= 0 then if app.club_php:getCestIsOpen(app.club_php.clubID) then --隐私数据 local clubInfo = app.club_php.clubList[app.club_php.clubID] self.cliext = clubInfo.groupext and clubInfo.groupext.cliext if not self.cliext or not self.cliext.is_hideUid or (self.cliext and self.cliext.is_hideUid == 1) then if clubInfo.role == ClubDefine.Job.Creator or clubInfo.role == ClubDefine.Job.Manager then nodeName:setVisible(true) else nodeName:setVisible(false) end end end end if player.nUserId == tonumber(app.user.loginInfo.uid) then nodeName:setVisible(true) end -- end nodeHu:setVisible(false) if player.result>0 then nodeHu:setVisible(true) local orderNum = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_num"..player.huOrder..".png") 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 - 20 tPos.y = tPos.y - 46 posSpr:setPosition(tPos) nodeHu:getParent():addChild(posSpr) else local index = 0 for k,v in pairs(roomInfo.memberList) do if v.result <= 0 or v.huOrder > player.huOrder then local formUid = v.nUserId local posSpr = self:createFromPos(formUid,nSeatId+1) local tPos = nodeHu:getPosition() tPos.y = tPos.y - 46 tPos.x = tPos.x + index*40 posSpr:setPosition(tPos) nodeHu:getParent():addChild(posSpr) index = index + 1 end end 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.y = tPos.y - 46 posSpr:setPosition(tPos) nodeHu:getParent():addChild(posSpr) end nodeHu:addChild(orderNum) end --黄庄才会查叫和查花猪 if roomInfo.stopFlag==MJDefine.StopFlag.STOP_FLAG_HUANG_ZHUANG 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 for k,v in pairs(roomInfo.memberList) do local index = 1 if v.result <= 0 and v.isDj ~= 1 then local formUid = v.nUserId local posSpr = self:createFromPos(formUid,nSeatId+1) local tPos = nodeHu:getPosition() tPos.y = tPos.y - 46 if noTingNum > 1 then if index == 1 then tPos.x = -20 elseif index == 2 then tPos.x = 20 end end posSpr:setPosition(tPos) nodeHu:getParent():addChild(posSpr) index = index + 1 end end 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 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_Pos:loadTexture(string.format("mj_dazhou/res/zy_fangjian/xzddadd/xzdd_xj_Pos_%d.png", nSeatId+1), 0) end function dazhouRoomXiaoJuView: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--]] if MJDefine.MJGameHuStr[player.subPaiType] then str = str .. MJDefine.MJGameHuStr[player.subPaiType].." " end if MJDefine.MJGameHuStr[player.huType] then str = str .. MJDefine.MJGameHuStr[player.huType].." " end --[[local specialType = { ["isJueZhang"] = "绝张", ["isJinGouDiao"] = "金钩钓", ["isHaiDiLaoYue"] = "海底捞月", ["isHaiDiPao"] = "海底炮", ["isGangShangKaiHua"] = "杠上开花", ["isGangShangPao"] = "杠上炮", ["isQiangGangHu"] = "抢杠胡", ["isMenQing"] = "门清", ["isZhongZhang"] = "中张", }--]] if player.result > 0 or player.huType > 0 then if player.genCount > 0 then str = str .. player.genCount.."根".." " end if player.isJinGouDiao > 0 then str = str .. "金钩钓".." " end if player.isHaiDiLaoYue > 0 then str = str .. "海底捞月".." " end if player.isHaiDiPao > 0 then str = str .. "海底炮".." " end if player.isGangShangKaiHua > 0 then str = str .. "杠上开花".." " end if player.isGangShangPao > 0 then str = str .. "杠上炮".." " end if player.isQiangGangHu > 0 then str = str .. "抢杠胡".." " end if player.isMenQing > 0 then str = str .. "门清".." " end if player.isZhongZhang > 0 then str = str .. "中张".." " end end if player.isJueZhang and player.isJueZhang > 0 then str = str .. "绝张+1".." " end if player.isSiJiao and player.isSiJiao > 0 then str = str .. "死叫" .. " " end if player.isBaoPai and player.isBaoPai == 1 then str = str.."报叫".." " end if player.isShaBao and player.isShaBao == 1 then str = str.."杀报".." " end local ganginfo = json.decode(roomInfo.ganginfo) if ganginfo then local showGang = ganginfo[tostring(userId)] if ganginfo and showGang then if showGang.agang and showGang.agang >0 then str = str.."暗杠x"..showGang.agang.." " end if showGang.mgang and showGang.mgang>0 then str = str.."明杠x"..showGang.mgang.." " end if showGang.bgang and showGang.bgang>0 then str = str.."巴杠x"..showGang.bgang.." " end if showGang.diangang_cnt and showGang.diangang_cnt>0 then str = str.."点杠x"..showGang.diangang_cnt.." " end if showGang.gsgang and showGang.gsgang>0 then str = str.."过手杠x"..showGang.gsgang.." " end --[[if ganginfo.gangCnt and ganginfo.gangCnt > 0 then str = str..ganginfo.gangCnt.."杠".." " end--]] end end end return str end --合并牌型得到最终的字符串 function dazhouRoomXiaoJuView: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 dazhouRoomXiaoJuView:createHandCards(layer,arg,seatId) for k,v in pairs(arg) do local mj if self.desktopType == MJDefine.DesktopType.TwoDL then mj=MJ:new(v.card,MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType) mj:setPosition(cc.p(self.initX[seatId],MJ_HAND_CARD_INIT_Y)) self.initX[seatId]=self.initX[seatId]+mj:getContentSize().width+MJ_PADDING_X else mj = CardClass:new(v.card, MJDefine.MyViewId, MJDefine.MJType.Stand, 10) mj:setScale(MJ_HANDCARD_SCALE) mj:setPosition(cc.p(self.initX[seatId],MJ_HAND_CARD_INIT_Y)) self.initX[seatId]=self.initX[seatId]+mj:getContentSize().width+MJ_HANDCARD_PADDING_X end layer:addChild(mj) end end function dazhouRoomXiaoJuView:createHuCard(layer,card,seatId) local mj if self.desktopType == MJDefine.DesktopType.TwoDL then mj=MJ:new(card,MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType) 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 else mj = CardClass:new(card, MJDefine.MyViewId, MJDefine.MJType.Stand, 10) mj:setScale(MJ_HANDCARD_SCALE) mj:setPosition(cc.p(self.initX[seatId],MJ_HAND_CARD_INIT_Y)) self.initX[seatId]=self.initX[seatId]+mj:getContentSize().width+MJ_HANDCARD_PADDING_X local flag = cc.Sprite:create("mj/res/ui/zy_fangjian/mj_hu_flag.png") mj:addChild(flag) flag:setScale(2) flag:setPosition(cc.p(32,82)) end layer:addChild(mj) end function dazhouRoomXiaoJuView: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 self.desktopType == MJDefine.DesktopType.TwoDL then mj=MJ:new(values[i],MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType) 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) else mj = CardClass:new(values[i], MJDefine.MyViewId, MJDefine.MJType.Operate, 10) mj:setScale(MJ_OPERATE_SCALE) local mjWidth=mj:getContentSize().width * MJ_OPERATE_SCALE local mjHeight=mj:getContentSize().height * MJ_OPERATE_SCALE local x=mjWidth/2+(i-1)*(mjWidth+MJ_OPERATE_PADDING_X) local y=mjHeight/2 width=width+mjWidth height=mjHeight mj:setPosition(x,y) end node:addChild(mj) end end node:setContentSize(cc.size(width,height)) return node end function dazhouRoomXiaoJuView: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 self.desktopType == MJDefine.DesktopType.TwoDL then mj=MJ:new(values[i],MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType) if isBaGang and i == 4 then mj=MJ:new(0,MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType) mj:setAutoSize(false) mj:setSize(cc.size(47,72)) if self.desktopType == MJDefine.DesktopType.TwoDGold then mj:setSize(cc.size(36,55)) end end local mjWidth=mj:getContentSize().width local mjHeight=mj:getContentSize().height local x=mjWidth/2+(i-1)*(mjWidth+MJ_PADDING_X) local y=mjHeight/2 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) else mj = CardClass:new(values[i], MJDefine.MyViewId, MJDefine.MJType.Operate, 10) mj:setScale(MJ_OPERATE_SCALE) if isBaGang and i == 4 then--血战巴杠朝上 --mj:setOperateBackImage() end local mjWidth=mj:getContentSize().width * MJ_OPERATE_SCALE local mjHeight=mj:getContentSize().height * MJ_OPERATE_SCALE local x=mjWidth/2+(i-1)*(mjWidth+MJ_OPERATE_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_OPERATE_PADDING_X) else width = width + mjWidth end height=mjHeight mj:setPosition(x,y) end node:addChild(mj) end end node:setContentSize(cc.size(width,height)) return node end function dazhouRoomXiaoJuView: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 self.desktopType == MJDefine.DesktopType.TwoDL then if i <= 3 then mj=MJ:new(values[i],MJDefine.MJType.OutBlack,MJDefine.MyViewId,self.desktopType) mj:setAutoSize(false) mj:setSize(cc.size(47,72)) if self.desktopType == MJDefine.DesktopType.TwoDGold then mj:setSize(cc.size(36,55)) end else mj=MJ:new(values[i],MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType) end local mjWidth=mj:getContentSize().width local mjHeight=mj:getContentSize().height local x=mjWidth/2+(i-1)*(mjWidth+MJ_PADDING_X) local y=mjHeight/2 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) else mj = CardClass:new(values[i], MJDefine.MyViewId, MJDefine.MJType.Operate, 10) mj:setScale(MJ_OPERATE_SCALE) -- 暗杠盖牌 if not IS_SHOW_ANGANG_CARD then if i <= 3 then mj:setOperateBackImage() end end local mjWidth=mj:getContentSize().width * MJ_OPERATE_SCALE local mjHeight=mj:getContentSize().height * MJ_OPERATE_SCALE if i <= 3 then local x=mjWidth/2+(i-1)*(mjWidth+MJ_OPERATE_PADDING_X) local y=mjHeight/2 width=width+mjWidth height=mjHeight mj:setPosition(x,y) else local x=mjWidth/2+(2-1)*(mjWidth+MJ_OPERATE_PADDING_X) - 1 local y=mjHeight/2 + 16 height=mjHeight mj:setPosition(x, y); end end node:addChild(mj) end end node:setContentSize(cc.size(width,height)) return node end function dazhouRoomXiaoJuView: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)) else posSpr = self:createFromPos(nil,seatId) posSpr:setPosition(cc.p(group:getContentSize().width/2-25,-5)) end elseif v.opType == MJDefine.MJGroupType.AnGang then posSpr = self:createFromPos(nil,seatId) posSpr:setPosition(cc.p(group:getContentSize().width/2-25,-5)) 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_OPERATE_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 dazhouRoomXiaoJuView:createFromPos(formUid,seatId,posY)-- 来源uid 自己的seatId local mLayout = cc.Layout:createNode() if formUid then local nSeatId = app.room:getSeatIdByUserId(formUid)--app.room:getSeatIdByViewId(formUid) local spr = cc.ImageView:createNode() local posName = string.format("mj_dazhou/res/zy_fangjian/xzddadd/xzdd_xj_Pos_%d.png", nSeatId+1) spr:loadTexture(posName,0) local tSize = spr:getContentSize() mLayout:setSize(tSize) mLayout:addChild(spr) else local index = 1 local maxNum = app.room.roomInfo.nMaxPlayCount or 4 for i=1,maxNum do if i~=seatId then local spr = cc.ImageView:createNode() local posName = string.format("mj_dazhou/res/zy_fangjian/xzddadd/xzdd_xj_Pos_%d.png", i) spr:loadTexture(posName,0) local contenSize = spr:getContentSize() local offsetX = index == 1 and -20 or 20 local tPos = cc.p(0 + (index-1)*40,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 dazhouRoomXiaoJuView: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 or 0 local fromViewId = nil local targetSeatId = g.targetSeatId--操作位置座位号 local fromUserId = g.opUserId or g.fromUserId or 0 --触发操作玩家 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 dazhouRoomXiaoJuView: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) end end end function dazhouRoomXiaoJuView:initOther() local roomInfo = app.room.roomInfo 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.ListView:jumpToTop() --时间 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 dazhouRoomXiaoJuView: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 dazhouRoomXiaoJuView: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 dazhouRoomXiaoJuView:_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 dazhouRoomXiaoJuView:changeMjSize(mj) if not mj then return end mj:setAutoSize(false) mj:setSize(cc.size(47,72)) end return dazhouRoomXiaoJuView