local PKDef = PKFramework.PKImport("pk_base.luaScript.PKDef") local PKFuc = PKFramework.PKImport("pk_base.luaScript.PKFunctions") local PKSound = PKFramework.PKImport("pk_base.luaScript.PKSound") local PKWanFa = PKFramework.ImportWanFa("luaScript.SubGameDefine.PuKe.PKWanFa") local PKRoomXiaoJuView = class("PKRoomXiaoJuView", cc.UIView) function PKRoomXiaoJuView:ctor(nextCallBackFun,chaPaiCallBackFun,dajuCallBack) PKRoomXiaoJuView.super.ctor(self); self.nextCallBack = nextCallBackFun self.chaPaiCallBackFun = chaPaiCallBackFun self.dajuCallBack = dajuCallBack self.xiaojuData = app.room.roomInfo.playList end function PKRoomXiaoJuView:loadUI() local ui = loadUI("pk_base/res/ui/ui_fangjian/pk_ui_xiaoju.ui"); self.ui = ui; self:addChild(ui); end function PKRoomXiaoJuView:onEnter() PKRoomXiaoJuView.super.onEnter(self) self:loadUI() -- 下一局 self.ui.Items.Button_Next:registerClick(handler(self , self.onClickNext)) --显示总结算 self.ui.Items.Button_All:registerClick(handler(self , self.onClickZongJieSuan)) --查牌 self.ui.Items.Button_ChaPai:registerClick(handler(self , self.onClickChaPai)) --复制用 self.ui.Items.Layout_Player_Item:setVisible(false) self.ui.Items.Layout_Player_VS:setVisible(false) self.ui.Items.Layout_PlayerNoPlay_Item:setVisible(false) self.ui.Items.Layout_Player_gz:setVisible(false) --显示结束 if app.room.roomInfo.isGameOver == 1 then self.ui.Items.Button_Next:setVisible(false) self.ui.Items.Button_All:setVisible(true) else self.ui.Items.Button_All:setVisible(false) end --初始化人物信息 self:initOtherData() self:updatePlayerInfo() end function PKRoomXiaoJuView:initOtherData() local roomInfo = app.room.roomInfo --规则 self.ui.Items.Text_Rule:setText(PKWanFa.getRuleInfo()) --时间 self.ui.Items.Text_Time:setText(os.date("%Y-%m-%d %X",roomInfo.mTime)) --房号 self.ui.Items.Text_RoomNum:setText("房间号:"..tostring(app.room.roomInfo.nShowTableId)) --局数 self.ui.Items.TextJuShu:setText("局数:"..tostring(app.room.roomInfo.nGameStartCount).."/"..tostring(app.room.roomInfo.nTotalGameNum)) end function PKRoomXiaoJuView:updatePlayerInfo() local maxPlayer = app.room:getCurMaxPlayer() --是否第一次 local isFirst = true --是否观战 local isHaveGuanZhan = false --是否包牌 local isHavePeopleBaoPai = false --非观战数据 local friendList = {} local enemyList = {} for k,v in pairs(app.room.roomInfo.playerList) do if v.mPlaying == 0 then isHaveGuanZhan = true self.ui.Items.Layout_Player:setPositionX(self.ui.Items.Layout_Player:getPositionX() + 50) end local memberInfo = app.room.roomInfo.memberList[v.nUserId] if memberInfo then if tonumber(memberInfo.baoPai) == PKDef.BaoPai.BAOPAI then isHavePeopleBaoPai = true end end end if isHaveGuanZhan then self.ui.Items.Layout_Player:setAnchorPoint(cc.p(1,self.ui.Items.Layout_Player:getAnchorPoint().y)) end --某个情况调整布局 --A VS B |观战 if isHaveGuanZhan and maxPlayer == 3 then self.ui.Items.Layout_Player:setPositionX(self.ui.Items.Layout_Player:getPositionX() + 140) self.ui.Items.Layout_noPlayer:setPositionX(self.ui.Items.Layout_noPlayer:getPositionX() + 140) end --观战数据 for k,v in pairsByKeys(app.room.roomInfo.playerList) do if v.mPlaying == 0 then if isFirst then isFirst = false local gz = self.ui.Items.Layout_Player_gz:getCopied() self.ui.Items.Layout_noPlayer:addChild(gz) end local player = self.ui.Items.Layout_PlayerNoPlay_Item:getCopied() player.Items = getUIItems(player) local userInfo = json.decode(v.userInfo); local name = getShortName(userInfo.nickname) setPlayerHeadImage(v.nUserId,userInfo.headimgurl,player.Items.ImageView_head_1,false) player.Items.Text_name_1:setText(tostring(name)) player.Items.Text_id_1:setText(tostring(v.nUserId)) --显示隐藏游戏内选手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 player.Items.Text_id_1:setVisible(true) else player.Items.Text_id_1:setVisible(false) end end end end if v.nUserId == tonumber(app.user.loginInfo.uid) then player.Items.Text_id_1:setVisible(true) end -- end if tonumber(v.nScore) > 0 then player.Items.Text_TurnScore_1:setText("+"..tostring(v.nScore)) else player.Items.Text_TurnScore_1:setText(tostring(v.nScore)) end self.ui.Items.Layout_noPlayer:addChild(player) if v.nUserId == app.room:getMyUserId() then self.ui.Items.ImageView_title:setVisible(false) end end if v.mPlaying == 1 and maxPlayer ~= 3 then if v.nUserId ~= app.room.roomInfo.nBankerUserId and v.nUserId ~= app.room.roomInfo.nBankerHelper then enemyList[v.nUserId] = v else friendList[v.nUserId] = v end end --3人玩法 if v.mPlaying == 1 and maxPlayer == 3 then if tonumber(v.nScore) < 0 then enemyList[v.nUserId] = v else friendList[v.nUserId] = v end end end for k,v in pairsByKeys(friendList) do local player = self.ui.Items.Layout_Player_Item:getCopied() player.Items = getUIItems(player) local userInfo = json.decode(v.userInfo); local name = getShortName(userInfo.nickname) setPlayerHeadImage(v.nUserId,userInfo.headimgurl,player.Items.ImageView_head,false) player.Items.Text_name:setText(tostring(name)) player.Items.Text_id:setText(tostring(v.nUserId)) --显示隐藏游戏内选手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 player.Items.Text_id:setVisible(true) else player.Items.Text_id:setVisible(false) end end end end if v.nUserId == tonumber(app.user.loginInfo.uid) then player.Items.Text_id:setVisible(true) end -- end player.Items.Text_boomScore:setText(tostring(v.mBombTimes)) if tonumber(v.nScore) > 0 then player.Items.Text_TurnScore:setText("+"..tostring(v.nScore)) else player.Items.Text_TurnScore:setText(tostring(v.nScore)) player.Items.ImageView_bg:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_lose.png") player.Items.ImageView_5:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_bombBg0.png") end if v.nUserId == app.room:getMyUserId() then if v.mWinLose == 2 then self.ui.Items.ImageView_title:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_xiaoju_pingju.png") elseif v.mWinLose == 0 then self.ui.Items.ImageView_title:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_xiaoju_lose.png") elseif v.mWinLose == 1 then self.ui.Items.ImageView_title:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_xiaoju_win.png") elseif v.mWinLose == -1 then self.ui.Items.ImageView_title:setVisible(false) end end if v.ranking > 0 then local file = string.format("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_ranking%d.png",v.ranking) player.Items.ImageView_flag:loadTexture(file) else player.Items.ImageView_4:setVisible(false) end self.ui.Items.Layout_Player:addChild(player) end local function doVs() local vs = self.ui.Items.Layout_Player_VS:getCopied() self.ui.Items.Layout_Player:addChild(vs) end --根据规则动态显示VS if PKFuc.getIsSingleBattle() and not isHavePeopleBaoPai then if maxPlayer == 2 then doVs() end else doVs() end for k,v in pairsByKeys(enemyList) do local player = self.ui.Items.Layout_Player_Item:getCopied() player.Items = getUIItems(player) local userInfo = json.decode(v.userInfo); local name = getShortName(userInfo.nickname) setPlayerHeadImage(v.nUserId,userInfo.headimgurl,player.Items.ImageView_head,false) player.Items.Text_name:setText(tostring(name)) player.Items.Text_id:setText(tostring(v.nUserId)) --显示隐藏游戏内选手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 player.Items.Text_id:setVisible(true) else player.Items.Text_id:setVisible(false) end end end end if v.nUserId == tonumber(app.user.loginInfo.uid) then player.Items.Text_id:setVisible(true) end -- end player.Items.Text_boomScore:setText(tostring(v.mBombTimes)) if tonumber(v.nScore) > 0 then player.Items.Text_TurnScore:setText("+"..tostring(v.nScore)) else player.Items.Text_TurnScore:setText(tostring(v.nScore)) player.Items.ImageView_bg:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_lose.png") player.Items.ImageView_5:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_bombBg0.png") end if v.nUserId == app.room:getMyUserId() then if v.mWinLose == 2 then self.ui.Items.ImageView_title:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_xiaoju_pingju.png") elseif v.mWinLose == 0 then self.ui.Items.ImageView_title:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_xiaoju_lose.png") elseif v.mWinLose == 1 then self.ui.Items.ImageView_title:loadTexture("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_xiaoju_win.png") elseif v.mWinLose == -1 then self.ui.Items.ImageView_title:setVisible(false) end end if v.ranking > 0 then local file = string.format("pk_base/res/ui/zy_fangjian/jiesuanView/pk_jiesuan_ranking%d.png",v.ranking) player.Items.ImageView_flag:loadTexture(file) else player.Items.ImageView_4:setVisible(false) end self.ui.Items.Layout_Player:addChild(player) end self.ui.Items.Layout_Player:requestDoLayout() self.ui.Items.Layout_Player:doLayout() self.ui.Items.Layout_noPlayer:requestDoLayout() self.ui.Items.Layout_noPlayer:doLayout() end -- 查牌 function PKRoomXiaoJuView:onClickChaPai() playBtnEffect() self:setVisible(false) if self.chaPaiCallBackFun then self.chaPaiCallBackFun() end end -- 下一局 function PKRoomXiaoJuView:onClickNext() playBtnEffect() if self.nextCallBack then self.nextCallBack() end end function PKRoomXiaoJuView:onClickZongJieSuan() playBtnEffect() if self.dajuCallBack then self.dajuCallBack() end end return PKRoomXiaoJuView;