|
- local MJ=MJFramework.MJImport("mj.luaScript.Views.Game.MJ")
- local MJDefine=MJFramework.MJImport("mj.luaScript.MJDefine")
- local MJGroupFactory=MJFramework.MJImport("mj.luaScript.Views.Game.MJGroupFactory")
- local MJPositionCompnent = MJFramework.MJImport("mj.luaScript.Views.Compnent.MJPositionCompnent")
- local MJMessage=MJFramework.MJImport("mj.luaScript.Protocol.MJMessage")
- local MJHandCardView=MJFramework.MJFrameworkClassImprot("mj.luaScript.Views.Game.MJHandCardView")
- local MJSound = MJFramework.MJImport("mj.luaScript.MJSound")
-
- local GuangAnHandCardView = class("GuangAnHandCardView", MJHandCardView)
-
- function GuangAnHandCardView:ctor(viewId,desktopType)
- GuangAnHandCardView.super.ctor(self,viewId,desktopType)
- end
-
- function GuangAnHandCardView:loadUI()
- local ui
- if self.desktopType==MJDefine.DesktopType.TwoD or self.desktopType==MJDefine.DesktopType.TwoDGold or self.desktopType==MJDefine.DesktopType.TwoDL then
- ui = loadUI("mj_guangan/res/ui_fangjian/mj_guangan_hand_card_2d.ui");
- else
- ui = loadUI("mj_guangan/res/ui_fangjian/mj_guangan_hand_card.ui");
- end
- self.ui = ui;
- self:addChild(ui)
- end
-
- function GuangAnHandCardView:initView()
- if self:isUseNew3D() then
- self:initNew3DUI()
- else
- GuangAnHandCardView.super.initView(self)
- self:hideOperateItem()
-
- if self.desktopType ~= MJDefine.DesktopType.TwoDGold then
- local playerCount = app.room:getMaxPlayerCount()
- local startPos = MJDefine.MJConfig_2d.OutCardStartPos[self.viewId]
- if playerCount == 2 then
- startPos = MJDefine.MJConfig_2d.OutCardStartPos2[self.viewId]
- end
-
- self.outX=startPos.x
- self.outY=startPos.y
- end
-
- end
-
- end
-
- ---
- -- 初始化新3d牌
- --
- function GuangAnHandCardView:initNew3DUI()
- self:loadUI()
-
- if self.ui.Items.Layout_Hand_Card then
- self.ui.Items.Layout_Hand_Card:setVisible(false)
- end
- if self.ui.Items.Layout_OperateItem then
- self.ui.Items.Layout_OperateItem:setVisible(false)
- end
- if self.ui.Items.Button_Sure then
- self.ui.Items.Button_Sure:setVisible(false)
- end
-
- local MJConfig = MJDefine.MJConfig_2d
- if self.desktopType == MJDefine.DesktopType.ThreeD then
- MJConfig = MJDefine.MJConfig_3d
- end
-
- local MahjongHandCard = require(MJConfig.HANDCARD_VIEW)
- local MahjongOutCardView = require(MJConfig.OUTCARD_VIEW)
- local MahjongHuCardView = require(MJConfig.HU_CARD_VIEW)
-
- self._huCardView = MahjongHuCardView:new(self.viewId)
- self:addChild(self._huCardView)
-
- self._handcard = MahjongHandCard:new(self.viewId, self.desktopType)
- self:addChild(self._handcard)
-
- self._outCardView = MahjongOutCardView:new(self.viewId)
- self:addChild(self._outCardView)
-
- self.ui:setLocalZOrder(10)
- end
-
- function GuangAnHandCardView:pushTing()
- local groupCards
- if self:isUseNew3D() then
- self._handcard:pushTing()
- groupCards = self._handcard._groupNodes
- else
- local tings=app.room.roomInfo.tings
- if tings then
- for k,v in pairs(tings) do
- for _,mj in pairs(self.handCards) do
- if mj.value==v.outCard then
- mj:setTing(true)
- end
- end
- end
- end
- groupCards = self.handGroupCards
- end
- end
-
-
- --摸牌
- function GuangAnHandCardView:onGetCard(operates,card,isSwap)
- if self:isUseNew3D() then
- self.touchMJ = nil
- self:createHandCards(card)
- self:setPaoCard(true)--为了标记摸到的牌也是炮牌
-
- if not operates or table.nums(operates) == 0 then
- self._handcard:setOutCardEnable(true)
- MJDefine.outCardSendGuo = false
- else
- self._handcard:setOutCardEnable(true)
- MJDefine.outCardSendGuo = true
- -- self:canOutCard(true)
- end
-
- if self.viewId==MJDefine.MyViewId then
- MJSound.PlayGetCard()
- end
- else
- if self.viewId==MJDefine.MyViewId then
- self:resetHandCardsPosAndOpacity()
- end
- self:createHandCards(card)
- self:setPaoCard(true)--为了标记摸到的牌也是炮牌
- self:resetCardsSortValue()--为了给刚摸上的牌重新赋值排序值
-
- if self.viewId==MJDefine.PlayerViewType.Right and not self.isReplay then
- self:resetHandCards()
- end
-
- if isSwap and isSwap == true then return end --如果是换牌阶段,返回
- if not operates or table.nums(operates)==0 then
- self:setOutCardEnable(true)
- MJDefine.outCardSendGuo = false
- else
- self:setOutCardEnable(true)
- self:moveLastCard()
- MJDefine.outCardSendGuo = true
- -- self:canOutCard(true)
- end
-
- if self.viewId==MJDefine.MyViewId then
- MJSound.PlayGetCard()
- end
- end
- end
-
- function GuangAnHandCardView:setOutCardEnable(b)
- if self:isUseNew3D() then
- self._handcard:setOutCardEnable(b)
- else
- self.isOutCard=b
- if b then
- self:moveLastCard()
- end
- if self.viewId==MJDefine.MyViewId and self.ui.Items.Button_Sure then
- -- self.ui.Items.Button_Sure:setVisible(b)
- end
- end
- end
-
-
- --不管是否自动对齐,红中始终保持放在最左边
- function GuangAnHandCardView:sortRedMahjong()
- local redNum = 0
- for k,mj in pairs(self.handCards) do
- if mj.value == 65 then
- redNum = redNum + 1
- table.remove(self.handCards,k)
- table.insert(self.handCards,redNum,mj)
- end
- end
- end
-
- function GuangAnHandCardView:removeHandCardByNum(value,num,redNum)
- redNum = redNum or 0
- if self:isUseNew3D() then
- self._handcard:removeHandCardByNum(value, num,redNum)
- else
- if self.viewId==MJDefine.MyViewId or self.isReplay then
- for i=1,num do
- local mj
- if redNum > 0 and i <= redNum then
- mj=self:getMjByValue(65) --红中值
- else
- mj=self:getMjByValue(value)
- end
- if mj then
- table.removeItem(self.handCards,mj)
- mj:removeFromParent()
- end
- end
- else
- -- local num=#self.handCards-#arg
- -- print(num)
-
- for i=#self.handCards,#self.handCards-num+1,-1 do
- if self.handCards[i] then
- self.handCards[i]:removeFromParent()
- table.remove(self.handCards,i)
- end
- end
- end
- end
- end
-
- function GuangAnHandCardView:getGroup(card,opType)
- if self:isUseNew3D() then
- return self._handcard:getGroup(card, opTypes)
- else
- for k,v in pairs(self.handGroupCards) do
- if v.opType==opType and (v.mjs[1].value==card or v.mjs[2].value == card or v.mjs[3].value == card) then
- local redNum = 0
- for i,mj in pairs(v.mjs) do
- --先取出原组合的红中个数
- if mj.value == 65 then
- redNum = redNum + 1
- end
- end
- return v,redNum
- end
- end
- end
- end
-
- function GuangAnHandCardView:createGroupCards(arg,fromViewId)
- if self:isUseNew3D() then
- self._handcard:createGroupCards(arg, fromViewId)
- else
- local x=self.initX
- local y=self.initY
- local MJGroupStartOffSet = MJDefine.MJGroupStartOffSet[self.desktopType]
- for k,v in pairs(arg) do
- if not fromViewId then
- fromViewId = v.fromViewId
- end
- local group=MJGroupFactory.CreateGroup(v.values,v.showType,self.viewId,self.desktopType,v.redNum)
- if group then
- --设置碰杠来源
- --group:setDirection(self.viewId,v.fromViewId1)
-
- if group.setAnColor and (v.opType == MJDefine.MJOperateType.OPREATE_PENG
- or v.opType == MJDefine.MJOperateType.OPREATE_ZHIGANG
- or v.opType == MJDefine.MJOperateType.OPREATE_BAGANG) then
- --牌的阴影显示刚好和视图id相反
- if v.fromViewId == 1 then v.fromViewId = 3
- elseif v.fromViewId==3 then v.fromViewId = 1 end
- -- 杠牌对家,换成第四张
- if v.opType ~= MJDefine.MJOperateType.OPREATE_PENG then
- if v.fromViewId==2 then v.fromViewId = 4 end
- end
- group:setAnColor(v.opCard, v.fromViewId)
- end
- if v.opType == MJDefine.MJOperateType.OPREATE_BAGANG and group.mjs and group.mjs[4] then
- group.mjs[4]:setOutBlackImage(0,self.viewId)
- end
-
- group.fromViewId = v.fromViewId ---保留触发操作的玩家位置,补杠需要
- group.opType=v.opType
- self.ui.Items.Layout_Hand_Card:addChild(group,-4+#self.handGroupCards)
- group:setPosition(cc.p(x+MJGroupStartOffSet[self.viewId].x,y+MJGroupStartOffSet[self.viewId].y))
- x,y=MJPositionCompnent.getGroupPosition(self.viewId,x,y,group,self.desktopType)
- table.insert(self.handGroupCards,group)
- end
- end
- --更新起始位置
- self.initX=x
- self.initY=y
- end
- end
-
- --添加杠操作按钮
- function GuangAnHandCardView:addOperateBtn(operates,isCanHu)
- local x=self.ui.Items.Layout_Operate:getContentSize().width
- local y=self.ui.Items.Layout_Operate:getContentSize().height/2
- local btnOperate=cc.Button:createNode()
- btnOperate:setDefaults()
- btnOperate:setText("")
- btnOperate:loadTextureNormal(MJDefine.MJOperateImage[operates[1].opType])
- btnOperate:ignoreAnchorPointForPosition(false)
- self.btnPosX = self.btnPosX-MJDefine.MJ_OPERATE_PADDING
- btnOperate:setPosition(cc.p(self.btnPosX, y))
- self.ui.Items.Layout_Operate:addChild(btnOperate,2)
-
- if operates and table.nums(operates) <=1 then
- --self.btnPosX = self.btnPosX-50
- btnOperate:setPosition(cc.p(self.btnPosX, y))
- local gangBg = cc.Layout:create()
- gangBg:setBackGroundImageScale9Enabled(true)
- gangBg:setBackGroundImage("mj_guangan/res/zy_fangjian/guanganadd/guangan_room_gangBg1.png",0)
- --gangBg:setOpacity(150)
- --gangBg:setPosition(cc.p(btnOperate:getPositionX()+30, y-40))
- gangBg:setPosition(cc.p(btnOperate:getPositionX()-52, y+50))
- gangBg:setSize(cc.size(70,90))
- gangBg:setScale(1.3)
- self.ui.Items.Layout_Operate:addChild(gangBg,5)
-
- gangBg:registerClick(function(sender)
- self:sendOp({opType = operates[1].opType,opCard = operates[1].opCard,redNum = operates[1].redNum})
- end)
-
- local mj
- local guangan_mj_color = loadUserInfo("mj_guangan_desktop_2d_mjType") or MJDefine.DesktopType.TwoDL
- local CardClass
- --if guangan_mj_color == "2dl" then
- -- CardClass = require("mj_guangan.luaScript.Views.2d.Card_2d_L")
- -- mj = CardClass:new(operates[1].opCard, 4, MJDefine.MJConfig_2d.MJType.Out, 1)
- --else
- mj=MJ:new(operates[1].opCard,MJDefine.MJType.Out,MJDefine.MyViewId,self.desktopType)
- --end
-
- --mj:setScale(0.7)
- mj:setAnchorPoint(cc.p(0.5,0.5))
- gangBg:addChild(mj)
- --self.ui.Items.Layout_Operate:addChild(mj)
- mj:setPosition(cc.p(gangBg:getContentSize().width/2, gangBg:getContentSize().height/2))
- --mj:setPosition(cc.p(btnOperate:getPositionX()-6, y+90))
- end
- local function qiHuConfirm()
- local content = string.format("确定放弃胡牌吗?")
- local okCallBack = function ()
- if operates and table.nums(operates) <=1 then
- self:sendOp({opType = operates[1].opType,opCard = operates[1].opCard,redNum = operates[1].redNum})
- else
- self:showGangItem(operates)
- end
- end
- local cancelCallBack = function ()
-
- end
- showConfirmDialog(content,okCallBack,cancelCallBack)
- end
-
- if isCanHu and isCanHu == true then
- btnOperate:registerClick(qiHuConfirm)
- else
- btnOperate:registerClick(function()
- -- playBtnEffect()
- if operates and table.nums(operates) <=1 then
- self:sendOp({opType = operates[1].opType,opCard = operates[1].opCard,redNum = operates[1].redNum})
- else
- self:showGangItem(operates)
- end
- end)
- end
- end
-
- function GuangAnHandCardView:showGangItem(operates)
- self.ui.Items.Layout_OperateItem:setVisible(true)
- self.ui.Items.Layout_Operate_Content:removeAllChildren()
- local col = 0
- local count = 6
- for k,v in pairs(operates) do
- local item = self.ui.Items.Layout_MJ_Item:getCopied()
- local mj=MJ:new(v.opCard,MJDefine.MJType.Stand,self.viewId,self.desktopType)
- item:addChild(mj)
- local size = item:getContentSize()
- mj:setPosition(cc.p(size.width/2,size.height/2))
-
- self.ui.Items.Layout_Operate_Content:addChild(item)
-
- mj:registerClick(function()
- self:sendOp({opType = v.opType,opCard = v.opCard,redNum = v.redNum})
- end)
-
- -- local col = k
- local row = math.ceil(k/count)
- -- logD(k.." :".. (k%count))
- -- local isChangeRow = k%count==0
-
- local x = self.ui.Items.Layout_Operate_Content:getContentSize().width-col*133
- local y = (row-1)*size.height
- item:setPositionX(x)
- item:setPositionY(y)
- col = col+1
- if k%count==0 then
- col = 0
- end
- end
- -- local count = table.nums(operates)
- -- local padding=10
- -- local width=self.ui.Items.Layout_OperateItem:getContentSize().width
- -- local height=self.ui.Items.Layout_OperateItem:getContentSize().height
-
- -- local layoutItem = cc.Layout:create()
- -- layoutItem:setBackGroundImageScale9Enabled(true)
- -- --layoutItem:setBackGroundImage("mj/res/ui/zy_fangjian/mj_gang_bg.png")
-
- -- layoutItem:setAnchorPoint(cc.p(0.5,1))
- -- self.ui.Items.Layout_OperateItem:addChild(layoutItem)
- -- if count <= 3 then
- -- layoutItem:setSize(cc.size(230*count+padding*count,height+padding))
- -- else
- -- layoutItem:setSize(cc.size(230*3+padding*3,height*(math.floor(count/3)+1)+(math.floor(count/3)+1)*padding))
- -- --self.ui.Items.Layout_OperateItem:setSize(cc.size(230*3+padding*3,height*(math.floor(count/3)+1)+(math.floor(count/3)+1)*padding))
- -- end
-
- -- layoutItem:setPosition(cc.p(width/2,height))
- -- local layoutHeight = layoutItem:getContentSize().height
- -- local y = 0
- -- for k,v in ipairs(operates) do
- -- local layout=cc.Layout:create()
- -- layout:setBackGroundImageScale9Enabled(true)
- -- layout:setBackGroundImage("mj/res/ui/zy_fangjian/mj_gang_bg.png")
- -- self.ui.Items.Layout_OperateItem:addChild(layout)
- -- layout:setSize(cc.size(230,height))
- -- layout:setAnchorPoint(cc.p(0,1))
- -- if k%3 == 1 then
- -- y = layoutHeight -15- height*(math.floor(k/3)+1)-10*(math.floor(k/3)+1)
- -- end
- -- if count < 3 then
- -- layout:setPosition(cc.p(-145+padding*(k-1)+230*(k-1),layoutHeight-15))
- -- elseif count == 3 then
- -- layout:setPosition(cc.p(-260+padding*(k-1)+230*(k-1),layoutHeight-15))
- -- else
- -- layout:setPosition(cc.p(-260+padding*(k%3-1)+230*(k%3-1),y))
- -- if k%3 == 0 then
- -- layout:setPosition(cc.p(-260+padding*2+230*2,y))
- -- end
- -- end
-
- -- for i=1,4 do
- -- local mj
- -- if v.redNum > 0 and i<=v.redNum then
- -- mj=MJ:new(65,MJDefine.MJType.Stand,self.viewId,self.desktopType)
- -- else
- -- mj=MJ:new(v.opCard,MJDefine.MJType.Stand,self.viewId,self.desktopType)
- -- end
- -- mj:setScale(0.6)
- -- layout:addChild(mj)
- -- local mjWidth = mj:getContentSize().width*0.6
- -- mj:setAnchorPoint(cc.p(0.5,0.5))
- -- mj:setPosition(32+3*(i-1)+mjWidth*(i-1),layout:getContentSize().height/2)
- -- end
-
- -- layout:registerClick(function ( sender )
- -- self:sendOp({opType = v.opType,opCard = v.opCard,redNum = v.redNum})
- -- end)
- -- end
-
- end
-
-
- function GuangAnHandCardView:hideOperateItem()
- if self.ui.Items.Layout_OperateItem then
- self.ui.Items.Layout_Operate_Content:removeAllChildren()
- self.ui.Items.Layout_OperateItem:setVisible(false)
- end
- end
-
-
- --显示操作
- function GuangAnHandCardView:showOperate(operates,card,isMyGetCard)
- if not operates or table.nums(operates)==0 then return end
- print(table.tostring(operates))
- local card = card or 0
-
- self:hideOperateItem()
- self:hideOperate()
-
- if operates and table.nums(operates) > 0 then
- self.ui.Items.Button_Sure:setVisible(false)
- end
-
- local newOperates = {}
- --有操作默认添加过的操作
- local operate=MJMessage.OperateRequest:new()
- operate.opType=MJDefine.MJOperateType.OPREATE_CANCEL
- operate.opCard=card
- operate.sortValue=0
- operate.redNum = 0
- --table.insert(operates.Datas,1,operate)
- table.insert(newOperates,1,operate)
-
- self.ui.Items.Layout_Operate:removeAllChildren()
- self.ui.Items.Layout_Operate:setVisible(true)
-
- local x=self.ui.Items.Layout_Operate:getContentSize().width
- local y=self.ui.Items.Layout_Operate:getContentSize().height/2
- self.btnPosX = x
-
- local gangCards ={} --所有杠組合
- local onceGang = false
- local onceTang = false
- local isCanHu = false
- --增加排序标签
- for k,v in pairs(operates.Datas) do
- if (v.opType == MJDefine.MJOperateType.OPREATE_DIANPAOHU) or (v.opType == MJDefine.MJOperateType.OPREATE_ZIMOHU) then
- v.sortValue = 4
- --v.Datas.sortValue = 1
- elseif (v.opType==MJDefine.MJOperateType.OPREATE_ZHIGANG) or (v.opType==MJDefine.MJOperateType.OPREATE_BAGANG) or (v.opType==MJDefine.MJOperateType.OPREATE_ANGANG) then
- v.sortValue = 3
- --v.Datas.sortValue = 2
- elseif (v.opType==MJDefine.MJOperateType.OPREATE_PENG) then
- v.sortValue = 2
- else--OPREATE_QIANG_GANG_HU
- v.sortValue = 1
- --v.Datas.sortValue = 3
- end
- end
- --operates.Datas包含所有碰杠组合,服务器不管是否贴鬼碰/杠,需客户端自己分离贴鬼碰和无贴鬼碰
- for k,v in pairs(operates.Datas) do
- if v.opType ~= MJDefine.MJOperateType.OPREATE_CANCEL then
- if MJDefine.isTieGui == true then --选择贴鬼碰/杠
- if (v.opType == MJDefine.MJOperateType.OPREATE_PLACE_CARD) or (v.opType == MJDefine.MJOperateType.OPREATE_DIANPAOHU) or (v.opType == MJDefine.MJOperateType.OPREATE_ZIMOHU) or onceGang == false then
- if (v.opType == MJDefine.MJOperateType.OPREATE_DIANPAOHU) or (v.opType == MJDefine.MJOperateType.OPREATE_ZIMOHU) then
- isCanHu = true
- --[[self:runAction(cc.Sequence:create(cc.DelayTime:create(1.5),cc.CallFunc:create(function()
- self:sendOp(v)--胡牌自动胡牌
- end)))--]]
-
- end
-
-
- table.insert(newOperates,v)
- end
-
- if (v.opType==MJDefine.MJOperateType.OPREATE_ZHIGANG) or (v.opType==MJDefine.MJOperateType.OPREATE_BAGANG) or (v.opType==MJDefine.MJOperateType.OPREATE_ANGANG) then
- --onceGang = true
- table.insert(gangCards,v)
- end
- else
- if (v.opType == MJDefine.MJOperateType.OPREATE_PLACE_CARD) or (v.opType == MJDefine.MJOperateType.OPREATE_DIANPAOHU) or (v.opType == MJDefine.MJOperateType.OPREATE_ZIMOHU) then
- isCanHu = true
- table.insert(newOperates,v)
- end
- --不勾选贴鬼碰/杠时,过滤掉带红中的碰杠
- if v.redNum == 0 and v.opType ~= MJDefine.MJOperateType.OPREATE_DIANPAOHU and (v.opType ~= MJDefine.MJOperateType.OPREATE_ZIMOHU) then
- if onceGang == false then
- table.insert(newOperates,v)
- end
- if (v.opType==MJDefine.MJOperateType.OPREATE_ZHIGANG) or (v.opType==MJDefine.MJOperateType.OPREATE_BAGANG) or (v.opType==MJDefine.MJOperateType.OPREATE_ANGANG) then
- --onceGang = true
- table.insert(gangCards,v)
- end
- end
-
- end
- end
- end
-
- if isCanHu and isCanHu == true then
- self:setOutCardEnable(false)
- end
- print(table.tostring(newOperates))
- if table.nums(newOperates) >= 2 then
- local function sortOperate(opA,opB)
- if opA.sortValue and opB.sortValue then
- if opA.sortValue<opB.sortValue then
- return true
- elseif opA.sortValue==opB.sortValue then
- if opA.opCard<opB.opCard then
- return true
- end
- end
- end
- return false
- end
- table.sort(newOperates,sortOperate)
- --没有碰杠操作,此条件只有不勾选贴鬼碰/杠才可能会执行
- else
-
- --[[--如果不是自己摸牌的情况下
- if not isMyGetCard then --app.room.roomInfo.outCardUserId~=app.room:getMyUserId() then --
- print("not isMyGetCard")
- self:sendOp({opType = MJDefine.MJOperateType.OPREATE_CANCEL,opCard=card,redNum=0})
- MJDefine.isSendGuo = true
- return;
- end
- --是自己摸牌
- self:hideOperate()
- self:setOutCardEnable(true)
-
- logD("GuangAnHandCardView:showOperate setOutCardEnable true")--]]
- end
-
- local pengCard = {}
- for k,v in pairs(newOperates) do
- if MJDefine.MJOperateImage[v.opType] then
- if(v.opType==MJDefine.MJOperateType.OPREATE_ZHIGANG) or (v.opType==MJDefine.MJOperateType.OPREATE_BAGANG) or (v.opType==MJDefine.MJOperateType.OPREATE_ANGANG) then
- self:addOperateBtn({v},isCanHu)
- elseif v.opType==MJDefine.MJOperateType.OPREATE_PENG then
- table.insert(pengCard,v)
- self:addOperateBtn(pengCard,isCanHu)
- elseif (v.opType~=MJDefine.MJOperateType.OPREATE_ZHIGANG) or (v.opType~=MJDefine.MJOperateType.OPREATE_BAGANG) or (v.opType~=MJDefine.MJOperateType.OPREATE_ANGANG) or (v.opType~=MJDefine.MJOperateType.OPREATE_PENG) then
- local btnOperate=cc.Button:createNode()
- btnOperate:setDefaults()
- btnOperate:setText("")
- btnOperate:loadTextureNormal(MJDefine.MJOperateImage[v.opType])
- btnOperate:ignoreAnchorPointForPosition(false)
- self.btnPosX = self.btnPosX-MJDefine.MJ_OPERATE_PADDING
- btnOperate:setPosition(cc.p(self.btnPosX, y))
- self.ui.Items.Layout_Operate:addChild(btnOperate)
-
- if isCanHu and isCanHu == true and v.opType == MJDefine.MJOperateType.OPREATE_CANCEL then
- local function qiHuConfirm()
- local content = string.format("确定放弃胡牌吗?")
- local okCallBack = function ()
- self:sendOp(v)
- end
- local cancelCallBack = function ()
-
- end
- showConfirmDialog(content,okCallBack,cancelCallBack)
- end
- btnOperate:registerClick(qiHuConfirm)
- else
- if v.opType == MJDefine.MJOperateType.OPREATE_PLACE_CARD then--摆牌
- btnOperate:registerClick(function()
- local handCards = {}
- self:tangCardEnabled(true)
- local function quxiaoCallback()
- if self.baopai and self.baopai == 1 then
- self:tangCardEnabled(true)
- self:setIsTanging(false)
- else
- self:tangCardEnabled(false)
- end
-
- self.ui.Items.Layout_Operate:setVisible(true)
- end
- if not self.tangView or tolua.isnull(self.tangView) then
- self.tangView = import("mj_guangan.luaScript.Views.Compnent.GuangAnTangView"):new(handCards,self.desktopType)
- self.tangView:setQuXiaoCallBack(quxiaoCallback)
- self.tangView:showCancelBtnOnly()
- --self.tangView:setPosition()
- self:addChild(self.tangView)
- else
- self.tangView:showCancelBtnOnly()
- end
- self.ui.Items.Layout_Operate:setVisible(false)
- end)
- else
- btnOperate:registerClick(function()
- -- playBtnEffect()
- self:sendOp(v)
-
- end)
- end
- end
- end
- end
- end
- end
-
- function GuangAnHandCardView:sendOp(value)
- local request = MJMessage.OperateRequest:new()
- request.opType = value.opType
- request.opCard = value.opCard
- request.redNum = value.redNum
- logE("GuangAnHandCardView:sendOp"..table.tostring(request))
- self.ui:sendMsg(app.room, MJDefine.MJEvent.Operate, request, function(status, response)
- logE("MJHandCardView showOperate() response = ", table.tostring(response))
- end)
- self:hideOperateItem()
- self:hideOperate()
-
- if value.opType == MJDefine.MJOperateType.OPREATE_CANCEL then
- app.room:dispatchEvent({name = MJDefine.MJEvent.SendGuo})
- end
- self:setTing(false)
- --app.room:resetTings()
- end
-
- --发送出牌消息
- function GuangAnHandCardView:sendOutCard()
- if not self.isOutCard or not self.touchMJ or self.touchMJ.value == 0 then return end
- self:hideOperate()
- -- if MJDefine.outCardSendGuo == true then
-
- -- self:sendOp({opType = MJDefine.MJOperateType.OPREATE_CANCEL,opCard=0,redNum=0})
-
- -- -- self:runDelay(0.1,function()
- -- GuangAnHandCardView.super.sendOutCard(self)
- -- -- end)
- -- else
- GuangAnHandCardView.super.sendOutCard(self)
- -- end
-
- app.room.roomInfo.lastOutViewId = MJDefine.MyViewId
- self:checkQueAndDisableOtherCard()
- end
-
- --插牌动画
- function GuangAnHandCardView:runInsertCardAction()
- self:resetHandCards()
- end
-
- --恢复麻将位置和透明度
- function GuangAnHandCardView:resetHandCardsPosAndOpacity()
- local initX,initY=self:getInitHandCardPostion()
-
- local x=initX
- local y=initY
- local insertX=0
- local insertY=0
-
- if MJDefine.isAutomatic == true then
- self:sortHandCards()
- else
- end
-
- for k,mj in pairs(self.handCards) do
- mj:setPosition(x,y)
- mj:setOpacity(255)
- x,y=MJPositionCompnent.getHandCardPosition(self.viewId,initX,initY,mj,k,self.desktopType)
- end
- return insertX,insertY
- end
-
- function GuangAnHandCardView:resetHandCards(insertMj,isAnimation)
- if self:isUseNew3D() then
- self._handcard:resetHandCards(insertMj,isAnimation)
- else
- -- local initX=self.initX
- -- local initY=self.initY
- local initX,initY=self:getInitHandCardPostion()
-
- local x=initX
- local y=initY
- local insertX=0
- local insertY=0
-
- if MJDefine.isAutomatic == true then
- self:sortHandCards()
- else
- -- self:sortRedMahjong()
- end
-
- for k,mj in pairs(self.handCards) do
- if mj.status ~= MJDefine.MJStatus.Disable then
- mj:setStatus(MJDefine.MJStatus.Normal)
- mj:stopAllActions()
- end
- logD("k:"..k.." value:"..mj.value)
- if insertMj==mj then --记录插入麻将的坐标 动画需要
- insertX=x
- insertY=y
- else
- if isAnimation then
- mj:runAction(cc.MoveTo:create(0.1,cc.p(x,y)))
- else
- mj:setPosition(x,y)
- end
- end
- x,y=MJPositionCompnent.getHandCardPosition(self.viewId,initX,initY,mj,k,self.desktopType)
- end
- return insertX,insertY
- end
- end
-
- function GuangAnHandCardView:moveRestHandCards(insertMj,isAnimation)
- local initX,initY=self:getInitHandCardPostion()
-
- local x=initX
- local y=initY
- local insertX=0
- local insertY=0
- for k,mj in pairs(self.handCards) do
- --如果可以出牌 最后的麻将不重置位置
- -- local isLastCard = self.isOutCard and k==#self.handCards
- -- if isLastCard then
- -- break
- -- end
-
- if mj.status ~= MJDefine.MJStatus.Disable then
- mj:setStatus(MJDefine.MJStatus.Normal)
- mj:stopAllActions()
- end
- logD("k:"..k.." value:"..mj.value)
- if insertMj==mj then --记录插入麻将的坐标 动画需要
- insertX=x
- insertY=y
- else
- if isAnimation then
- mj:runAction(cc.MoveTo:create(0.1,cc.p(x,y)))
- else
- mj:setPosition(x,y)
- end
- end
- x,y=MJPositionCompnent.getHandCardPosition(self.viewId,initX,initY,mj,k,self.desktopType)
- end
- return insertX,insertY
- end
-
- --[[function GuangAnHandCardView:onTouchEnd(touch)
- if MJDefine.isAutomatic == false then
- local touchPos=self:convertToNodeSpace(touch:getLocation())
- local newHandCards = {}
- for k,mj in pairs(self.handCards) do
- table.insert(newHandCards,k,mj)
- local width = mj:getContentSize().width
- local height = mj:getContentSize().height
- local x = mj:getPosition().x-width/2
- local y = mj:getPosition().y-height/2
- local rect = cc.Rectangle:new(x,y,width,height)
-
- if rect:contains(touchPos.x,touchPos.y) then
- if self.handCards[k] then
- table.remove(newHandCards,k)
- end
- if self.touchMJ and not tolua.isnull(self.touchMJ) then
- table.insert(newHandCards,k,self.touchMJ)
- end
- end
- end
- self.handCards = nil
- self.handCards = DeepCopy(newHandCards)
- end
- self:touchOutCard()
- end
- --]]
-
- function GuangAnHandCardView:buGang(card,newRedNum)
- newRedNum = newRedNum or 0
- if self:isUseNew3D() then
- self._handcard:buGang(card, newRedNum)
- else
- local oldGroup,oldRedNum=self:getGroup(card,MJDefine.MJOperateType.OPREATE_PENG)
- if not oldGroup then return end
- local fromViewId = oldGroup.fromViewId
- -- 杠牌对家,换成第四张
- if app.room:getMaxPlayerCount()==2 and fromViewId~=0 then
- fromViewId = 4
- end
- if app.room:getMaxPlayerCount()==4 and fromViewId == 2 then
- fromViewId = 4
- end
- local redNum = newRedNum + oldRedNum
- local newGroup=MJGroupFactory.CreateGroup({card,card,card,card},MJDefine.MJGroupType.Gang,self.viewId,self.desktopType,redNum)
- if newGroup.setAnColor then
- newGroup:setAnColor(card, fromViewId)
- end
- newGroup.fromViewId = fromViewId
- newGroup.opType=MJDefine.MJOperateType.OPREATE_BAGANG
- newGroup:setPosition(oldGroup:getPosition())
- if newGroup.mjs and newGroup.mjs[4] then
- newGroup.mjs[4]:setOutBlackImage(0,self.viewId)
- end
-
-
- self.ui.Items.Layout_Hand_Card:addChild(newGroup)
-
- local index=table.indexOf(self.handGroupCards,oldGroup)
- table.remove(self.handGroupCards,index)
- table.insert(self.handGroupCards,index,newGroup)
- oldGroup:removeFromParent()
- end
- end
-
- function GuangAnHandCardView:retoreBuGang(card,newRedNum)
- newRedNum = newRedNum or 0
- if self:isUseNew3D() then
- self._handcard:restoreBuGang(card, cardNum)
- else
- local oldGroup,oldRedNum=self:getGroup(card,MJDefine.MJOperateType.OPREATE_BAGANG)
- if not oldGroup then return end
- local fromViewId = oldGroup.fromViewId
- -- 杠牌对家,换成第四张
- if app.room:getMaxPlayerCount()==2 and fromViewId~=0 then
- fromViewId = 4
- end
- if app.room:getMaxPlayerCount()==4 and fromViewId == 2 then
- fromViewId = 4
- end
- --local redNum = newRedNum + oldRedNum
- local redNum = oldRedNum
- local newGroup=MJGroupFactory.CreateGroup({card,card,card},MJDefine.MJGroupType.Peng,self.viewId,self.desktopType,redNum)
- if newGroup.setAnColor then
- newGroup:setAnColor(card, fromViewId)
- end
- newGroup.fromViewId = fromViewId
- newGroup.opType=MJDefine.MJOperateType.OPREATE_PENG
- newGroup:setPosition(oldGroup:getPosition())
-
- self.ui.Items.Layout_Hand_Card:addChild(newGroup)
-
- local index=table.indexOf(self.handGroupCards,oldGroup)
- table.remove(self.handGroupCards,index)
- table.insert(self.handGroupCards,index,newGroup)
- oldGroup:removeFromParent()
- end
- end
-
- function GuangAnHandCardView:lockHandCard(isForbidTouch)
- if self:isUseNew3D() then
- self._handcard:lockHandCard(isForbidTouch)
- else
- for k,v in pairs(self.handCards) do
- v:setStatus(MJDefine.MJStatus.Disable)
- end
- self:getEventDispatcher():removeEventListenersForTarget(self)
- end
- end
-
- function GuangAnHandCardView:moveLastOpenCard()
- local count=#self.handCards
- if count>=2 then
- local frontMj=self.handCards[count-1]
- local lastMj=self.handCards[count]
-
- local margin=0
- local frontX=frontMj:getPositionX()
- local frontY=frontMj:getPositionY()
- local lastX=lastMj:getPositionX()
- local lastY=lastMj:getPositionY()
-
- local MJLastHandCardOffset=MJDefine.MJLastHandCardOffset[self.desktopType]
- local MJ_HAND_CARD_LEFT_PADDING_HEIGHT = MJDefine.MJ_HAND_CARD_LEFT_PADDING_HEIGHT[self.desktopType]
- --根据视图ID 计算坐标
- if self.viewId==MJDefine.PlayerViewType.My then
- margin=lastMj:getContentSize().width
- -- if math.abs(lastX-frontX)==margin then
- lastMj:setPositionX(lastX+MJLastHandCardOffset[self.viewId].x)
- -- end
- elseif self.viewId==MJDefine.PlayerViewType.Left then
- margin=MJ_HAND_CARD_LEFT_PADDING_HEIGHT
- -- if math.abs(lastY-frontY)==margin then
- lastMj:setPositionX(lastX+MJLastHandCardOffset[self.viewId].x)
- lastMj:setPositionY(lastY+MJLastHandCardOffset[self.viewId].y)
- -- end
- elseif self.viewId==MJDefine.PlayerViewType.Right then
- margin=MJ_HAND_CARD_LEFT_PADDING_HEIGHT
- -- if math.abs(lastY-frontY)==margin then
- lastMj:setPositionX(lastX+MJLastHandCardOffset[self.viewId].x)
- lastMj:setPositionY(lastY+MJLastHandCardOffset[self.viewId].y)
- -- end
- elseif self.viewId==MJDefine.PlayerViewType.Top then
- margin=lastMj:getContentSize().width-MJDefine.MJ_HAND_CARD_TOP_OFFSET_X
- -- print("width:"..lastMj:getContentSize().width)
- -- if math.abs(lastX-frontX)==margin then
- lastMj:setPositionX(lastX+MJLastHandCardOffset[self.viewId].x)
- -- end
- end
-
-
- end
- end
-
- function GuangAnHandCardView:onTouchMove(touch)
- GuangAnHandCardView.super.onTouchMove(self,touch)
- -- 2021/4/23 2D风格的 金黄、金黄大不能挪动位置 ljx
- -- if self.touchMJ and self.isTouchMove==true then
- -- local pos = self.touchMJ:getPosition()
- -- local index = nil
- -- for k,v in pairs(self.handCards) do
-
- -- local width = v:getContentSize().width
- -- local height = v:getContentSize().height
- -- local x = v:getPosition().x-width/2
- -- local y = v:getPosition().y-height/2
- -- local rect = cc.Rectangle:new(x,y,width*0.8,height*0.8)
-
- -- --如果可以出牌 最后的麻将不参与移动操作
- -- -- local isLastCard = self.isOutCard and k==#self.handCards
-
- -- if rect:contains(pos.x,pos.y) and v ~=self.touchMJ and not isLastCard then
- -- index = k
- -- break
- -- end
- -- end
- -- if index then
- -- local touchMJIndex = table.indexOf(self.handCards,self.touchMJ)
- -- local offsetIndex = touchMJIndex-index
- -- local num = math.abs(offsetIndex)-1
- -- --大于0则往左移动 3-1:3-2 2-1 小于0右 5-8:5-6 6-7 7-8
- -- local reduce = offsetIndex>0 and -1 or 1
- -- for i = touchMJIndex,index-reduce,reduce do
- -- self.handCards[i],self.handCards[i+reduce] = self.handCards[i+reduce],self.handCards[i]
- -- end
- -- local x,y = self:moveRestHandCards(self.touchMJ)
- -- self.touchMJ:recordPostion(cc.p(x,y))
- -- end
- -- end
- end
-
- function GuangAnHandCardView:touchOutCard()
- if self.touchMJ and self.isTouchMove then
- if self.touchMJ:getPositionY()>MJDefine.MJ_TOUCH_OUT_CARD_Y and self.isOutCard then
- self:sendOutCard()
- else
- self.touchMJ:restorePostion()
- self.touchMJ:setStatus(MJDefine.MJStatus.Normal)
- app.room:dispatchEvent({name = MJDefine.MJEvent.SelectCard})
- app.room:dispatchEvent({name = MJDefine.MJEvent.ShowTing})
- if self.isOutCard then
- self:moveLastCard()
- end
- end
- end
-
- self.isTouchMove=false
- end
-
- function GuangAnHandCardView:outCardFalg(event)
- if event.viewId == MJDefine.MyViewId then
- self:hideOperateItem()
- self:hideOperate()
- end
- if self:isUseNew3D() then
- self._outCardView:outCardFalg(event)
- else
- for k,v in pairs(self.outCards) do
- v:stopAllActions()
- v:setStatus(MJDefine.MJStatus.Normal)
- for i,child in pairs(v:getChildren()) do
- local tag = child:getTag()
- if tag ~= MJ.MJ_HAND_CARD_FLAG_LAIZI then
- child:removeFromParent()
- end
- end
- end
-
-
- local mj=self.outCards[#self.outCards]
- if event.value and mj and mj.value == event.value and event.viewId==self.viewId then
- --[[ local flag = cc.Sprite:create()
- flag:setTexture("mj_guangan/res/zy_fangjian/guangan_pointer.png");
- -- flag:setScale(0.8)
- mj:addChild(flag)
- flag:setPosition(mj:getContentSize().width/2,mj:getContentSize().height)
- local moveBy=cc.MoveBy:create(0.5,cc.p(0, 30))
- flag:runAction(cc.RepeatForever:create(cc.Sequence:create(moveBy,moveBy:reverse())))--]]
- local acTintto = cc.TintTo:create(1.2,141,144,242)
- local acTintto1 = cc.TintTo:create(1.2,255, 255, 255)
- mj:runAction(cc.RepeatForever:create(cc.Sequence:create(acTintto,acTintto1)))
- end
-
- end
- end
-
- function GuangAnHandCardView:getHandCardNodes()
- if self:isUseNew3D() then
- return self._handcard:getHandCardNodes()
- else
- return self.handCards
- end
- end
-
- function GuangAnHandCardView:isUseNew3D()
- return (self.desktopType == MJDefine.DesktopType.ThreeD or self.desktopType == MJDefine.DesktopType.TwoD) and MJDefine.IS_NEW_3D
- end
-
- --躺成功了
- function GuangAnHandCardView:setTangSuccess(is)
- GuangAnHandCardView.super.setTangSuccess(self,is)
- if self.tangView and (not tolua.isnull(self.tangView)) then
- self.tangView:removeFromParent()
- self.tangView = nil
- end
- self.isTangCard = is
- end
-
- function GuangAnHandCardView:showTangView(event)
- if self.tangView and (not tolua.isnull(self.tangView)) then
- local handCards = {}
- for k,v in pairs(self:getHandCardNodes() or {}) do
- table.insert(handCards,{card = v.value or v:getValue()})
- end
- --[[for i,v in pairs(handCards) do
- if v.card == event.card then
- table.remove(handCards,i)
- break
- end
- end--]]
- self.tangView:showTangView(handCards,event.card,self.desktopType)
- end
- end
-
- function MJHandCardView:createOutCards(arg)
- if self:isUseNew3D() then
- self._outCardView:createOutCards(arg)
- else
- if type(arg)=="number" then
- arg={
- {card=arg}
- }
- end
-
- for k,v in pairs(arg) do
- print("测试:"..v.card)
- local mj=MJ:new(v.card,MJDefine.MJType.Out,self.viewId,self.desktopType)
- self.ui.Items.Layout_Hand_Card:addChild(mj)
- table.insert(self.outCards,mj)
-
- local x,y=MJPositionCompnent.getOutCardPosition(self.viewId,self.outX,self.outY,mj,#self.outCards,self.desktopType,app.room:getMaxPlayerCount())
- mj:setPosition(x,y)
- end
- end
- end
-
- --玩家出牌
- function GuangAnHandCardView:onOutCard(card,callback)
- if self:isUseNew3D() then
- self._handcard:onOutCard(card, callback)
- self._outCardView:onOutCard(card, callback)
- else
- self:runOutCardAction(card)
- if callback then
- callback()
- end
-
- if self.viewId~=MJDefine.MyViewId then --其他玩家删除最后一个牌
- local mj=self:getMjByValue(card)
- if mj then
- self:removeHandCard(card)
- self:resetHandCards()
- -- mj:removeFromParent()
- else
- local last=#self.handCards
- if last and self.handCards[last] then
- self.handCards[last]:removeFromParent()
- table.remove(self.handCards,last)
- end
- end
- else
- -- self:runOutCardAction(self.touchMJ.value)
- -- app.room:dispatchEvent({name = MJDefine.MJEvent.OutCardFalg,value=self.touchMJ.value,viewId=self.viewId})
- self:setOutCardEnable(false)
-
- local mj=self:getMjByValueReverseOrder(card)
- --插牌
- if mj==self.handCards[#self.handCards] then
- table.removeItem(self.handCards,mj)
- self:resetHandCards()
- else
- table.removeItem(self.handCards,mj)
- --self:runInsertCardAction()
- self:resetHandCards()
- end
-
- -- self:removeHandCard(card)
- -- self:resetHandCards()
- if mj then
- mj:removeFromParent()
- mj=nil
- end
- end
-
- -- local memberInfo=app.room.roomInfo.memberList[data.response.nUserId]
- local userInfo=app.room:getUserInfoByViewId(self.viewId)
- if userInfo and (self.viewId~=MJDefine.MyViewId or self.isReplay) then
- MJSound.PlayMJSound(userInfo.sex,card)
- end
- end
- end
-
- --出牌动画
- function GuangAnHandCardView:runOutCardAction(value,callback)
- MJSound.PlayOutCard()
- self:createOutCards(value)
- local outCard=self.outCards[#self.outCards]
-
- --[[ local showCard=MJ:new(value,MJDefine.MJType.Stand,MJDefine.MyViewId,self.desktopType)
- self:addChild(showCard)--]]
- --[[ if self.viewId==MJDefine.MyViewId then
- outCard:setVisible(false)
-
- local mj=nil
- if self.touchMJ and not tolua.isnull(self.touchMJ) then
- mj = self.touchMJ
- else
- mj = self:getMjByValueReverseOrder(value)
- end
- if mj and (not tolua.isnull(mj)) then
- showCard:setPosition(mj:getPosition())
- end
- local actions={
- cc.MoveTo:create(MJDefine.MJ_TIME_OUT_CARD,outCard:getPosition()),
- cc.CallFunc:create(function()
- -- MJSound.PlayOutCard()
- if outCard and not tolua.isnull(outCard) then
- outCard:setVisible(true)
- end
- if callback then callback() end
- end),
- cc.RemoveSelf:create(),
- }
- showCard:runAction(cc.Sequence:create(actions))
-
- else
- showCard:setScale(MJDefine.MJ_OUT_CARD_SCALE)
- showCard:setPosition(self.showCardPostion)
- local rotate=0
- if self.viewId==MJDefine.PlayerViewType.Left then
- rotate=-45
- elseif self.viewId==MJDefine.PlayerViewType.Right then
- rotate=45
- end
- local actions={
- cc.ScaleTo:create(MJDefine.MJ_TIME_OUT_CARD_SCALE,1),
- cc.DelayTime:create(MJDefine.MJ_TIME_OUT_CARD_WAIT),
- cc.Spawn:create(
- cc.Spawn:create(
- cc.MoveTo:create(MJDefine.MJ_TIME_OUT_CARD,outCard:getPosition()),
- cc.ScaleTo:create(MJDefine.MJ_TIME_OUT_CARD,MJDefine.MJ_OUT_CARD_SCALE)
- ),
- cc.RotateBy:create(MJDefine.MJ_TIME_OUT_CARD,rotate)
- ),
- cc.CallFunc:create(function()
- -- MJSound.PlayOutCard()
- if outCard and not tolua.isnull(outCard) then
- outCard:setVisible(true)
- end
- if callback then callback() end
- end),
- cc.RemoveSelf:create(),
-
- }
- showCard:runAction(cc.Sequence:create(actions))
- -- showCard:runAction(cc.ScaleTo:create(MJDefine.MJ_TIME_OUT_CARD,MJDefine.MJ_TOP_SCALE))
- end--]]
-
- local showCardBg = cc.ImageView:createNode()
- showCardBg:loadTexture("mj_guangan/res/zy_fangjian/guanan_outCard_bg.png")
- showCardBg:setAutoSize(true)
- showCardBg:setScale9Enabled(true)
- showCardBg:setSize(cc.size(140,170))
- showCardBg:setLocalZOrder(9999)
- self:addChild(showCardBg)
-
-
- local showCard=MJ:new(value,MJDefine.MJType.Stand,MJDefine.MyViewId,self.desktopType)
- --local showCard=MJ:new(value,MJDefine.MJType.Stand,MJDefine.MyViewId,self.desktopType)
- showCardBg:addChild(showCard)
- showCard:setScale(1.2)
- showCard:setLocalZOrder(9999)
- local showsize = showCardBg:getContentSize()
- showCard:setPosition(cc.p(showsize.width/2,showsize.height/2))
-
-
- --showCard:setScale(MJDefine.MJ_OUT_CARD_SCALE)
- showCardPostion = {
- [1] = {x = 1015*g_radio_x, y = 423*g_radio_y},
- [2] = {x = 641*g_radio_x, y = 571*g_radio_y},
- [3] = {x = 265*g_radio_x, y = 423*g_radio_y},
- [4] = {x = 640*g_radio_x, y = 210*g_radio_y},
- }
- showCardBg:setPosition(showCardPostion[self.viewId])
- local rotate=0
- if self.viewId==MJDefine.PlayerViewType.Left then
- rotate=-45
- elseif self.viewId==MJDefine.PlayerViewType.Right then
- rotate=45
- end
- local actions={
- --cc.ScaleTo:create(MJDefine.MJ_TIME_OUT_CARD_SCALE,1),
- cc.DelayTime:create(MJDefine.MJ_TIME_OUT_CARD_WAIT),
- --[[cc.Spawn:create(
- cc.Spawn:create(
- cc.MoveTo:create(MJDefine.MJ_TIME_OUT_CARD,outCard:getPosition()),
- cc.ScaleTo:create(MJDefine.MJ_TIME_OUT_CARD,MJDefine.MJ_OUT_CARD_SCALE)
- ),
- cc.RotateBy:create(MJDefine.MJ_TIME_OUT_CARD,rotate)
- ),--]]
- cc.CallFunc:create(function()
- -- MJSound.PlayOutCard()
- if outCard and not tolua.isnull(outCard) then
- --outCard:setVisible(true)
- end
- showCard:setVisible(false)
- if callback then callback() end
- end),
- cc.RemoveSelf:create(),
-
- }
- showCardBg:runAction(cc.Sequence:create(actions))
-
- -- showCard:runAction()
- end
-
- --设置定缺类型 0万,1同,2条
- function GuangAnHandCardView:setQueType(que)
- if self:isUseNew3D() then
- self._handcard:setQueType(que)
- else
- self.queType = que
- --设置完定缺牌后,重新设置一下麻将的排序值,目标为了把定缺牌放到右边
- self:resetCardsSortValue()
- end
- end
-
- function GuangAnHandCardView:resetCardsSortValue()
- for k,v in pairs(self.handCards) do
- if v:getMJColorType() == self.queType then
- v.sortValue = v.value + 100
- end
- end
- end
-
- function GuangAnHandCardView:selectCard(event)
- --if not self.touchMJ then return end
- if event.value then
- for k,v in pairs(self.outCards) do
- if not tolua.isnull(v) then
- if v.value==event.value then
- v:setStatus(MJDefine.MJStatus.Select,true)
- else
- v:setStatus(MJDefine.MJStatus.Normal)
- end
- end
- end
- else
- --self:setTing(false)
- for k,v in pairs(self.outCards) do
- if v.status~=MJDefine.MJStatus.Disable and (not tolua.isnull(v)) then
- v:setStatus(MJDefine.MJStatus.Normal)
- end
- end
- end
- -- app.room:dispatchEvent({name = "showProp",response = response});
- end
-
-
- --判断是否符合换三张规则
- function GuangAnHandCardView:checkIsInSwapRule()
- if self:isUseNew3D() then
- return self._handcard:checkIsInSwapRule()
- else
- local selectNums = #self._selectCards
- if selectNums ~= 3 then
- return false
- end
-
- local gameInfo = json.decode(app.room.roomInfo.strGameInfo)
- local specialRule = gameInfo.specRule
- local isNotHuanZFB = false
- if getNumBand(specialRule, 0x0002)>0 then
- isNotHuanZFB = true
- end
- local huase = self._selectCards[1]:getMJColorType()
- for i,v in pairs(self._selectCards) do
- local tHuase = v:getMJColorType()
- if tHuase ~= huase or (isNotHuanZFB and tHuase == 4) then
- return false
- end
- end
- return true
- end
- end
-
- return GuangAnHandCardView
|