|
- local ZPDef = ZPFramework.ZPImport("zp_base.luaScript.ZPDef")
- local ZPFuc = ZPFramework.ZPImport("zp_base.luaScript.ZPFunctions")
- local ZPSound = ZPFramework.ZPImport("zp_base.luaScript.ZPSound")
- local ZPMessage = ZPFramework.ZPImport("zp_base.luaScript.Protocol.ZPMessage")
-
- local ZPRoomOperationView = ZPFramework.ZPFrameworkClassImprot("zp_base.luaScript.Views.Room.ZPRoomOperationView")
- local hejiangRoomOperationView = class("hejiangRoomOperationView", ZPRoomOperationView)
-
- function hejiangRoomOperationView:ctor( ... )
- hejiangRoomOperationView.super.ctor(self)
- end
-
- function hejiangRoomOperationView:onEnter()
- hejiangRoomOperationView.super.onEnter(self)
- end
-
- function hejiangRoomOperationView:onEnter()
- ZPRoomOperationView.super.onEnter(self)
- local ui = loadUI("zp_hejiang/res/ui/ui_fangjian/hejiang_ui_operation.ui");
- self.ui = ui;
- self:addChild(ui);
-
- self.eatViewSrcSize = self.ui.Items.ImageView_EatPanelBg:getContentSize()
- self.eatBiViewSrcSize = self.ui.Items.ImageView_EatPanelBg_Bi:getContentSize()
- self.eatSanBiViewSrcSize = self.ui.Items.ImageView_EatPanelBg_SanBi:getContentSize()
-
- --ui排序:吃碰胡过
- self.ui.Items.Button_1:registerClick(nil,function ()
- local function chi()
- local code = self.operationLocalCode
- self:touchEatOneCardCallBack(false)
- end
- local isHu = self:getIsHaveHuOp()
- if isHu == true then
- local content = string.format("确定放弃胡牌吗?")
- local okCallBack = function ()
- chi()
- end
- local cancelCallBack = function ()
-
- end
- showConfirmDialog(content,okCallBack,cancelCallBack)
- else
- chi()
- end
- end)
-
- self.ui.Items.Button_2:registerClick(function ()
- local function peng()
- local operateCode = {}
- operateCode[1] = ZPDef.OpCode.OP_PENG
- self:sendOperationCode(operateCode)
- --直接隐藏界面
- self:setOperatorPanelView(false)
- end
- local isHu = self:getIsHaveHuOp()
- if isHu == true then
- local content = string.format("确定放弃胡牌吗?")
- local okCallBack = function ()
- peng()
- end
- local cancelCallBack = function ()
-
- end
- showConfirmDialog(content,okCallBack,cancelCallBack)
- else
- peng()
- end
- end)
-
- self.ui.Items.Button_7:registerClick(function ()
- local function peng()
- local operateCode = {}
- operateCode[1] = ZPDef.OpCode.OP_PAO
- self:sendOperationCode(operateCode)
- --直接隐藏界面
- self:setOperatorPanelView(false)
- end
- local isHu = self:getIsHaveHuOp()
- if isHu == true then
- local content = "确定放弃胡牌吗?"
- local okCallBack = function ()
- peng()
- end
- local cancelCallBack = function ()
-
- end
- showConfirmDialog(content,okCallBack,cancelCallBack)
- else
- peng()
- end
- end)
- --self:hidePengBtn()
-
- self.ui.Items.Button_3:registerClick(function ()
- if app.room:isLittleFamily() then return end
- local isHu = self:getIsHaveHuOp()
- if isHu == true then
- local content = "确定放弃胡牌吗?"
- local okCallBack = function ()
- self:onClickGuo()
- end
- local cancelCallBack = function ()
-
- end
- showConfirmDialog(content,okCallBack,cancelCallBack)
- else
- self:onClickGuo()
- end
- end)
-
- self.ui.Items.Button_4:registerClick(function ()
- local operateCode = {}
- operateCode[1] = ZPDef.OpCode.OP_HU
- self:sendOperationCode(operateCode)
- self:setOperatorPanelView(false)
- end)
-
- --不爆牌
- self.ui.Items.Button_6:registerClick(function ()
- if app.room:isLittleFamily() then return end
- local request = ZPMessage.BaoPai:new()
- request.optType = 0
- logE("ZPRoomOperationView:baopai"..table.tostring(request))
- self.ui:sendMsg(app.room, "BaoPai", request, function(status, response)
- logE("ZPRoomOperationView baopai response = ", table.tostring(response))
- end)
- self:showBaoPaiOpView(false)
- end)
-
- --爆牌
- self.ui.Items.Button_5:registerClick(function ()
- if app.room:isLittleFamily() then return end
- local request = ZPMessage.BaoPai:new()
- request.optType = 1
- logE("ZPRoomOperationView:baopai"..table.tostring(request))
- self.ui:sendMsg(app.room, "BaoPai", request, function(status, response)
- logE("ZPRoomOperationView baopai response = ", table.tostring(response))
- end)
- self:showBaoPaiOpView(false)
- end)
-
-
-
- self:hideSelf()
- end
-
- function hejiangRoomOperationView:showOpeation(mainOpCode,viewId,card)
- if app.room:isLittleFamily() then return end
- --操作码
- self.operationLocalCode = mainOpCode
- logE("RoomView:showOpeation(mainOpCode) 1:"..mainOpCode)
- --操作类型
- local beginList = {}
-
- beginList = ZPFuc.getZPOperationType(mainOpCode,true)--,self.playerZhao[1] > 0
- logE("RoomView:showOpeation isCheckMustOperation before (beginList)1 :"..table.tostring(beginList))
-
- --胡牌优先规则
- local isHu = false
- for k,opType in pairs(beginList) do
- if opType == ZPDef.OpType.OP_TYPE_HU then
- isHu = true
- break
- end
- end
-
- --发送操作
- if not isHu then
- --自动操作判断
- for k,opType in ipairs(beginList) do
- if opType == ZPDef.OpType.OP_TYPE_MINGWEI then
- local operateCode = {}
- operateCode[1] = ZPDef.OpCode.OP_MING_SHAO
- self:sendOperationCode(operateCode)
- --直接隐藏界面
- self:setOperatorPanelView(false)
- return
- elseif opType == ZPDef.OpType.OP_TYPE_ANWEI then
- local operateCode = {}
- operateCode[1] = ZPDef.OpCode.OP_AN_SHAO
- self:sendOperationCode(operateCode)
- --直接隐藏界面
- self:setOperatorPanelView(false)
- return
- elseif opType == ZPDef.OpType.OP_TYPE_PAO then
- local operateCode = {}
- operateCode[1] = ZPDef.OpCode.OP_PAO
- self:sendOperationCode(operateCode)
- --直接隐藏界面
- self:setOperatorPanelView(false)
- return
- elseif opType == ZPDef.OpType.OP_TYPE_CHONG_PAO then
- local operateCode = {}
- operateCode[1] = ZPDef.OpCode.OP_PAO
- self:sendOperationCode(operateCode)
- --直接隐藏界面
- self:setOperatorPanelView(false)
- return
- elseif opType == ZPDef.OpType.OP_TYPE_TI then
- local operateCode = {}
- operateCode[1] = ZPDef.OpCode.OP_TI
- self:sendOperationCode(operateCode)
- --直接隐藏界面
- self:setOperatorPanelView(false)
- return
- elseif opType == ZPDef.OpType.OP_TYPE_PENG then
- local operateCode = {}
- operateCode[1] = ZPDef.OpCode.OP_PENG
- self:sendOperationCode(operateCode)
- --直接隐藏界面
- self:setOperatorPanelView(false)
- return
- end
- end
- else
- --是否必须操作
- local isCheckMustOperation = false
- for k,v in pairs(beginList) do
- if v == ZPDef.OpType.OP_TYPE_PENG or v == ZPDef.OpType.OP_TYPE_MINGWEI or v == ZPDef.OpType.OP_TYPE_ANWEI
- or v == ZPDef.OpType.OP_TYPE_TI or v == ZPDef.OpType.OP_TYPE_PAO
- or v == ZPDef.OpType.OP_TYPE_CHONG_PAO then
- isCheckMustOperation = true
- break
- end
- end
- if isCheckMustOperation then
- --获取操作类型
- beginList = ZPFuc.getZPOperationType(mainOpCode,false)
- end
- --[[local operateCode = {}
- operateCode[1] = ZPDef.OpCode.OP_HU
- self:sendOperationCode(operateCode)
- return--]]
- --self:setHuPanelView(true,beginList)
- --return
- end
-
- --如果没有胡,扫,提,跑,等自动操作,则显示吃碰过操作
- self:setOperatorPanelView(true,beginList)
- end
-
- --隐藏行为操作层
- function hejiangRoomOperationView:setOperatorPanelView(bVisible,operations)
- self:setVisible(bVisible)
- self.ui.Items.Layout_operatorPanel:setVisible(bVisible)
-
- --置灰所有 ui排序:吃碰过
- for i = 1 ,7 do
- local name = string.format("Layout_%d",i)
- if self.ui.Items[name] then
- self.ui.Items[name]:setVisible(false)
- end
- end
-
-
- --显示操作序列
- if operations then
- for k,v in pairs(operations) do
- local name = string.format("Button_%d",v)
- local layout = string.format("Layout_%d",v)
- if self.ui.Items[name] then
- self.ui.Items[name]:setEnabled(true)
- self.ui.Items[layout]:setVisible(true)
- end
- end
- end
-
- self.ui.Items.Layout_operatorPanel:requestDoLayout();
- self.ui.Items.Layout_operatorPanel:doLayout();
- end
-
- return hejiangRoomOperationView
|