|
- local Functions = require("pk_nanchongdoudizhu.luaScript.Functions_53")
- local defs = require("pk_nanchongdoudizhu.luaScript.Def_53")
-
- -- 房间设置界面
- local RoomPlayerView_53 = class("RoomPlayerView_53", cc.UIView)
-
- function RoomPlayerView_53:ctor()
- RoomPlayerView_53.super.ctor(self)
- end
-
- function RoomPlayerView_53:onEnter()
- RoomPlayerView_53.super.onEnter(self)
- local ui = loadUI("pk_nanchongdoudizhu/res/ui/ui_fangjian/doudizhu_ui_PlayerView.ui")
- self:addChild(ui)
- self.ui = ui
-
- --默认隐藏玩家头像
- for i = 1, 4 do
- local player = self.ui.Items["Layout_Player_" .. i]
- if player then
- player:setVisible(false)
- end
- end
-
- self:initChatComponent()
- end
-
- function RoomPlayerView_53:initChatComponent()
- if self.chatComponentView and not tolua.isnull(self.chatComponentView) then
- return
- end
-
- local heads = {
- -- [1] = self.allNodes[1].head,
- -- [2] = self.allNodes[2].head,
- -- [3] = self.allNodes[3].head,
- -- [4] = self.allNodes[4].head,
- }
-
- for i = 1, 4 do
- local head = self.ui.Items["Image_Head_" .. i]
- if head then
- table.insert(heads, head)
- end
- end
-
- self.chatComponentView = import("luaScript.Views.Room.RoomChatComponentView"):new(heads, defs.GAME_CHAT_TXT)
- local voiceEnable = tonumber(loadUserInfo("PingBiYuYinKG" .. app.gameId)) or 1
- local propEnable = tonumber(loadUserInfo("HuDongBiaoQingKG" .. app.gameId)) or 1
- self.chatComponentView:setVoiceEnabled(voiceEnable==1)
- self.chatComponentView:setPropEnabled(propEnable==1)
- self:addChild(self.chatComponentView)
- end
-
- function RoomPlayerView_53:ontSetPropEnabled()
- local propEnable = tonumber(loadUserInfo("HuDongBiaoQingKG" .. app.gameId)) or 1
- self.chatComponentView:setPropEnabled(propEnable==1)
- end
-
- function RoomPlayerView_53:onSetVoiceEnabled()
- local voiceEnable = tonumber(loadUserInfo("PingBiYuYinKG" .. app.gameId)) or 1
- self.chatComponentView:setVoiceEnabled(voiceEnable==1)
- end
-
- function RoomPlayerView_53:getPlayerData(type, viewId)
- local player = self.ui.Items["Layout_Player_" .. viewId]
-
- if player then
- if type == "sex" then
- return player.userInfo.sex
- end
- end
-
- return nil
- end
-
- --刷新玩家
- function RoomPlayerView_53:updatePlayer(playerInfo, viewId)
- if playerInfo then
- self:initPlayer(playerInfo, viewId)
- else
- for _,v in pairs(app.room.roomInfo.memberList) do
- self:initPlayer(v, app.room:getViewIdByUserId(v.nUserId))
- end
- end
- end
-
- --更新玩家信息
- function RoomPlayerView_53:initPlayer(playerInfo, viewId)
- logE("RoomPlayerView_53 initPlayer viewId : " .. viewId)
- logE("RoomPlayerView_53 initPlayer playerInfo : " .. table.tostring(playerInfo))
-
- local player = self.ui.Items["Layout_Player_" .. viewId]
- if player then
- player:setVisible(true)
- local userInfo = json.decode(playerInfo.userInfo)
-
- player.playerInfo = playerInfo
- player.userInfo = userInfo
-
- --头像
- local head = self.ui.Items["Image_Head_" .. viewId]
- setDefaultHeadImg(userInfo.sex, playerInfo.nUserId, head, head:getContentSize().width)
- setPlayerHeadImage(playerInfo.nUserId, userInfo.headimgurl, head)
- head:registerClick(function()
- self:onClickHead(viewId)
- end)
-
- --名字
- local nickname = userInfo.nickname or "error"
- self.ui.Items["Text_Name_" .. viewId]:setText(nickname)
-
- --分数
- local nTotalScore = playerInfo.nTotalScore or 0
- self.ui.Items["Text_Score_" .. viewId]:setText(nTotalScore)
-
- --庄家
- local nBankerId = app.room.roomInfo.nBankerId or 0
- self.ui.Items["Image_Banker_" .. viewId]:setVisible(nBankerId == playerInfo.nUserId)
-
- --离线 (0:离线、1:在线)
- local nOnlineStatus = playerInfo.nOnlineStatus or 1
- self.ui.Items["Image_OffLine_" .. viewId]:setVisible(nOnlineStatus == 0)
- --头像变灰
- self:setHeadGreyEnabled(nOnlineStatus == 0, viewId)
-
- --准备 (0:未准备、1:已准备)
- local nPlayerFlag = playerInfo.nPlayerFlag or 0
- self.ui.Items["Image_Ready_" .. viewId]:setVisible(nPlayerFlag == 1)
-
- --加倍
- local askBei = playerInfo.askBei or 0
- self.ui.Items["Image_AskBei_" .. viewId]:setVisible(askBei == 1)
-
- --闹钟
- self.ui.Items["Image_Clock_" .. viewId]:setVisible(false)
-
- --请让我再想想
- self.ui.Items["Image_Pop_" .. viewId]:setVisible(false)
-
- -- 头像框
- self.ui.Items["Image_HeadMask_" .. viewId]:setVisible(false)
-
- -- 漂
- self.ui.Items['Layout_Piao_' .. viewId]:setVisible(false)
-
- -- 倒or拉
- self.ui.Items['Layout_DaoOrLa_' .. viewId]:setVisible(false)
-
- -- 定漂中
- self.ui.Items['Image_ChoosePiao_' .. viewId]:setVisible(false)
-
- --剩余牌
- local leftNumText = self.ui.Items["Text_LeftNum_" .. viewId]
- local leftNumImage = self.ui.Items["Image_LeftNum_" .. viewId]
- if leftNumText then
- leftNumText:setVisible(false)
- end
- if leftNumImage then
- leftNumImage:setVisible(false)
- end
-
- self.ui.Items['Layout_Head_Tip_' .. viewId]:requestDoLayout()
- self.ui.Items['Layout_Head_Tip_' .. viewId]:doLayout()
- end
- end
-
- function RoomPlayerView_53:onClickHead(index)
- playBtnEffect()
- local nUserId = app.room.seatShowList[index]
- local memberInfo = app.room.roomInfo.memberList[nUserId]
- if memberInfo then
- local view = import("luaScript.Views.Room.RoomPlayerInfoViewNew"):new(nUserId, memberInfo.userInfo)
- view:setAnchorPoint(cc.p(0.5, 0.5))
- app:showWaitDialog(view, 0, true)
- end
- end
-
- --隐藏玩家
- function RoomPlayerView_53:hidePlayer(viewId)
- local player = self.ui.Items["Layout_Player_" .. viewId]
-
- logE("RoomPlayerView_53 hidePlayer viewId : " .. viewId)
-
- if player then
- player:setVisible(false)
- end
- end
-
- --刷新分数
- function RoomPlayerView_53:updateScore(viewId, totalScore)
- local score = self.ui.Items["Text_Score_" .. viewId]
-
- logE("RoomPlayerView_53 updateScore viewId : " .. viewId)
-
- if score then
- score:setText("" .. totalScore)
- end
- end
-
- --显隐剩余牌
- function RoomPlayerView_53:setLeftNumVisible(bVisible, viewId, num)
- --是否是回放
- if app.room.roomInfo.isRecord then
- return
- end
-
- -- 剩余牌
- local isNotShowLeftNumCard = false
-
- logE("RoomPlayerView_53 setReadyVisible bVisible : " .. (bVisible and 1 or 0))
- logE("RoomPlayerView_53 setReadyVisible viewId : " .. (viewId and viewId or -1))
- logE("RoomPlayerView_53 setReadyVisible num : " .. (num and num or -1))
-
- if not isNotShowLeftNumCard then
- -- 显示剩余牌
- if viewId == -1 then
- for i = 1, 4 do
- local leftNumText = self.ui.Items["Text_LeftNum_" .. i]
- local leftNumImage = self.ui.Items["Image_LeftNum_" .. i]
- if leftNumText then
- leftNumText:setVisible(bVisible)
- if bVisible then
- leftNumText:setText("" .. num)
- end
- end
- if leftNumImage then
- leftNumImage:setVisible(bVisible)
- end
- end
- else
- local leftNumText = self.ui.Items["Text_LeftNum_" .. viewId]
- local leftNumImage = self.ui.Items["Image_LeftNum_" .. viewId]
- if leftNumText then
- leftNumText:setVisible(bVisible)
- if bVisible then
- leftNumText:setText("" .. num)
- end
- end
- if leftNumImage then
- leftNumImage:setVisible(bVisible)
- end
- end
- end
-
- -- 显示闹钟
- if viewId == -1 then
- self:cleanAllBaoJing()
- else
- if num == 1 or num == 2 then
- self:showBaoJingAni(viewId)
- Functions.playLastNumVoice(num, self:getPlayerData('sex', viewId))
- else
- self:showBaoJingAni(viewId, true)
- end
- end
- end
-
- --显隐准备
- function RoomPlayerView_53:setReadyVisible(bVisible, viewId)
- local ready = self.ui.Items["Image_Ready_" .. viewId]
-
- logE("RoomPlayerView_53 showReady viewId : " .. viewId)
-
- if ready then
- ready:setVisible(bVisible)
- end
- end
-
- function RoomPlayerView_53:getChatViewPos()
- local headInfos = {}
- for i = 1, 4 do
- local head = self.ui.Items["Image_Head_" .. i]
- local player = self.ui.Items["Layout_Player_" .. i]
- if head and player then
- table.insert(headInfos, {headPos = cc.pAdd(cc.pAdd(player:getPosition(), head:getPosition()), cc.p(0, 0))})
- end
- end
- return headInfos
- end
-
- function RoomPlayerView_53:setOffLineVisible(bVisible, viewId)
- local offLine = self.ui.Items["Image_OffLine_" .. viewId]
- if offLine then
- offLine:setVisible(bVisible)
- --头像变灰
- self:setHeadGreyEnabled(bVisible, viewId)
- end
- end
-
- function RoomPlayerView_53:setHeadGreyEnabled(bVisible, viewId)
- local head = self.ui.Items["Image_Head_" .. viewId]
- local headMask = self.ui.Items["Image_HeadMask_" .. viewId]
- if head and headMask then
- head:setGreyEnabled(bVisible)
- headMask:setGreyEnabled(bVisible)
- end
- end
-
- function RoomPlayerView_53:bankerAni(viewId)
- local banker = self.ui.Items["Image_Banker_" .. viewId]
- if banker then
- banker:stopAllActions()
- banker:runAction(
- cc.Sequence:create(
- cc.ScaleTo(0, 2)
- )
- )
- end
- end
-
- function RoomPlayerView_53:setBankerVisible(bVisible, viewId)
- local banker = self.ui.Items["Image_Banker_" .. viewId]
- if banker then
- banker:setVisible(bVisible)
- end
- end
-
- function RoomPlayerView_53:setClockVisibel(bVisible, viewId, times)
- local clock = self.ui.Items["Image_Clock_" .. viewId]
- if clock then
- clock:setVisible(bVisible)
- local imagePop = self.ui.Items["Image_Pop_" .. viewId]
- if imagePop then
- imagePop:setVisible(false)
- end
- local time = self.ui.Items["Text_Clock_" .. viewId]
- time:stopAllActions()
- if bVisible then
- local timesEx = times
- time:runAction(
- cc.RepeatForever:create(
- cc.Sequence:create(
- cc.CallFunc:create(function()
- time:setText("" .. timesEx)
- timesEx = timesEx - 1
- if timesEx < 5 then
- -- imagePop:setVisible(true)
- if timesEx < 0 then
- time:stopAllActions()
- end
- end
- end),
- cc.DelayTime:create(1.0)
- )
- )
- )
- end
- end
- end
-
- function RoomPlayerView_53:setTipsVisible(tipsType, bVisible, viewId, data)
- --显示锚点设置
- local anchorPont = {
- [1] = cc.p(1, 0.5),
- [2] = cc.p(0.5, 0.5),
- [3] = cc.p(0, 0.5),
- [4] = cc.p(0.5, 0.5),
- }
-
- local tipsFunc = {}
-
- -- 漂
- tipsFunc["tips_piao"] = function(nodeParent)
- local tips = nodeParent["tips_piao"]
- if tips then
- tips:removeFromParent()
- nodeParent["tips_piao"] = nil
- end
- if bVisible then
- local str = "pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_tips_piao.png"
- if data.piaoState ~= defs.PIAO_STATE.PIAO_STATE_YES then
- str = "pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_tips_bupiao.png"
- end
- local tipsEx = cc.Sprite:create(string.format(str))
- if tipsEx then
- tipsEx:setAnchorPoint(anchorPont[viewId])
- nodeParent["tips_piao"] = tipsEx
- nodeParent:addChild(tipsEx)
- end
- self:setPiaoVisible(viewId, data.piaoState == defs.PIAO_STATE.PIAO_STATE_YES)
- end
- end
-
- --闷抓
- tipsFunc["tips_menzhua"] = function(nodeParent)
- local tips = nodeParent["tips_menzhua"]
- if tips then
- tips:removeFromParent()
- nodeParent["tips_menzhua"] = nil
- end
- if bVisible then
- local str = "pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_tips_menzhua.png"
- if data.menzhua ~= defs.MEN_STATE.MEN_STATE_ZHUAI then
- str = "pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_tips_pass.png"
- end
- local tipsEx = cc.Sprite:create(string.format(str))
- if tipsEx then
- tipsEx:setAnchorPoint(anchorPont[viewId])
- nodeParent["tips_menzhua"] = tipsEx
- nodeParent:addChild(tipsEx)
- end
- end
- end
-
- --闷倒
- tipsFunc["tips_mendao"] = function(nodeParent)
- local tips = nodeParent["tips_mendao"]
- if tips then
- tips:removeFromParent()
- nodeParent["tips_mendao"] = nil
- end
- if bVisible then
- local str = "pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_tips_mendao.png"
- if data.mendao ~= defs.MEN_STATE.MEN_STATE_DAO then
- str = "pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_tips_pass.png"
- end
- local tipsEx = cc.Sprite:create(string.format(str))
- if tipsEx then
- tipsEx:setAnchorPoint(anchorPont[viewId])
- nodeParent["tips_mendao"] = tipsEx
- nodeParent:addChild(tipsEx)
- end
- -- self:setDaoOrLaVisible(viewId, data.mendao == defs.MEN_STATE.MEN_STATE_DAO, 'dao')
- end
- end
-
- --闷拉
- tipsFunc["tips_menla"] = function(nodeParent)
- local tips = nodeParent["tips_menla"]
- if tips then
- tips:removeFromParent()
- nodeParent["tips_menla"] = nil
- end
- if bVisible then
- local str = "pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_tips_menla.png"
- if data.menla ~= defs.MEN_LA_STATE.MEN_STATE_LA_ZHUAI then
- str = "pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_tips_pass.png"
- end
- local tipsEx = cc.Sprite:create(string.format(str))
- if tipsEx then
- tipsEx:setAnchorPoint(anchorPont[viewId])
- nodeParent["tips_menla"] = tipsEx
- nodeParent:addChild(tipsEx)
- end
- -- self:setDaoOrLaVisible(viewId, data.menla == defs.MEN_LA_STATE.MEN_STATE_LA_ZHUAI, 'la')
- end
- end
-
- --叫分(抓)
- tipsFunc["tips_jiaofen"] = function(nodeParent)
- local tips = nodeParent["tips_jiaofen"]
- if tips then
- tips:removeFromParent()
- nodeParent["tips_jiaofen"] = nil
- end
- if bVisible then
- local str = "pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_tips_fen%d.png"
- if data.askLoard ~= 1 then
- str = "pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_tips_pass.png"
- end
- local tipsEx = cc.Sprite:create(string.format(str, data.askLoard))
- if tipsEx then
- tipsEx:setAnchorPoint(anchorPont[viewId])
- nodeParent["tips_jiaofen"] = tipsEx
- nodeParent:addChild(tipsEx)
- end
- end
- end
-
- --加倍(倒)
- tipsFunc["tips_jiabei"] = function(nodeParent)
- local tips = nodeParent["tips_jiabei"]
- if tips then
- tips:removeFromParent()
- nodeParent["tips_jiabei"] = nil
- end
- if bVisible then
- local str = "pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_tips_bei%d.png"
- if data.askBei ~= defs.DAO_STATE.DAO_STATE_YES then
- str = "pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_tips_pass.png"
- end
- local tipsEx = cc.Sprite:create(string.format(str, data.askBei))
- if tipsEx then
- tipsEx:setAnchorPoint(anchorPont[viewId])
- nodeParent["tips_jiabei"] = tipsEx
- nodeParent:addChild(tipsEx)
- end
- -- self:setAskBeiVisible(data.askBei == defs.DAO_STATE.DAO_STATE_YES, viewId)
- -- self:setDaoOrLaVisible(viewId, data.askBei == defs.DAO_STATE.DAO_STATE_YES, 'dao')
- end
- end
-
- --加倍(拉)
- tipsFunc["tips_jiabei_la"] = function(nodeParent)
- local tips = nodeParent["tips_jiabei_la"]
- if tips then
- tips:removeFromParent()
- nodeParent["tips_jiabei_la"] = nil
- end
- if bVisible then
- local str = "pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_tips_la%d.png"
- if data.askBei ~= defs.DAO_STATE.LA_STATE_YES then
- str = "pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_tips_pass.png"
- end
- local tipsEx = cc.Sprite:create(string.format(str, data.askBei))
- if tipsEx then
- tipsEx:setAnchorPoint(anchorPont[viewId])
- nodeParent["tips_jiabei_la"] = tipsEx
- nodeParent:addChild(tipsEx)
- end
- -- self:setAskBeiVisible(data.askBei == defs.DAO_STATE.LA_STATE_YES, viewId)
- -- self:setDaoOrLaVisible(viewId, data.askBei == defs.DAO_STATE.LA_STATE_YES, 'la')
- end
- end
-
- --要不起,不出
- tipsFunc["tips_yaobuqi"] = function(nodeParent)
- local tips = nodeParent["tips_yaobuqi"]
- if tips then
- tips:removeFromParent()
- nodeParent["tips_yaobuqi"] = nil
- end
- if bVisible then
- local tipsEx = cc.Sprite:create(string.format("pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_desk/doudizhu_desk_tips_yaobuqi.png"))
- if tipsEx then
- tipsEx:setAnchorPoint(anchorPont[viewId])
- nodeParent["tips_yaobuqi"] = tipsEx
- nodeParent:addChild(tipsEx)
- end
- end
- end
-
- --显隐对应的提示
- local tipsNode = self.ui.Items["Layout_Tips_" .. viewId]
- if tipsNode then
- local tipsFuncEx = tipsFunc["" .. tipsType]
- if tipsFuncEx then
- tipsFuncEx(tipsNode)
- end
- end
- end
-
- function RoomPlayerView_53:hideAllTip()
- local allTips = {
- 'tips_piao',
- 'tips_menzhua',
- 'tips_mendao',
- 'tips_menla',
- 'tips_jiaofen',
- 'tips_jiabei',
- 'tips_jiabei_la',
- 'tips_yaobuqi',
- }
-
-
- print('清除所有节点')
- for i = 1, 4 do
- for _, v in ipairs(allTips) do
- self:setTipsVisible(v, false, i)
- end
- end
- end
-
- function RoomPlayerView_53:setAskBeiVisible(bVisible, viewId)
- local askBei = self.ui.Items["Image_AskBei_" .. viewId]
- if askBei then
- askBei:setVisible(bVisible)
- end
- end
-
- function RoomPlayerView_53:showBaoJingAni(viewId, clean)
- local nodeLayout = self.ui.Items['Layout_baojing_'..viewId]
- nodeLayout:removeAllChildren()
-
- if clean then
- return
- end
-
- --ani
- local img = cc.ImageView:createNode()
- img:loadTextureFromPlist("ddz_baojing_bg.png")
- nodeLayout:addChild(img)
- img:setPosition(cc.p(nodeLayout:getContentSize().width/2,nodeLayout:getContentSize().height/2))
-
- --light
- local light = cc.ImageView:createNode("ddz_baojing_bg.png")
- nodeLayout:addChild(light)
- light:setPosition(cc.p(nodeLayout:getContentSize().width/2,nodeLayout:getContentSize().height/2))
-
- local indexFace = 0;
- --每隔多少秒切换一张图片
- local everyFrame = 0.01
- local seq = cc.Sequence:create(cc.DelayTime:create(everyFrame),cc.CallFunc:create(function ()
- indexFace = indexFace + 1
- if 0 < indexFace and indexFace <= 8 then
- local name = string.format("ddz_baojing_%d.png",indexFace)
- light:loadTextureFromPlist(name)
- else
- indexFace = 0
- end
- end))
- local act = cc.RepeatForever:create(seq)
- light:runAction(act)
-
- -- 经过几面后,移除警报动画
- local removeDelayTime = 1.5
- local function removeCallBack()
- nodeLayout:stopAllActions()
- nodeLayout:removeAllChildren()
- end
- schedule(nodeLayout, removeCallBack, removeDelayTime)
- end
-
- function RoomPlayerView_53:cleanAllBaoJing()
- for i = 1, 4 do
- local nodeLayout = self.ui.Items['Layout_baojing_'..i]
- nodeLayout:removeAllChildren()
- end
- end
-
- -- 倒or拉
- function RoomPlayerView_53:setDaoOrLaVisible(viewId, bVisible, tag)
- local nodeParent = self.ui.Items['Layout_Head_Tip_'..viewId]
- local nodeLayout = self.ui.Items['Layout_DaoOrLa_'..viewId]
- local nodeImg = self.ui.Items['Image_DaoOrLa_'..viewId]
-
- if nodeParent and nodeLayout and nodeImg then
- if tag and bVisible then
- if tag == 'dao' then
- nodeImg:loadTexture('pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_player/zy_ddz_player_dao.png')
- elseif tag == 'la' then
- nodeImg:loadTexture('pk_nanchongdoudizhu/res/ui/zy_fangjian/doudizhu_player/zy_ddz_player_la.png')
- end
- end
-
- nodeLayout:setVisible(bVisible)
- nodeParent:requestDoLayout()
- nodeParent:doLayout()
- end
- end
-
- -- 漂
- function RoomPlayerView_53:setPiaoVisible(viewId, bVisible)
- local nodeParent = self.ui.Items['Layout_Head_Tip_'..viewId]
- local nodeLayout = self.ui.Items['Layout_Piao_'..viewId]
-
- if nodeParent and nodeLayout then
- nodeLayout:setVisible(bVisible)
- nodeParent:requestDoLayout()
- nodeParent:doLayout()
- end
- end
-
- -- 选漂
- function RoomPlayerView_53:setChoosePiaoVisible(bVisible, viewId)
- if viewId == 4 then
- return
- end
-
- local nodeImg = self.ui.Items['Image_ChoosePiao_' .. viewId]
- if nodeImg then
- nodeImg:setVisible(bVisible)
- end
- end
-
- return RoomPlayerView_53
|