diff --git a/lua_probject/base_project/Game/View/MainView.lua b/lua_probject/base_project/Game/View/MainView.lua index 8c5cf628..d173ed16 100644 --- a/lua_probject/base_project/Game/View/MainView.lua +++ b/lua_probject/base_project/Game/View/MainView.lua @@ -10,7 +10,7 @@ local FGAssistView = import('.FGAssistView') MainView = {} -- 继承 BaseView -setmetatable(MainView, {__index = BaseView}) +setmetatable(MainView, { __index = BaseView }) local M = MainView @@ -18,49 +18,48 @@ local M = MainView local record_baned = 0 function M:init() - TimerManager.Clear() + TimerManager.Clear() self._gamectr = ControllerManager.GetController(GameController) self._room = DataManager.CurrenRoom self._allow_dissmiss = true -- 游戏开始后显示解散房间按钮 - self._multilingual = false -- 游戏支持多语言切换 - self._language = 0 -- 语言默认0,1可以设为需要的方言 - self._style = 1 -- 游戏风格 - self._hide_assist = false -- 是否隐藏牌友圈助手 + self._multilingual = false -- 游戏支持多语言切换 + self._language = 0 -- 语言默认0,1可以设为需要的方言 + self._style = 1 -- 游戏风格 + self._hide_assist = false -- 是否隐藏牌友圈助手 self._gps_style = 1 self.dismiss_cd = 0 UIPackage.AddPackage('base/chat/ui/Chat') self.Fix_Msg_Chat = ViewUtil.Fix_Msg_Chat -- 自动回复消息列表 - self.Fix_Msg_Chat2 = nil -- 自动回复列表2 + self.Fix_Msg_Chat2 = nil -- 自动回复列表2 self:InitView() - self:SetTuoGuanState() + self:SetTuoGuanState() end function M:SetTuoGuanState() - --printlog("初始化设置托管状态") - if ControllerManager.enterPlayerData and #ControllerManager.enterPlayerData>0 then - --pt(ControllerManager.enterPlayerData) - for i=1,#ControllerManager.enterPlayerData do - local p =self._player_info[self:GetPos(ControllerManager.enterPlayerData[i].seat)] - --p.seat=ControllerManager.enterPlayerData[i].seat - local t=ControllerManager.enterPlayerData[i].entrust_time - --local isShow=ControllerManager.enterPlayerData[i].entrust - --if isShow==nil then return end - - if t and t>0 then - p:IsShowTGTips(true,t) - else - - end - - end - ControllerManager.enterPlayerData=nil - end + --printlog("初始化设置托管状态") + if ControllerManager.enterPlayerData and #ControllerManager.enterPlayerData > 0 then + --pt(ControllerManager.enterPlayerData) + for i = 1, #ControllerManager.enterPlayerData do + local p = self._player_info[self:GetPos(ControllerManager.enterPlayerData[i].seat)] + --p.seat=ControllerManager.enterPlayerData[i].seat + local t = ControllerManager.enterPlayerData[i].entrust_time + --local isShow=ControllerManager.enterPlayerData[i].entrust + --if isShow==nil then return end + + if t and t > 0 then + p:IsShowTGTips(true, t) + else + + end + end + ControllerManager.enterPlayerData = nil + end end function M:InitView(url, isHideIpAdds) - --print("url===>>>") - --print(url) - --print(debug.traceback()) + --print("url===>>>") + --print(url) + --print(debug.traceback()) BaseView.InitView(self, url) -- @@ -78,7 +77,7 @@ function M:InitView(url, isHideIpAdds) self._gcm_chat = self._view:GetChild('gcm_chat') if self._gcm_chat then - if self._room.ban_chat2 then + if self._room.ban_chat2 then self._gcm_chat:GetController('sdk').selectedIndex = 1 self._gcm_chat.visible = false end @@ -90,7 +89,7 @@ function M:InitView(url, isHideIpAdds) local _view = self._view local _room = self._room self._state = _view:GetController('state') - self._ctr_action = _view:GetController("action") + self._ctr_action = _view:GetController("action") self:InitPlayerInfoView(isHideIpAdds) @@ -111,7 +110,7 @@ function M:InitView(url, isHideIpAdds) -- 显示玩家距离 self.btn_distance = self._view:GetChild('btn_distance') - --self.btn_distance.displayObject.gameObject:SetActive(false) + --self.btn_distance.displayObject.gameObject:SetActive(false) if self.btn_distance then self.btn_distance.onClick:Add(function() if self._room.self_player.seat == 0 then @@ -120,7 +119,8 @@ function M:InitView(url, isHideIpAdds) self.distance_view = PlayerDistanceView.new(false, self._gps_style, function(v) self:continue_game(v) end) - self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and self._state.selectedIndex < 3 and 1 or 0 + self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and + self._state.selectedIndex < 3 and 1 or 0 self.distance_view:Show() end) end @@ -149,7 +149,7 @@ function M:InitView(url, isHideIpAdds) str_des = string.format('%s %s', str_des, _room.room_config:GetDes()) com_roominfo:GetChild('tex_detail').text = str_des local tex_time = com_roominfo:GetChild('tex_time') - self._co_timer =coroutine.start(function() + self._co_timer = coroutine.start(function() while true do tex_time.text = os.date('%m-%d %H:%M') local _client = ControllerManager.GameNetClinet @@ -189,7 +189,7 @@ function M:InitView(url, isHideIpAdds) -- 语音Stard local gcm_chat = _view:GetChild('gcm_chat') - --gcm_chat.displayObject.gameObject:SetActive(false) + --gcm_chat.displayObject.gameObject:SetActive(false) if gcm_chat then gcm_chat.visible = false local _btn_chat = gcm_chat:GetChild('n1') @@ -208,7 +208,7 @@ function M:InitView(url, isHideIpAdds) self._ctr_voice = gcm_chat:GetController('voice') self._btn_record = gcm_chat:GetChild('btn_record') - self._btn_record.displayObject.gameObject:SetActive(false) + self._btn_record.displayObject.gameObject:SetActive(false) self.ctr_record_ban = self._btn_record:GetController('ban') self.ctr_record_ban.selectedIndex = record_baned self._record_time = 0 @@ -231,19 +231,19 @@ function M:InitView(url, isHideIpAdds) btn_ready.onClick:Set(function() self._gamectr:PlayerReady() end) - - local btn_xipai = _view:GetChild('btn_xipai') - if btn_xipai then - btn_xipai.onClick:Set(function() - self._gamectr:PlayerXiPai() - end) - end - - local btn_start = _view:GetChild('btn_start') - btn_start.onClick:Set(function() - self._gamectr:StartGame() - end) + -- local btn_xipai = _view:GetChild('btn_xipai') + -- if btn_xipai then + -- btn_xipai.onClick:Set(function() + -- self._gamectr:PlayerXiPai() + -- end) + -- end + + + -- local btn_start = _view:GetChild('btn_start') + -- btn_start.onClick:Set(function() + -- self._gamectr:StartGame() + -- end) local _btn_wxyqhy = _view:GetChild('btn_wxyqhy') if _btn_wxyqhy then @@ -255,7 +255,7 @@ function M:InitView(url, isHideIpAdds) self._left_time = 0 self.dismiss_room_cd_time = 0 local btn_back_exit = _view:GetChild('btn_back_exit') - --btn_back_exit.displayObject.gameObject:SetActive(false) + --btn_back_exit.displayObject.gameObject:SetActive(false) if btn_back_exit ~= nil then btn_back_exit.onClick:Set( function() @@ -291,42 +291,42 @@ function M:InitView(url, isHideIpAdds) end ) end - local btn_back_lobby = _view:GetChild('btn_back_lobby') + local btn_back_lobby = _view:GetChild('btn_back_lobby') if btn_back_lobby ~= nil then - btn_back_lobby.onClick:Set( + btn_back_lobby.onClick:Set( function() local tip_owner = '您是否退出房间?\n(退出房间后房间将解散)' - local tip = '您是否退出房间?' -- \n (请注意,申请洗牌后退出,不会返还洗牌分) - local tipStr = '' - if self._room.agent then - tipStr = '您是否退出房间?' - else - tipStr = self._room.owner_id == self._room.self_player.self_user.account_id and tip_owner or tip - end - local _curren_msg = MsgWindow.new(self._root_view, tipStr, MsgWindow.MsgMode.OkAndCancel) - _curren_msg.onOk:Add( - function() - if self._state.selectedIndex > 0 and self._state.selectedIndex < 3 then - ViewUtil.ErrorTip(nil, '房间已开始,无法退出游戏。') - else - ViewUtil.ShowModalWait(self._root_view) - self._gamectr:LevelRoom( - function(res) - ViewUtil.CloseModalWait() - if res.ReturnCode == 0 then - ViewManager.ChangeView(ViewManager.View_Lobby) - else - ViewUtil.ErrorTip(res.ReturnCode) - end - end - ) - end - end - ) - _curren_msg:Show() - end - ) - end + local tip = '您是否退出房间?' -- \n (请注意,申请洗牌后退出,不会返还洗牌分) + local tipStr = '' + if self._room.agent then + tipStr = '您是否退出房间?' + else + tipStr = self._room.owner_id == self._room.self_player.self_user.account_id and tip_owner or tip + end + local _curren_msg = MsgWindow.new(self._root_view, tipStr, MsgWindow.MsgMode.OkAndCancel) + _curren_msg.onOk:Add( + function() + if self._state.selectedIndex > 0 and self._state.selectedIndex < 3 then + ViewUtil.ErrorTip(nil, '房间已开始,无法退出游戏。') + else + ViewUtil.ShowModalWait(self._root_view) + self._gamectr:LevelRoom( + function(res) + ViewUtil.CloseModalWait() + if res.ReturnCode == 0 then + ViewManager.ChangeView(ViewManager.View_Lobby) + else + ViewUtil.ErrorTip(res.ReturnCode) + end + end + ) + end + end + ) + _curren_msg:Show() + end + ) + end --[[local btn_back_lobby = _view:GetChild('btn_back_lobby') btn_back_lobby.displayObject.gameObject:SetActive(false) if btn_back_lobby ~= nil then @@ -350,27 +350,25 @@ function M:InitView(url, isHideIpAdds) -- 显示牌友圈助手 if self._room.group_id ~= 0 and not self._hide_assist then - - local bShow = true + local bShow = true local l_groups = DataManager.groups - local group = l_groups:get(self._room.group_id) + local group = l_groups:get(self._room.group_id) if group ~= nil then local option = group.option or 0 - if bit:_and(option,8) > 0 then + if bit:_and(option, 8) > 0 then bShow = false end end if bShow then --self:ShowFGAssist() end - end if self._room.self_player.entrust then self:MarkSelfTuoguan() end - - - --[[local gameCommonBtn = UIPackage.CreateObjectFromURL('ui://Common/gameCommonPanel') + + + --[[local gameCommonBtn = UIPackage.CreateObjectFromURL('ui://Common/gameCommonPanel') if gameCommonBtn then self._view:AddChild(gameCommonBtn) local shuaxingameBtn=gameCommonBtn:GetChild("shuaxinbtn") @@ -382,11 +380,6 @@ function M:InitView(url, isHideIpAdds) ) end end--]] - - - - - end function M:continue_game(continue) @@ -444,16 +437,15 @@ function M:ShowFGAssist() self._view:AddChild(btn_assist) local panel_assist = FGAssistView.new( - self._root_view, - function() - btn_assist.touchable = true - end - ) + self._root_view, + function() + btn_assist.touchable = true + end + ) if self._full then btn_assist.x = 40 else btn_assist.x = (GRoot.inst.width - 1334) * -0.5 + 40 - end btn_assist.y = panel_assist._root_view.height / 3 - 0.5 * btn_assist.height @@ -568,7 +560,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.PlayerState, function(...) - local arg = {...} + local arg = { ... } local p = arg[1] local info = _player_info[self:GetPos(p.seat)] info._ctr_offline.selectedIndex = p.line_state == 0 and 1 or 0 @@ -584,7 +576,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.DeskBreak, function(...) - local arg = {...} + local arg = { ... } local code = arg[1] if code == 0 then if self.dismissWin == nil then @@ -613,7 +605,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.Interaction, function(...) - local arg = {...} + local arg = { ... } local p = arg[1] if not p or not p.seat or p.seat == 0 then return @@ -658,7 +650,7 @@ function M:EventInit() _gamectr:AddEventListener( GameEvent.OnKicked, function() - printlog("GameEvent.OnKicked====》》》》》") + printlog("GameEvent.OnKicked====》》》》》") self:UnmarkSelfTuoguan() local _curren_msg = MsgWindow.new(self._root_view, '由于长时间未准备,你已被踢出房间!', MsgWindow.MsgMode.OnlyOk) _curren_msg.onOk:Add( @@ -669,27 +661,24 @@ function M:EventInit() _curren_msg:Show() end ) - - _gamectr:AddEventListener( + + _gamectr:AddEventListener( GameEvent.TupGuanOpen, function(...) - --print("刷新托管数据=====") - local arg = {...} - local p = arg[1] - local info = self._player_info[self:GetPos(p.seat)] - - if info and info.IsShowTGTips then - info:IsShowTGTips(arg[2],arg[3]) - end - - if info and info.SetShowTGTips then - info:SetShowTGTips(arg[2],arg[3]) - end - + --print("刷新托管数据=====") + local arg = { ... } + local p = arg[1] + local info = self._player_info[self:GetPos(p.seat)] + + if info and info.IsShowTGTips then + info:IsShowTGTips(arg[2], arg[3]) + end + + if info and info.SetShowTGTips then + info:SetShowTGTips(arg[2], arg[3]) + end end ) - - end -- 设置能否互动,1允许,0禁止 @@ -720,45 +709,45 @@ function M:PlayInteractAnimation(str, mypos, pos) local total_rotation = (offsetY + offsetX) / 100 * 50 self._run_move = TweenUtils.TweenFloat( - 0, - 1, - 0.5, - function(value) - myEff.x = mypos.x + offsetX * value - myEff.y = mypos.y + offsetY * value - if str == '2' then - myEff.rotation = total_rotation * value + 0, + 1, + 0.5, + function(value) + myEff.x = mypos.x + offsetX * value + myEff.y = mypos.y + offsetY * value + if str == '2' then + myEff.rotation = total_rotation * value + end end - end - ) + ) end self._run_eff = coroutine.start( - function() - if str ~= '1' then - coroutine.wait(0.5) - else - local degree = math.atan2(offsetX, offsetY) * 180 / math.pi - 90 - if degree < -180 then - degree = 360 + degree + function() + if str ~= '1' then + coroutine.wait(0.5) + else + local degree = math.atan2(offsetX, offsetY) * 180 / math.pi - 90 + if degree < -180 then + degree = 360 + degree + end + degree = degree * -1 + if degree > 90 or degree < -90 then + degree = degree + 180 * (degree > 90 and -1 or 1) + myEff.scaleX = -1 + end + myEff.rotation = degree + coroutine.wait(0.2) end - degree = degree * -1 - if degree > 90 or degree < -90 then - degree = degree + 180 * (degree > 90 and -1 or 1) - myEff.scaleX = -1 - end - myEff.rotation = degree - coroutine.wait(0.2) + self._view:AddChild(eff) + eff.x = pos.x + eff.y = pos.y + coroutine.wait(1.5) + eff:Dispose() + myEff:Dispose() end - self._view:AddChild(eff) - eff.x = pos.x - eff.y = pos.y - coroutine.wait(1.5) - eff:Dispose() - myEff:Dispose() - end - ) + ) end function M:GetReadyNum() @@ -775,13 +764,13 @@ end function M:OnPlayerEnter(...) printlog("进入房间222222222222222222++++++++++++++++++++++++++++") - local arg = {...} + local arg = { ... } local p = arg[1] if p ~= self._room.self_player and self._room.room_config.people_num <= 4 and - self._room.room_config.people_num >= 3 and - self._gamectr:CheckGPS() - then + self._room.room_config.people_num >= 3 and + self._gamectr:CheckGPS() + then if self._room.self_player.seat == 0 then return end @@ -791,7 +780,8 @@ function M:OnPlayerEnter(...) self.distance_view = PlayerDistanceView.new(true, self._gps_style, function(v) self:continue_game(v) end) - self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and self._state.selectedIndex < 3 and 1 or 0 + self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and + self._state.selectedIndex < 3 and 1 or 0 self.distance_view:Show() if self.btn_distance then self.btn_distance:GetController("state").selectedIndex = 1 @@ -803,30 +793,30 @@ function M:OnPlayerEnter(...) end function M:OnPlayerReady(...) - local arg = {...} + local arg = { ... } local p = arg[1] - - if p.isSendCardState~=nil and p.isSendCardState==true then - p.isSendCardState=false - ControllerManager.IsSendCard=false - --print("进入设置计时器控制==========") - coroutine.start(function() - --print("计时器倒计时5s=============") - coroutine.wait(5) - --print("当前状态==============") - --print(ControllerManager.IsSendCard) - if ControllerManager.IsSendCard==true then - --print("以发送开牌======================") - return - else - --print("开始断线重连") - --ControllerManager.OnConnect(SocketCode.TimeoutDisconnect) - ViewManager.refreshGameView() - end - ControllerManager.IsSendCard=false - end) - end - + + if p.isSendCardState ~= nil and p.isSendCardState == true then + p.isSendCardState = false + ControllerManager.IsSendCard = false + --print("进入设置计时器控制==========") + coroutine.start(function() + --print("计时器倒计时5s=============") + coroutine.wait(5) + --print("当前状态==============") + --print(ControllerManager.IsSendCard) + if ControllerManager.IsSendCard == true then + --print("以发送开牌======================") + return + else + --print("开始断线重连") + --ControllerManager.OnConnect(SocketCode.TimeoutDisconnect) + ViewManager.refreshGameView() + end + ControllerManager.IsSendCard = false + end) + end + if p.seat == self._room.self_player.seat then if self._ctr_action then self._ctr_action.selectedIndex = 0 @@ -838,7 +828,7 @@ function M:OnPlayerReady(...) end function M:OnUpdateInfo(...) - local arg = {...} + local arg = { ... } local p = arg[1] local t = arg[2] -- 托管状态变化 @@ -866,8 +856,8 @@ function M:MarkSelfTuoguan() if self._com_tuoguan then return end - - + + self._com_tuoguan = UIPackage.CreateObjectFromURL('ui://Common/com_tuoguan_self') local com_tuoguan = self._com_tuoguan GRoot.inst:AddChild(com_tuoguan) @@ -902,14 +892,14 @@ function M:MarkSelfTuoguan() _msg_view = nil end ) - local roate=GRoot.inst.width/GRoot.inst.height - local num=100 - if roate<1.9 then - num=250 - end + local roate = GRoot.inst.width / GRoot.inst.height + local num = 100 + if roate < 1.9 then + num = 250 + end com_tuoguan:AddChild(_msg_view) _msg_view:GetChild('tex_message').text = '确定要取消托管吗?' - _msg_view.x = (com_tuoguan.width - _msg_view.width) * 0.5-num + _msg_view.x = (com_tuoguan.width - _msg_view.width) * 0.5 - num _msg_view.y = (com_tuoguan.height - com_tuoguan.y - _msg_view.height) * 0.5 end ) @@ -924,7 +914,7 @@ function M:UnmarkSelfTuoguan() end function M:OnPlayerLeave(...) - local arg = {...} + local arg = { ... } local p = arg[1] local info = self._player_info[self:GetPos(p.seat)] info._view.visible = false @@ -985,14 +975,14 @@ function M:OnUpdate() if (self._popEvent) then local func = self._gamectr:PopEvent() if (func ~= nil) then - if pcall(func) then - - else - self._gamectr = ControllerManager.GetController(GameController) - if self._gamectr then - self._gamectr:ResetConnect() - end - end + if pcall(func) then + + else + self._gamectr = ControllerManager.GetController(GameController) + if self._gamectr then + self._gamectr:ResetConnect() + end + end --func() end end @@ -1006,16 +996,16 @@ function M:OnUpdate() local leftTime = math.floor(_left_time) if leftTime < 10 then self._tex_leftTime.text = '0' .. tostring(leftTime) - for i=2,4 do - local text = self["_tex_leftTime"..i] + for i = 2, 4 do + local text = self["_tex_leftTime" .. i] if text then text.text = '0' .. tostring(leftTime) end end else self._tex_leftTime.text = tostring(leftTime) - for i=2,4 do - local text = self["_tex_leftTime"..i] + for i = 2, 4 do + local text = self["_tex_leftTime" .. i] if text then text.text = tostring(leftTime) end @@ -1035,8 +1025,8 @@ function M:OnUpdate() if self._tex_leftTime then self._tex_leftTime.text = '00' end - for i=2,4 do - local text = self["_tex_leftTime"..i] + for i = 2, 4 do + local text = self["_tex_leftTime" .. i] if text then text.text = '00' end @@ -1060,16 +1050,18 @@ function M:OnUpdate() -- self.dismissWin = nil -- else self.dismissWin:OnUpdate(deltaTime) - -- end + -- end + end + + if self.OnMuShiUpdate then + self:OnMuShiUpdate() end - - if self.OnMuShiUpdate then - self:OnMuShiUpdate() - end end + function M:onLeftTimeOver() - + end + function M:Clear() -- self:__CloseTip() for i = 1, #self._player_info do @@ -1077,14 +1069,12 @@ function M:Clear() end end - function M:DestroyPlayerInfo() - for i = 1, #self._player_info do + for i = 1, #self._player_info do self._player_info[i]:Destroy() end end - function M:GetPos(seat) return ViewUtil.GetPos(self._room.self_player.seat, seat, self._room.room_config.people_num) end @@ -1104,7 +1094,7 @@ end --游戏激活 function M:OnApplicationActive() - --print("游戏激活================") + --print("游戏激活================") if os.time() - last_pause_time > 15 then last_pause_time = os.time() ControllerManager.WebClient:clearActionQueue() @@ -1124,16 +1114,17 @@ function M:Show() self.distance_view = PlayerDistanceView.new(true, self._gps_style, function(v) self:continue_game(v) end) - self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and self._state.selectedIndex < 3 and 1 or 0 + self.distance_view._view:GetController("state").selectedIndex = self._state.selectedIndex > 0 and + self._state.selectedIndex < 3 and 1 or 0 self.distance_view:Show() self.btn_distance:GetController("state").selectedIndex = 1 end end function M:Destroy() - TimerManager.Clear() + TimerManager.Clear() self:UnmarkSelfTuoguan() - self:DestroyPlayerInfo() + self:DestroyPlayerInfo() DSTweenManager.ClearTween() NetResetConnectWindow.CloseNetReset() @@ -1148,5 +1139,4 @@ function M:Destroy() BaseView.Destroy(self) BaseWindow.DestroyAll() ResourcesManager.UnLoadGroup('base_chat') - end diff --git a/lua_probject/base_project/Game/View/PlayerInfoView copy.lua b/lua_probject/base_project/Game/View/PlayerInfoView copy.lua new file mode 100644 index 00000000..d5cc739e --- /dev/null +++ b/lua_probject/base_project/Game/View/PlayerInfoView copy.lua @@ -0,0 +1,317 @@ +--- + +local PlayerInfoView = { + _view = nil, + _main_view = nil, + _tex_player_name = nil, + _tex_player_id = nil, + _tex_score = nil, + _ctr_offline = nil, + _ctr_bank = nil, + _ctr_room_owner = nil, + _ctr_mask_voice = nil, + _btn_head = nil, + _biaoqing = nil, + _chat = nil, + _player = nil, + __runwait_voice = nil, + _isHideIpAdds = false +} + +local M = PlayerInfoView + +function M.new(view, main_view, isHideIpAdds) + local self = {} + setmetatable(self, { __index = PlayerInfoView }) + self._view = view + self._main_view = main_view + self._isHideIpAdds = isHideIpAdds + self.isShowTGTimer = false + self.currentTime = 0 + self.totalTime = 0 + --self.isShow = fasle + self:init() + return self +end + +function M:init() + local view = self._view + UIPackage.AddPackage('base/chat/ui/Chat') + self._tex_player_name = view:GetChild('name') + + + self._biaoqing = view:GetChild('face') + self._chat = view:GetChild('chat') + + self._ctr_read = view:GetController('read') + self._ctr_offline = view:GetController('offline') + + self._btn_head = view:GetChild('btn_head') + self._ctr_bank = view:GetController('bank') + self._ctr_room_owner = view:GetController('room_owner') + self._ctr_mask_voice = view:GetController('mask_voice') + self._ctr_dismiss_room = view:GetController('dismiss_room') + + self.PlayerTGTips = view:GetChild('tuoguanTips') + if self.PlayerTGTips and self.PlayerTGTips.displayObject.gameObject then + self.PlayerTGTips.displayObject.gameObject:SetActive(false) + end +end + +function M:IsShowTGTips(isShow, time) + --printlog("isShowisShowisShow==== ",isShow," time ",time) + if time == nil then time = 0 end + + self.isShowTGTimer = isShow + if self.PlayerTGTips and self.PlayerTGTips.displayObject.gameObject then + self.PlayerTGTips.displayObject.gameObject:SetActive(isShow) + end + self.currentTime = 0 + if isShow then + if self.PlayerTGTips then + self.PlayerTGTips.text = "开启托管剩余时间" .. time .. "s" + end + self.totalTime = time + TimerManager.AddTimer(self.OnUpdate, self) + else + TimerManager.RemoveTimer(self.OnUpdate, self) + end +end + +function M:OnUpdate() + --printlog("OnUpdate=====================") + if self.isShowTGTimer then + self.currentTime = self.currentTime + Time.deltaTime + if self.currentTime >= 1 then + self.currentTime = 0 + self.totalTime = self.totalTime - 1 + --printlog("当前计时器===>>>",self.totalTime) + if self.PlayerTGTips then + self.PlayerTGTips.text = "开启托管剩余时间" .. self.totalTime .. "s" + end + + if self.totalTime <= 0 then + self.isShowTGTimer = false + if self.PlayerTGTips and self.PlayerTGTips.displayObject.gameObject then + self.PlayerTGTips.displayObject.gameObject:SetActive(false) + end + end + end + + if self.muShiPlayerUpdate then + self:muShiPlayerUpdate() + end + end +end + +function M:FillData(player) + self._player = player + if player == nil then + return + end + local isHidden = false + local room = DataManager.CurrenRoom + if room and room.playback ~= true and room.room_config and room.room_config.isHidden then + isHidden = room.room_config.isHidden == 1 + end + if isHidden == false then + ImageLoad.Load(player.self_user.head_url, self._btn_head._iconObject) + self._btn_head.onClick:Set( + function() + --local headView = HeadView.new(self._main_view._root_view, player.self_user, self._isHideIpAdds) + --headView:Show() + end + ) + else + local ctr = self._btn_head:GetController("hidden") + if ctr then + ctr.selectedIndex = 1 + end + end + + print("============================playinfoview") + pt(player) + + if isHidden + --and player.self_user.account_id ~= room.self_player.self_user.account_id + then + if player.orgSeat and player.orgSeat > 0 then + self._tex_player_name.text = "玩家" .. player.orgSeat + else + self._tex_player_name.text = "玩家" .. player.seat + player.orgSeat = membe_clone(player.seat) + end + if self._tex_player_id then + self._tex_player_id.text = "" + end + else + self._tex_player_name.text = player.self_user.nick_name + if self._tex_player_id then + self._tex_player_id.text = "ID:" .. player.self_user.account_id + end + end + self._ctr_room_owner.selectedIndex = room.owner_id == player.self_user.account_id and 1 or 0 + if (DataManager.CurrenRoom.self_player ~= player) then + self._ctr_offline.selectedIndex = player.line_state == 0 and 1 or 0 + end + -- self:UpdateScore() + self:Ready(player.ready) + + if player.entrust and player ~= room.self_player then + self:MarkTuoguan() + end +end + +function M:DismissRoom(state) + state = state or false + self._ctr_dismiss_room.selectedIndex = state == true and 1 or 0 +end + +function M:UpdateLineState(state) + self._ctr_offline.selectedIndex = state == 0 and 1 or 0 +end + +function M:Ready(isread) + self._ctr_read.selectedIndex = isread and 1 or 0 +end + +function M:MarkBank(isbank) + self._ctr_bank.selectedIndex = isbank and 1 or 0 +end + +-- 表情 语音 +function M:ShowInteraction(type, str) + if type == 3 then + Voice.DownLoad( + str, + function(clip) + if (clip) then + self:ShowMaskVoice(clip.length) + GameApplication.Instance:PlayVoice(clip) + end + end + ) + elseif type == 4 then + self:SetChat(str) + elseif type == 2 then + local chat_index = tonumber(str) + self._main_view:PlayChatSound(self._player.self_user.sex, chat_index) + local language, index = self._main_view:GetChatMsgLanguage(chat_index) + if language ~= 0 then + local msgs = self._main_view['Fix_Msg_Chat' .. language + 1] + self:SetChat(msgs[index]) + else + self:SetChat(self._main_view.Fix_Msg_Chat[chat_index]) + end + elseif type == 1 then + self:SetBiaoqing('ui://Chat/' .. str) + end +end + +function M:SetBiaoqing(url) + if (self.__runwait_biaoqing ~= nil) then + if self._biaoqing.numChildren > 0 then + self._biaoqing:RemoveChildAt(0, true) + end + coroutine.stop(self.__runwait_biaoqing) + end + self._biaoqing.alpha = 1 + local bq = UIPackage.CreateObjectFromURL(url) + self._biaoqing:AddChild(bq) + bq:Center() + -- self._biaoqing:GetChild("n1").icon = url + self.__runwait_biaoqing = nil + self.__runwait_biaoqing = coroutine.start(self.__WaitBiaoqing, self) +end + +function M:__WaitBiaoqing() + coroutine.wait(2) + self._biaoqing.alpha = 0 + -- self._biaoqing:GetChild("n1").icon = nil + self._biaoqing:GetChildAt(0):Dispose() +end + +function M:SetChat(msg) + -- body + self._chat.alpha = 1 + self._chat:GetChild('title').text = msg + if (self.__runwait_chat ~= nil) then + coroutine.stop(self.__runwait_chat) + end + self.__runwait_chat = nil + self.__runwait_chat = coroutine.start(self.__WaitChat, self) +end + +function M:__WaitChat() + coroutine.wait(2) + self._chat.alpha = 0 + self._chat:GetChild('title').text = '' +end + +function M:ShowMaskVoice(time, mask) + mask = mask or true + + GameApplication.Instance.StopMusic = GameApplication.Instance.StopMusic + 1 + if (mask) then + self._ctr_mask_voice.selectedIndex = 1 + end + if (self.__runwait_voice ~= nil) then + coroutine.stop(self.__runwait_voice) + GameApplication.Instance.StopMusic = GameApplication.Instance.StopMusic - 1 + end + self.__runwait_voice = nil + self.__runwait_voice = coroutine.start(self.__WaitMaskVoice, self, time) +end + +function M:__WaitMaskVoice(time) + coroutine.wait(time) + self._ctr_mask_voice.selectedIndex = 0 + self.__runwait_voice = nil + GameApplication.Instance.StopMusic = GameApplication.Instance.StopMusic - 1 +end + +function M:GetHeadCenter() + local btn_head = self._view:GetChild('btn_head') + local pt = Vector2(btn_head.x + 1 / 2 * btn_head.width, btn_head.y + 1 / 2 * btn_head.height) + return pt +end + +-- 添加、移除托管标记 +function M:MarkTuoguan() + local com_tuoguan = UIPackage.CreateObjectFromURL('ui://Common/com_tuoguan') + self:AddMarkToHead(com_tuoguan, 'mark_tuoguan') +end + +function M:UnmarkTuoguan() + self:RemoveMarkFromHead('mark_tuoguan') +end + +-- 动态的往头像上加载组件 +function M:AddMarkToHead(com, key) + if key then + if self[key] then + self[key]:Dispose() + end + self[key] = com + end + self._view:AddChild(com) + com.touchable = false + com.xy = self:GetHeadCenter() +end + +-- 动态移除组件 +function M:RemoveMarkFromHead(key) + if self[key] then + self[key]:Dispose() + self[key] = nil + end +end + +function M:Destroy() + self.isShowTGTimer = false + TimerManager.RemoveTimer(self.OnUpdate, self) + self.OnUpdate = nil + self.muShiPlayerUpdate = nil +end + +return M diff --git a/lua_probject/extend_project/extend/majiang/changsha/EXMainView.lua b/lua_probject/extend_project/extend/majiang/changsha/EXMainView.lua index 2db670bf..7898b695 100644 --- a/lua_probject/extend_project/extend/majiang/changsha/EXMainView.lua +++ b/lua_probject/extend_project/extend/majiang/changsha/EXMainView.lua @@ -29,8 +29,8 @@ local M = {} --- Create a new CS_MainView function M.new() - setmetatable(M,{__index = MJMainView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = MJMainView }) + local self = setmetatable({}, { __index = M }) self.class = "CS_MainView" self.asset_group = "ChangSha_MJ" self:init() @@ -41,41 +41,42 @@ end function M:InitView(url) local room = self._room - self._style = 1 - self._gps_style = 1 - self._full = true + self._style = 1 + self._gps_style = 1 + self._full = true -- self.Fix_Msg_Chat = Fix_Msg_Chat UIPackage.AddPackage("extend/majiang/changsha/ui/Extend_MJ_ChangSha") - MJMainView.InitView(self,"ui://Main_Majiang/Main_"..room.room_config.people_num .. "_s2") + MJMainView.InitView(self, "ui://Main_Majiang/Main_new_" .. room.room_config.people_num) + -- MJMainView.InitView(self, "ui://Main_Majiang/Main_" .. room.room_config.people_num .. "_s2") + self._view:GetChild('wanfa_text').text = room.room_config.people_num .. '人长麻 ' .. room.score_times .. '倍' - self.LaiziBG=self._view:GetChild('n103') - self.LaiziBG.text="鬼牌" - self.LaiziBG.visible=false - self.selectLaiziBtn=self._view:GetChild('selectlaizi') - self.Laizi1Btn=self._view:GetChild('selectlaizi1') - self.Laizi2Btn=self._view:GetChild('selectlaizi2') - self.Laizi1Btn.visible=false - self.Laizi2Btn.visible=false - self.selectLaiziBtn.visible=false - - self._hu_tip = HuTipView.new(self) + self.LaiziBG = self._view:GetChild('n103') + self.LaiziBG.text = "鬼牌" + self.LaiziBG.visible = false + self.selectLaiziBtn = self._view:GetChild('selectlaizi') + self.Laizi1Btn = self._view:GetChild('selectlaizi1') + self.Laizi2Btn = self._view:GetChild('selectlaizi2') + self.Laizi1Btn.visible = false + self.Laizi2Btn.visible = false + self.selectLaiziBtn.visible = false + + self._hu_tip = HuTipView.new(self) self:PlayerChangeLineState() --print("CS_MainView") - if (room.playing or room.curren_round > 0) or room.status == 1 then + if (room.playing or room.curren_round > 0) or room.status == 1 then self:ReloadRoom() end end - -function M:NewMJPlayerCardInfoView(view,index) - if index == 1 then - return MJPlayerSelfCardInfoView.new(view,self) +function M:NewMJPlayerCardInfoView(view, index) + if index == 1 then + return MJPlayerSelfCardInfoView.new(view, self) end - return MJPlayerCardInfoView.new(view,self) + return MJPlayerCardInfoView.new(view, self) end function M:EventInit() @@ -85,60 +86,56 @@ function M:EventInit() local _gcm_outcard_url = UIPackage.GetItemURL("Main_Majiang", "Gcm_OutCard") local _player_info = self._player_info local _gamectr = self._gamectr - - _gamectr:AddEventListener(CS_GameEvent.EventXiPai,function( ... ) - local arg = {...} - local currentPlayer1=arg[1] - local currentPlayer2=arg[2] + + _gamectr:AddEventListener(CS_GameEvent.EventXiPai, function(...) + local arg = { ... } + local currentPlayer1 = arg[1] + local currentPlayer2 = arg[2] self._popEvent = false - if ( currentPlayer1 ) then - - local xipaiCB=function () + if (currentPlayer1) then + local xipaiCB = function() self._popEvent = true end - self:PlayXiPai(xipaiCB) - + self:PlayXiPai(xipaiCB) end - - - if ( currentPlayer2 ) then + + + if (currentPlayer2) then --self._popEvent = false - local xipaiCB2=function () + local xipaiCB2 = function() self._popEvent = true end - self:PlayXiPai1(xipaiCB2) + self:PlayXiPai1(xipaiCB2) end - - end) - _gamectr:AddEventListener(CS_GameEvent.SendCards,function( ... ) - local arg = {...} + _gamectr:AddEventListener(CS_GameEvent.SendCards, function(...) + local arg = { ... } self._tex_LeftCard.text = arg[1] local info = self._player_card_info[1] info._player.auto_out_card = false self:UpdateRound() self._state.selectedIndex = 1 local list = _room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = self._player_info[self:GetPos(p.seat)] info:FillData(p) info:MarkBank(p.seat == _room.banker_seat) info:Ready(false) local card_info = self._player_card_info[self:GetPos(p.seat)] - card_info:UpdateHandCard() + card_info:UpdateHandCard() end end) _gamectr:AddEventListener(CS_GameEvent.EventTurn, function(...) - local arg = {...} + local arg = { ... } self._left_time = 15 local seat = arg[1] self:UpdateCardBox(self:GetPos(seat)) end) _gamectr:AddEventListener(CS_GameEvent.OutHint, function(...) - local arg = {...} + local arg = { ... } local auto = arg[1].auto if auto then local p = self._room.self_player @@ -157,21 +154,21 @@ function M:EventInit() end) - local _gcm_outcard_url ="ui://Main_Majiang/Gcm_OutCard" + local _gcm_outcard_url = "ui://Main_Majiang/Gcm_OutCard" _gamectr:AddEventListener(CS_GameEvent.OutCard, function(...) self:__CloseTip() self:ClearQSHTips() self._left_time = 0 - local arg = {...} + local arg = { ... } local p = arg[1] local seat = p.seat local card = arg[2] local info = self._player_card_info[self:GetPos(seat)] self:RemoveCursor() info:UpdateHandCard() - local outcard = UIPackage.CreateObjectFromURL(_gcm_outcard_url) - info:UpdateOutCardList(outcard, card, self._cursor) - self:PlaySound(p.self_user.sex,tostring(card)) + local outcard = UIPackage.CreateObjectFromURL(_gcm_outcard_url) + info:UpdateOutCardList(outcard, card, self._cursor) + self:PlaySound(p.self_user.sex, tostring(card)) self:PlayMJSound("chupai.mp3") if seat == _room.self_player.seat then _room.curren_outcard_seat = -1 @@ -182,7 +179,7 @@ function M:EventInit() if self.kg_card then self.kg_card:Dispose() end - local arg = {...} + local arg = { ... } local seat = arg[1] local card = arg[2] self._tex_LeftCard.text = arg[3] @@ -192,12 +189,12 @@ function M:EventInit() end) _gamectr:AddEventListener(CS_GameEvent.FZTips, function(...) - local arg = {...} + local arg = { ... } local _tip = arg[1] - self:__FangziTip(_tip) + self:__FangziTip(_tip) end) - _gamectr:AddEventListener(CS_GameEvent.FangziAction, handler(self,self.OnFangziAction)) + _gamectr:AddEventListener(CS_GameEvent.FangziAction, handler(self, self.OnFangziAction)) _gamectr:AddEventListener(CS_GameEvent.ZPHuCard, function(...) if self.kg_card then @@ -207,7 +204,7 @@ function M:EventInit() self:UpdateCardBox(0) self:__CloseTip() self._popEvent = false - local arg = {...} + local arg = { ... } local win_seat = arg[1] local lose_seat = arg[2] local win_card = arg[3] @@ -224,26 +221,26 @@ function M:EventInit() info._view:AddChild(obj_win_card) obj_win_card:Center() - local player = _room:GetPlayerBySeat(win_seat) - local hu_sound = win_seat == lose_seat and ("zimo"..math.random(1, 3)) or ("hu"..math.random(1, 2)) - self:PlaySound(player.self_user.sex, hu_sound) + local player = _room:GetPlayerBySeat(win_seat) + local hu_sound = win_seat == lose_seat and ("zimo" .. math.random(1, 3)) or ("hu" .. math.random(1, 2)) + self:PlaySound(player.self_user.sex, hu_sound) if win_list[1].type == 11 then - local url, pNode - if win_seat ~= _room.self_player.seat then - url = "ui://Main_Majiang/别人胡" - pNode = info._mask_liangpai - elseif win_seat == _room.self_player.seat then - url = "ui://Main_Majiang/自己胡牌" - pNode = self._view - end - if win_seat == lose_seat then - url = "ui://Main_Majiang/eff_zimo" - end + local url, pNode + if win_seat ~= _room.self_player.seat then + url = "ui://Main_Majiang/别人胡" + pNode = info._mask_liangpai + elseif win_seat == _room.self_player.seat then + url = "ui://Main_Majiang/自己胡牌" + pNode = self._view + end + if win_seat == lose_seat then + url = "ui://Main_Majiang/eff_zimo" + end local he = UIPackage.CreateObjectFromURL(url) pNode:AddChild(he) he:GetTransition("t2"):Play() - if win_seat == _room.self_player.seat then - he:Center() + if win_seat == _room.self_player.seat then + he:Center() elseif url == "ui://Main_Majiang/eff_zimo" then he.scaleY = 0.4 he.scaleX = 0.4 @@ -257,40 +254,40 @@ function M:EventInit() self._popEvent = true end) else - local pNode = info._view - local url = (index == 1 or index == 3) and "eff_list1" or "eff_list2" - local he_list = UIPackage.CreateObjectFromURL("ui://Extend_MJ_ChangSha/" .. url) - he_list.touchable = false - pNode:AddChild(he_list) - he_list:Center() - coroutine.start(function() - for i = 1 ,#win_list do - local tem = win_list[i] - local com_name = "he" .. tem.type - if tem.type == 1 then - com_name = com_name .. "_" .. tem.value - end - local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_ChangSha/" .. com_name) - coroutine.wait(0.3) - end - if player.win_count and player.win_count >= 3 then - he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_ChangSha/he_4w") - end - coroutine.wait(2) - obj_win_card:Dispose() - he_list:Dispose() - self._popEvent = true - end) + local pNode = info._view + local url = (index == 1 or index == 3) and "eff_list1" or "eff_list2" + local he_list = UIPackage.CreateObjectFromURL("ui://Extend_MJ_ChangSha/" .. url) + he_list.touchable = false + pNode:AddChild(he_list) + he_list:Center() + coroutine.start(function() + for i = 1, #win_list do + local tem = win_list[i] + local com_name = "he" .. tem.type + if tem.type == 1 then + com_name = com_name .. "_" .. tem.value + end + local item = he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_ChangSha/" .. com_name) + coroutine.wait(0.3) + end + if player.win_count and player.win_count >= 3 then + he_list:GetChild("list"):AddItemFromPool("ui://Extend_MJ_ChangSha/he_4w") + end + coroutine.wait(2) + obj_win_card:Dispose() + he_list:Dispose() + self._popEvent = true + end) end end) _gamectr:AddEventListener(CS_GameEvent.EventNiao, function(...) - local arg = {...} + local arg = { ... } self._popEvent = false local list = arg[1] local start_seat = arg[2] ViewUtil.PlaySound("ChangSha_MJ", "extend/majiang/changsha/sound/zhuaniao.mp3") - coroutine.start(self.RunNiao,self,list, start_seat) + coroutine.start(self.RunNiao, self, list, start_seat) end) _gamectr:AddEventListener(CS_GameEvent.ZPResult1, function(...) @@ -302,11 +299,11 @@ function M:EventInit() end if self.kg_card then self.kg_card:Dispose() - _room.kg_card={} + _room.kg_card = {} end self._left_time = 0 self:UpdateCardBox(0) - local arg = {...} + local arg = { ... } local result = arg[1] local liuju = result.liuju local data = result.info_list @@ -329,7 +326,7 @@ function M:EventInit() if self._clearingView._is_destroy then return end self._clearingView:Show() self._popEvent = true - end) + end) end if _room.curren_round ~= _room.room_config.round then @@ -345,20 +342,20 @@ function M:EventInit() if _room:checkHpNonnegative() then p.cur_hp = data[i].hp_info.cur_hp end - info:UpdateScore() + -- info:UpdateScore() info._view:GetChild("zhanji").visible = true local num = data[i].hp_info.total_hp - if num > 0 then - info._view:GetController("text_color").selectedIndex = 0 - info._view:GetChild("text_jifen").text = "+" .. d2ad(num) - else - info._view:GetController("text_color").selectedIndex = 1 - info._view:GetChild("text_jifen").text = d2ad(num) - end + if num > 0 then + info._view:GetController("text_color").selectedIndex = 0 + info._view:GetChild("text_jifen").text = "+" .. d2ad(num) + else + info._view:GetController("text_color").selectedIndex = 1 + info._view:GetChild("text_jifen").text = d2ad(num) + end - info._view:GetChild("mask_piao").title = "" - info._view:GetController("piao_niao").selectedIndex = 0 - p.win_count = data[i].win_count + info._view:GetChild("mask_piao").title = "" + info._view:GetController("piao_niao").selectedIndex = 0 + p.win_count = data[i].win_count if p.win_count >= 3 then info._view:GetController("three_win").selectedIndex = 1 info._view:GetChild("com_three_win"):GetChild("tex_win").text = p.win_count @@ -368,7 +365,7 @@ function M:EventInit() end info._view:GetController("ting").selectedIndex = 0 p.fz_list = {} - p.auto_play=false + p.auto_play = false end DataManager.CurrenRoom.self_player.card_list = {} self._state.selectedIndex = 2 @@ -386,7 +383,7 @@ function M:EventInit() self:UnmarkSelfTuoguan() self._left_time = 0 self:UpdateCardBox(0) - local arg = {...} + local arg = { ... } local total_result = arg[2] local result = arg[1] local over = arg[3] @@ -394,13 +391,13 @@ function M:EventInit() coroutine.start(function() coroutine.wait(0.5) self._clearingView:Show() - end) + end) self._clearingView:InitData(over, _room, result, total_result) ControllerManager.ChangeController(LoddyController) end) _gamectr:AddEventListener(CS_GameEvent.EventQSTip, function(...) - local arg = {...} + local arg = { ... } local data = arg[1] local tip = data["types"] local lit = data["tip_list"] @@ -416,7 +413,7 @@ function M:EventInit() local item = tipList:AddItemFromPool() item:GetChild("icon").url = "ui://Extend_MJ_ChangSha/qs" .. tip[i].type item:GetChild("num").text = tip[i].value - end + end local id = lit[1].id tip_qishou:GetChild("btn_qs").onClick:Add(function() _gamectr:SendAction(id) @@ -433,15 +430,14 @@ function M:EventInit() end) _gamectr:AddEventListener(CS_GameEvent.EvnetQSAction, function(...) - local arg = {...} + local arg = { ... } local data = arg[1] self._popEvent = false self:__QsHu(data) end) _gamectr:AddEventListener(CS_GameEvent.EventKaiGang, function(...) - - local arg = {...} + local arg = { ... } local data = arg[1] local outlist = arg[2] self._popEvent = false @@ -453,10 +449,10 @@ function M:EventInit() end) _gamectr:AddEventListener(CS_GameEvent.EvnetPiaoTip, function() - self:UpdateRound() - self._tex_LeftCard.text = "0" - self._state.selectedIndex = 1 - if oldGameVersion==1 then + self:UpdateRound() + self._tex_LeftCard.text = "0" + self._state.selectedIndex = 1 + if oldGameVersion == 1 then self:__PiaoNiaoTip() else self:__PiaoNiaoTip1() @@ -464,7 +460,7 @@ function M:EventInit() end) _gamectr:AddEventListener(CS_GameEvent.EvnetPiao, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local num = arg[2] if num > 0 then @@ -473,8 +469,8 @@ function M:EventInit() head_info._view:GetController("piao_niao").selectedIndex = 1 end if seat == _room.self_player.seat then - if self._com_piao then - self._com_piao:Dispose() + if self._com_piao then + self._com_piao:Dispose() self._com_piao = nil end end @@ -490,46 +486,46 @@ function M:EventInit() local _btn_ting = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_fztip") _btn_ting.icon = "ui://Main_Majiang/fztip_6" - _btn_ting.onClick:Set(function( ... ) - _gamectr:SendAction(1) - com_tip:Dispose() - self._chipeng_tip = nil + _btn_ting.onClick:Set(function(...) + _gamectr:SendAction(1) + com_tip:Dispose() + self._chipeng_tip = nil end) local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") - _btn_pass.onClick:Set(function( ... ) - _gamectr:SendAction(0) - self._chipeng_tip:Dispose() - self._chipeng_tip = nil + _btn_pass.onClick:Set(function(...) + _gamectr:SendAction(0) + self._chipeng_tip:Dispose() + self._chipeng_tip = nil end) self._view:AddChild(com_tip) com_tip:Center() end) _gamectr:AddEventListener(CS_GameEvent.EventTing, function(...) - local arg = {...} + local arg = { ... } local seat = arg[1] local index = self:GetPos(seat) local head_info = self._player_info[index] head_info._view:GetController("ting").selectedIndex = 1 local info = self._player_card_info[index] info._player.auto_out_card = true - info:UpdateHandCard() + info:UpdateHandCard() end) end function M:UpdateRound() - self._view:GetChild("tex_round1").text = self._room.curren_round - self._view:GetChild("tex_round2").text = self._room.room_config.round + self._view:GetChild("text_round").text = string.format("当前局数:%d/%d", self._room.curren_round, + self._room.room_config.round) end function M:InitPlayerInfoView() - self._player_info = {} - local _player_info = self._player_info - for i = 1, self._room.room_config.people_num do - local tem = self._view:GetChild("player_info" .. i) - _player_info[i] = PlayerInfoView.new(tem,self) - tem.visible = false - end + self._player_info = {} + local _player_info = self._player_info + for i = 1, self._room.room_config.people_num do + local tem = self._view:GetChild("player_info" .. i) + _player_info[i] = PlayerInfoView.new(tem, self) + tem.visible = false + end end local discard_frame = 0 @@ -549,12 +545,12 @@ function M:OutCard(card) info:UpdateHandCard() info:UpdateOutCardList(nil, card, self._cursor) - self:PlaySound(self._room.self_player.self_user.sex,tostring(card)) + self:PlaySound(self._room.self_player.self_user.sex, tostring(card)) self:PlayMJSound("chupai.mp3") end) end -function M:__FangziTip(tip) +function M:__FangziTip(tip) if self.kg_card then self.kg_card:Dispose() end @@ -569,48 +565,48 @@ function M:__FangziTip(tip) _lit_fanzi:RemoveChildrenToPool() local _tlist = table.keys(tip.tip_map_type) - + local tip_hu = false local count = #_tlist table.sort(_tlist) local isHu = false - for k=1,#_tlist do + for k = 1, #_tlist do local td = tip.tip_map_type[_tlist[k]][1] local url = "ui://Main_Majiang/Btn_fztip" local weight = td.weight - if tonumber(weight) == 5 then + if tonumber(weight) == 5 then isHu = true - weight = 8 + weight = 8 url = "ui://Main_Majiang/Btn_hu" elseif tonumber(weight) == 3 then weight = 16 end local btn_t = _lit_fanzi:AddItemFromPool(url) - if url == "ui://Main_Majiang/Btn_hu" and td.card then - btn_t:GetChild("hupai").icon="ui://Main_Majiang/202_" ..td.card - btn_t:GetController("hupai").selectedIndex=1 + if url == "ui://Main_Majiang/Btn_hu" and td.card then + btn_t:GetChild("hupai").icon = "ui://Main_Majiang/202_" .. td.card + btn_t:GetController("hupai").selectedIndex = 1 end - btn_t.icon = "ui://Main_Majiang/fztip_"..weight + btn_t.icon = "ui://Main_Majiang/fztip_" .. weight btn_t.data = { tip, td } - btn_t.onClick:Add(self.__TipAction,self) + btn_t.onClick:Add(self.__TipAction, self) end local _btn_pass = _lit_fanzi:AddItemFromPool("ui://Main_Majiang/Btn_pass") _btn_pass.onClick:Set(function() - if isHu then - local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) - guo_msg.onOk:Add(function() - _gamectr:SendAction(0) - _chipeng_tip:Dispose() - self._chipeng_tip = nil - guo_msg:Close() - end) - guo_msg:Show() - else - _gamectr:SendAction(0) - _chipeng_tip:Dispose() - self._chipeng_tip = nil - end + if isHu then + local guo_msg = MsgWindow.new(self._root_view, "确定要点过吗?", MsgWindow.MsgMode.OkAndCancel) + guo_msg.onOk:Add(function() + _gamectr:SendAction(0) + _chipeng_tip:Dispose() + self._chipeng_tip = nil + guo_msg:Close() + end) + guo_msg:Show() + else + _gamectr:SendAction(0) + _chipeng_tip:Dispose() + self._chipeng_tip = nil + end end) self._view:AddChild(_chipeng_tip) @@ -627,15 +623,15 @@ function M:__TipAction(context) self:_ChiView(list, function(id) _gamectr:SendAction(id) self:__CloseTip() - end) - self._chipeng_tip.visible = false - return + end) + self._chipeng_tip.visible = false + return end - _gamectr:SendAction(td.id) - if (self._chipeng_tip == nil) then return end - self._chipeng_tip:Dispose() - self._chipeng_tip = nil + _gamectr:SendAction(td.id) + if (self._chipeng_tip == nil) then return end + self._chipeng_tip:Dispose() + self._chipeng_tip = nil end function M:_ChiView(tiplist, callback) @@ -644,20 +640,22 @@ function M:_ChiView(tiplist, callback) local list_choose1 = _pop_tip_choice:GetChild("Lst_choose") local list_choose2 = _pop_tip_choice:GetChild("Lst_choose2") local crossCtr = _pop_tip_choice:GetController("state") - crossCtr.selectedIndex = #tiplist == 3 and 0 or (#tiplist == 2 and 1 or (#tiplist == 4 and 2 or (#tiplist == 5 and 3 or 4))) + crossCtr.selectedIndex = #tiplist == 3 and 0 or + (#tiplist == 2 and 1 or (#tiplist == 4 and 2 or (#tiplist == 5 and 3 or 4))) _pop_tip_choice:GetChild("Btn_cross").onClick:Add(function() _pop_tip_choice:Dispose() self._chipeng_tip.visible = true end) - list_choose1:RemoveChildrenToPool() - list_choose2:RemoveChildrenToPool() - for i = 1, #tiplist do - local list_choose = i <= 3 and list_choose1 or list_choose2 + list_choose1:RemoveChildrenToPool() + list_choose2:RemoveChildrenToPool() + for i = 1, #tiplist do + local list_choose = i <= 3 and list_choose1 or list_choose2 local item_choose = list_choose:AddItemFromPool() item_choose:GetController("type").selectedIndex = (1 == tiplist[i].weight or 2 == tiplist[i].weight) and 1 or 0 if tiplist[i].weight ~= 1 then for j = 1, 4 do - item_choose:GetChild("card"..j).icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "202_"..tiplist[i].card) + item_choose:GetChild("card" .. j).icon = UIPackage.GetItemURL("Main_Majiang", + self:GetPrefix() .. "202_" .. tiplist[i].card) end else local tem = {} @@ -668,19 +666,23 @@ function M:_ChiView(tiplist, callback) table.sort(tem, function(a, b) return a < b end) - item_choose:GetChild("card1").icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "202_"..tem[1]) - item_choose:GetChild("card2").icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "202_"..tem[2]) - item_choose:GetChild("card4").icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "202_"..tem[3]) + item_choose:GetChild("card1").icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "202_" .. + tem[1]) + item_choose:GetChild("card2").icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "202_" .. + tem[2]) + item_choose:GetChild("card4").icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "202_" .. + tem[3]) local cardpos = tem[2] > tcard and 1 or (tem[2] < tcard and 4 or 2) item_choose:GetChild("card" .. cardpos):GetController("color").selectedIndex = 1 end item_choose.onClick:Add(function() - callback(tiplist[i].id) + callback(tiplist[i].id) end) - end - _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width)/2, (self._view.height - _pop_tip_choice.height)/2) - self._view:AddChild(_pop_tip_choice) - self._pop_tip_choice = _pop_tip_choice + end + _pop_tip_choice.xy = Vector2((self._view.width - _pop_tip_choice.width) / 2, + (self._view.height - _pop_tip_choice.height) / 2) + self._view:AddChild(_pop_tip_choice) + self._pop_tip_choice = _pop_tip_choice end function M:__QsHu(data) @@ -709,7 +711,7 @@ function M:__QsHu(data) local target_xy = self._view:GlobalToLocal(head_info._view:LocalToGlobal(head_info:GetHeadCenter())) local diff_x = (target_xy.x - 0.5 * shaizi.width) - xy.x local diff_y = (target_xy.y - 0.5 * shaizi.height) - xy.y - self._tween_shaizi = TweenUtils.TweenFloat(0,1,1,function(value) + self._tween_shaizi = TweenUtils.TweenFloat(0, 1, 1, function(value) shaizi.x = xy.x + diff_x * value shaizi.y = xy.y + diff_y * value end) @@ -725,7 +727,7 @@ function M:__QsHu(data) local qs_type = data.type -- 6是起手胡 8是中途 for i = 1, #qs_data do local cards = {} - local opcard =qs_data[i].opcard + local opcard = qs_data[i].opcard local qtype = qs_data[i].type if not types[qtype] then types[qtype] = qs_data[i].value end if qtype == 23 or qtype == 24 or qtype == 27 then @@ -741,7 +743,7 @@ function M:__QsHu(data) cards[card] = 1 end end - for k,v in pairs(cards) do + for k, v in pairs(cards) do local card = k if ShowCardsNum[card] then if ShowCardsNum[card] < cards[card] then @@ -754,7 +756,7 @@ function M:__QsHu(data) end end if not showAllCards then - for i,v in pairs(ShowCardsNum) do + for i, v in pairs(ShowCardsNum) do for j = 1, v do table.insert(allShowCards, i) end @@ -764,7 +766,7 @@ function M:__QsHu(data) end local info = self._player_card_info[self:GetPos(seat)] local pNode = info._mask_liangpai - self.QSHList={} + self.QSHList = {} coroutine.start(function() for i, v in pairs(types) do local show_tip = UIPackage.CreateObject("Extend_MJ_ChangSha", "Tip_qishou") @@ -772,18 +774,18 @@ function M:__QsHu(data) show_tip:GetChild("num").text = v pNode:AddChild(show_tip) show_tip:Center() - table.insert(self.QSHList,show_tip) + table.insert(self.QSHList, show_tip) --coroutine.wait(4) --show_tip:Dispose() end - end) + end) table.sort(allShowCards, ViewUtil.HandCardSort) info:UpdateHandCard(false, false, allShowCards) coroutine.start(function() coroutine.wait(0.5) - self._popEvent = true + self._popEvent = true coroutine.wait(4) - self._room.room_config.banyiquan=true + self._room.room_config.banyiquan = true if not (self._room.room_config.banyiquan and qs_type == 6) then info:UpdateHandCard(false, false, {}) end @@ -791,17 +793,15 @@ function M:__QsHu(data) end) end - function M:ClearQSHTips() - if self.QSHList and #self.QSHList>0 then - for i=1,#self.QSHList do + if self.QSHList and #self.QSHList > 0 then + for i = 1, #self.QSHList do self.QSHList[i]:Dispose() end - self.QSHList=nil + self.QSHList = nil end end - function M:__KaiGang(data) local seat = data["seat"] local kg_info = data["info"] @@ -811,8 +811,8 @@ function M:__KaiGang(data) local info = self._player_card_info[self:GetPos(seat)] local p = self._room:GetPlayerBySeat(seat) local card = p.outcard_list[#p.outcard_list] - printlog("jefe kai_gang",dice1) - printlog("jefe kai_gang",dice2) + printlog("jefe kai_gang", dice1) + printlog("jefe kai_gang", dice2) local shaizi = UIPackage.CreateObject("Extend_MJ_ChangSha", "Ani_shaizi") shaizi:GetChild("shaizi1").icon = UIPackage.GetItemURL("Extend_MJ_ChangSha", "shaizi" .. dice1) shaizi:GetChild("shaizi2").icon = UIPackage.GetItemURL("Extend_MJ_ChangSha", "shaizi" .. dice2) @@ -830,7 +830,7 @@ function M:__KaiGang(data) if p.seat == self._room.self_player.seat then if not info._player then info._player = {} end info._player.auto_out_card = true - info:UpdateHandCard() + info:UpdateHandCard() end coroutine.start(function() -- coroutine.wait(0.5) @@ -841,7 +841,7 @@ function M:__KaiGang(data) local target_xy = self._view:GlobalToLocal(head_info._view:LocalToGlobal(head_info:GetHeadCenter())) local diff_x = (target_xy.x - 0.5 * shaizi.width) - xy.x local diff_y = (target_xy.y - 0.5 * shaizi.height) - xy.y - self._tween_shaizi = TweenUtils.TweenFloat(0,1,1,function(value) + self._tween_shaizi = TweenUtils.TweenFloat(0, 1, 1, function(value) shaizi.x = xy.x + diff_x * value shaizi.y = xy.y + diff_y * value end) @@ -850,10 +850,10 @@ function M:__KaiGang(data) self._view:AddChild(self.kg_card) self.kg_card:Center() - info:UpdateOutCardList(nil,card, self._cursor) - self._view:GetChild("remaining_card").text = string.format("剩余%d张牌",self._room.remain_cards) + info:UpdateOutCardList(nil, card, self._cursor) + self._view:GetChild("remaining_card").text = string.format("剩余%d张牌", self._room.remain_cards) - coroutine.wait(1) + coroutine.wait(1) self._popEvent = true end) end @@ -869,80 +869,76 @@ function M:__Haidi() item:Dispose() end) btn_cancel.onClick:Add(function() - _gamectr:SendAction(0) - item:Dispose() + _gamectr:SendAction(0) + item:Dispose() end) self._view:AddChild(item) item:Center() self._com_haidi = item end - function M:__PiaoNiaoTip() - local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") - self._view:AddChild(obj_piao) - obj_piao.x = (self._view.width - obj_piao.width) * 0.5 - obj_piao.y = self._view.height * 0.6 - local piaoState=obj_piao:GetController('piao') - piaoState.selectedIndex=1 - for i = 1, 4 do - obj_piao:GetChild("btn_" .. i).onClick:Add(function() - self._gamectr:SendAction(i - 1) - obj_piao:Dispose() - end) - end - self._com_piao = obj_piao + local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") + self._view:AddChild(obj_piao) + obj_piao.x = (self._view.width - obj_piao.width) * 0.5 + obj_piao.y = self._view.height * 0.6 + local piaoState = obj_piao:GetController('piao') + piaoState.selectedIndex = 1 + for i = 1, 4 do + obj_piao:GetChild("btn_" .. i).onClick:Add(function() + self._gamectr:SendAction(i - 1) + obj_piao:Dispose() + end) + end + self._com_piao = obj_piao end - function M:__PiaoNiaoTip1() - local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") - self._view:AddChild(obj_piao) - obj_piao.x = (self._view.width - obj_piao.width) * 0.5 - obj_piao.y = self._view.height * 0.6 - local piaoState=obj_piao:GetController('piao') - - local tconfig=DataManager.CurrenRoom.room_config.config - - - - local piaoList={} - - for i = 1, 4 do - local piaoT=obj_piao:GetChild("btn_" .. i) - table.insert(piaoList,piaoT) - piaoT.onClick:Add(function() - self._gamectr:SendAction(i - 1) - obj_piao:Dispose() - end) - - end - self._com_piao = obj_piao - - + local obj_piao = UIPackage.CreateObject("Main_Majiang", "panel_piao_niao") + self._view:AddChild(obj_piao) + obj_piao.x = (self._view.width - obj_piao.width) * 0.5 + obj_piao.y = self._view.height * 0.6 + local piaoState = obj_piao:GetController('piao') - if tconfig.piao_niao<2 then - for i=1,#piaoList do - piaoList[i].visible=true - end - piaoState.selectedIndex=1 - else - piaoList[1].visible=false - for i=2,#piaoList do - piaoList[i].visible=tconfig["piao"..(i-1)] - end - piaoState.selectedIndex=2 + local tconfig = DataManager.CurrenRoom.room_config.config + + + + local piaoList = {} + + for i = 1, 4 do + local piaoT = obj_piao:GetChild("btn_" .. i) + table.insert(piaoList, piaoT) + piaoT.onClick:Add(function() + self._gamectr:SendAction(i - 1) + obj_piao:Dispose() + end) + end + self._com_piao = obj_piao + + + + if tconfig.piao_niao < 2 then + for i = 1, #piaoList do + piaoList[i].visible = true + end + piaoState.selectedIndex = 1 + else + piaoList[1].visible = false + for i = 2, #piaoList do + piaoList[i].visible = tconfig["piao" .. (i - 1)] + end + piaoState.selectedIndex = 2 end - end -function M:OnFangziAction(...) +function M:OnFangziAction(...) self._popEvent = false if self.kg_card then self.kg_card:Dispose() end self:__CloseTip() - local arg = {...} + local arg = { ... } local _player_card_info = self._player_card_info local fz = arg[1] local player = arg[2] @@ -956,32 +952,32 @@ function M:OnFangziAction(...) local fz_sound = "" if fz.type == FZType.Peng then fangzi = "碰" - fz_sound = "peng"..math.random(1, 3) + fz_sound = "peng" .. math.random(1, 3) elseif fz.type == FZType.Chi then fangzi = "吃" - fz_sound = "chi"..math.random(1, 3) + fz_sound = "chi" .. math.random(1, 3) else - if fz.opengang then + if fz.opengang then fangzi = "杠" - fz_sound = "gang"..math.random(1, 2) + fz_sound = "gang" .. math.random(1, 2) else fangzi = "补" fz_sound = "buzhang" - end + end end - self:PlaySound(player.self_user.sex,fz_sound) + self:PlaySound(player.self_user.sex, fz_sound) effect:GetChild("word1").icon = UIPackage.GetItemURL("Main_Majiang", fangzi) - effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", fangzi) + effect:GetChild("word2").icon = UIPackage.GetItemURL("Main_Majiang", fangzi) effect.touchable = false effect:GetTransition("t2"):Play() pNode:AddChild(effect) - + coroutine.start(function() coroutine.wait(0.3) self._popEvent = true end) - + coroutine.start(function() coroutine.wait(1.8) effect:Dispose() @@ -989,8 +985,8 @@ function M:OnFangziAction(...) self:RemoveCursor() if (player.seat ~= fz.from_seat) then - local fs_info = _player_card_info[self:GetPos(fz.from_seat)] - fs_info:UpdateOutCardList() + local fs_info = _player_card_info[self:GetPos(fz.from_seat)] + fs_info:UpdateOutCardList() end info:UpdateFzList(fz, index, true) @@ -998,50 +994,49 @@ function M:OnFangziAction(...) info:UpdateHandCard(getcard) self:PlayMJSound("fangzi.mp3") - end +end function M:RunNiao(list, start_seat) local _room = self._room --local _niao_View = self._niao_View - self._niao_View = UIPackage.CreateObject("Extend_MJ_ChangSha","Panel_Birds") + self._niao_View = UIPackage.CreateObject("Extend_MJ_ChangSha", "Panel_Birds") self._view:AddChild(self._niao_View) self._niao_View:Center() local _niao_View = self._niao_View local list_niao_card = self._niao_View:GetChild("Lst_birds") list_niao_card:RemoveChildrenToPool() - for i = 1, #list do - --添加背面的麻將 - local item = list_niao_card:AddItemFromPool() - item.icon = UIPackage.GetItemURL("Main_Majiang", "202_00") - item:GetChild("tex_score").text = "+" .. list[i].score + for i = 1, #list do + --添加背面的麻將 + local item = list_niao_card:AddItemFromPool() + item.icon = UIPackage.GetItemURL("Main_Majiang", "202_00") + item:GetChild("tex_score").text = "+" .. list[i].score end for i = 1, #list do --顯示正面 local item = list_niao_card:GetChildAt(i - 1) - local card = list[i].card - -- coroutine.wait(0.3) - item:GetTransition("appear"):Play() - item.icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "201_"..card) - if list[i].score > 0 then item:GetController("bg").selectedIndex = 1 end + local card = list[i].card + -- coroutine.wait(0.3) + item:GetTransition("appear"):Play() + item.icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "201_" .. card) + if list[i].score > 0 then item:GetController("bg").selectedIndex = 1 end end coroutine.start(function() - coroutine.wait(1.5) - _niao_View:Dispose() - self._popEvent = true + coroutine.wait(1.5) + _niao_View:Dispose() + self._popEvent = true end) end function M:ReloadRoom(bskip) - local room = self._room - + local room = self._room + if bskip == nil or bskip == false then if not room.playing then - self._state.selectedIndex = 2 + self._state.selectedIndex = 2 else - self._state.selectedIndex = 1 - self._room._reload_flag = true + self._state.selectedIndex = 1 + self._room._reload_flag = true end - end if room.kg_card and #room.kg_card ~= 0 then @@ -1053,11 +1048,10 @@ function M:ReloadRoom(bskip) self._view:AddChild(self.kg_card) self.kg_card:Center() end - for i = 1, #room.player_list do + for i = 1, #room.player_list do local p = room.player_list[i] local info = self._player_card_info[self:GetPos(p.seat)] local head_info = self._player_info[self:GetPos(p.seat)] - head_info:UpdateScore() head_info._view:GetChild('zhanji').visible = true local num = p.total_hp or 0 if num > 0 then @@ -1068,7 +1062,7 @@ function M:ReloadRoom(bskip) head_info._view:GetChild('text_jifen').text = d2ad(num) end - if p.win_count~=nil and p.win_count >= 3 then + if p.win_count ~= nil and p.win_count >= 3 then head_info._view:GetController("three_win").selectedIndex = 1 head_info._view:GetChild("com_three_win"):GetChild("tex_win").text = p.win_count end @@ -1084,53 +1078,53 @@ function M:ReloadRoom(bskip) end info:UpdateHandCard() if p.seat == room.last_outcard_seat then - local card = p.outcard_list[#p.outcard_list] - info:UpdateOutCardList(nil,card, self._cursor) + local card = p.outcard_list[#p.outcard_list] + info:UpdateOutCardList(nil, card, self._cursor) elseif p.seat == room.curren_outcard_seat then - info:UpdateHandCard(true) - info:UpdateOutCardList() + info:UpdateHandCard(true) + info:UpdateOutCardList() else - info:UpdateOutCardList() + info:UpdateOutCardList() end if p.seat == room.banker_seat then - local head = self._player_info[self:GetPos(p.seat)] - head:MarkBank(true) + local head = self._player_info[self:GetPos(p.seat)] + head:MarkBank(true) end - + if bskip == nil or bskip == false then if p.ready and room.playing == false then - self._player_info[self:GetPos(p.seat)]:Ready(true) + self._player_info[self:GetPos(p.seat)]:Ready(true) end end - if p.piao_niao~=nil and p.piao_niao > 0 then - local head_info = self._player_info[self:GetPos(p.seat)] - head_info._view:GetChild("mask_piao").title = "飘分 " .. p.piao_niao - head_info._view:GetController("piao_niao").selectedIndex = 1 - end - end - - if bskip == nil or bskip == false then + if p.piao_niao ~= nil and p.piao_niao > 0 then + local head_info = self._player_info[self:GetPos(p.seat)] + head_info._view:GetChild("mask_piao").title = "飘分 " .. p.piao_niao + head_info._view:GetController("piao_niao").selectedIndex = 1 + end + end + + if bskip == nil or bskip == false then self:UpdateCardBox(self:GetPos(room.curren_outcard_seat)) self._tex_LeftCard.text = room.left_count self:UpdateRound() - end - local me = room.self_player - if room.curren_outcard_seat == me.seat and me.auto_play then - self:OutCard(me.draw_card) - me.draw_card = nil - end + end + local me = room.self_player + if room.curren_outcard_seat == me.seat and me.auto_play then + self:OutCard(me.draw_card) + me.draw_card = nil + end end function M:GetPos(seat) - local pos = 0 - if seat ~= 0 then - pos = ViewUtil.GetPos(self._room.self_player.seat, seat, self._room.room_config.people_num) - end - return pos + local pos = 0 + if seat ~= 0 then + pos = ViewUtil.GetPos(self._room.self_player.seat, seat, self._room.room_config.people_num) + end + return pos end -function M:PlaySound(sex,path) - MJMainView.PlaySound(self, "ChangSha_MJ", sex, path) +function M:PlaySound(sex, path) + MJMainView.PlaySound(self, "ChangSha_MJ", sex, path) end function M:PlayerChangeLineState() @@ -1176,11 +1170,11 @@ function M:closeTipOnTuoguan() end function M:Destroy() - MJMainView.Destroy(self) - UIPackage.RemovePackage("extend/majiang/changsha/ui/Extend_MJ_ChangSha") - if self._tween_shaizi then - TweenUtils.Kill(self._tween_shaizi) - end + MJMainView.Destroy(self) + UIPackage.RemovePackage("extend/majiang/changsha/ui/Extend_MJ_ChangSha") + if self._tween_shaizi then + TweenUtils.Kill(self._tween_shaizi) + end end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/changsha/EXPlayerInfoView.lua b/lua_probject/extend_project/extend/majiang/changsha/EXPlayerInfoView.lua index f8a5fd69..a1687132 100644 --- a/lua_probject/extend_project/extend/majiang/changsha/EXPlayerInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/changsha/EXPlayerInfoView.lua @@ -1,10 +1,10 @@ -local PlayerInfoView = require("Game.View.PlayerInfoView") +local PlayerInfoView = require("Game.View.PlayerInfoView copy") local M = {} function M.new(view, mainView) - setmetatable(M, {__index = PlayerInfoView}) - local self = setmetatable({}, {__index = M}) + setmetatable(M, { __index = PlayerInfoView }) + local self = setmetatable({}, { __index = M }) self._view = view self._main_view = mainView self:init() @@ -13,15 +13,12 @@ end function M:init() PlayerInfoView.init(self) - self._tex_score = self._view:GetChild("info"):GetChild("tex_score1") - self._tex_score2 = self._view:GetChild("info"):GetChild("tex_score2") - self._ct_score = self._view:GetChild("info"):GetController("score") end -function M:ShowInteraction(type,str) +function M:ShowInteraction(type, str) if type == 3 then Voice.DownLoad(str, function(clip) - if (clip ) then + if (clip) then self:ShowMaskVoice(clip.length) GameApplication.Instance:PlayVoice(clip) end @@ -30,47 +27,25 @@ function M:ShowInteraction(type,str) self:SetChat(str) elseif type == 2 then local chat_index = tonumber(str) - self._main_view:PlayChatSound(self._player.self_user.sex,chat_index) + self._main_view:PlayChatSound(self._player.self_user.sex, chat_index) local language, index = self._main_view:GetChatMsgLanguage(chat_index) self:SetChat(self._main_view.Fix_Msg_Chat[index]) elseif type == 1 then - self:SetBiaoqing("ui://Chat/"..str) + self:SetBiaoqing("ui://Chat/" .. str) end end function M:UpdateRemainCard(card_num, hide) if hide then - self._view:GetController("show_remain").selectedIndex = 0 + self._view:GetController("show_remain").selectedIndex = 0 else - self._view:GetController("show_remain").selectedIndex = 1 + self._view:GetController("show_remain").selectedIndex = 1 end self._view:GetChild("com_remain"):GetChild("tex_remain").text = card_num end function M:FillData(player) PlayerInfoView.FillData(self, player) - self:UpdateScore(player.total_score) -end - -function M:UpdateScore() - local score = self._player.total_score - local room = DataManager.CurrenRoom - if room:checkHpNonnegative() then - score = d2ad(self._player.cur_hp) - end - if not score then - score = 0 - end - if score < 0 then - self._ct_score.selectedIndex = 1 - self._tex_score2.text = score - else - self._ct_score.selectedIndex = 0 - if not room:checkHpNonnegative() then - score = "+" .. score - end - self._tex_score.text = score - end end return M diff --git a/lua_probject/extend_project/extend/majiang/changsha/MJPlayerCardInfoView.lua b/lua_probject/extend_project/extend/majiang/changsha/MJPlayerCardInfoView.lua index f685a679..f9991009 100644 --- a/lua_probject/extend_project/extend/majiang/changsha/MJPlayerCardInfoView.lua +++ b/lua_probject/extend_project/extend/majiang/changsha/MJPlayerCardInfoView.lua @@ -2,14 +2,14 @@ local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView") local M = {} -function M.new(view,mainView) - setmetatable(M, {__index = MJPlayerCardInfoView}) - local self = setmetatable({},{__index = M}) - self.class = "PlayerCardInfoView" - self._view = view - self._mainView = mainView - self:init() - return self +function M.new(view, mainView) + setmetatable(M, { __index = MJPlayerCardInfoView }) + local self = setmetatable({}, { __index = M }) + self.class = "PlayerCardInfoView" + self._view = view + self._mainView = mainView + self:init() + return self end local function CardPos(obj, area, oder, loc, offset) @@ -32,85 +32,86 @@ local function CardPos(obj, area, oder, loc, offset) end function M:UpdateHandCard(getcard, mp, opcard) - -- mp 是否明牌 - -- 如果不明牌,但是有 opcard 表示是起手胡 - getcard = getcard or false - mp = mp or false - local handcard_list = self._mask_data["handcard_list"] - local oder = handcard_list["oder"] - local _player = self._player - local comp_back = handcard_list["comp_back"] - local comp = handcard_list["comp"] - local outcard_list = self._mask_data["outcard_list"] - local card = outcard_list["card"] + -- mp 是否明牌 + -- 如果不明牌,但是有 opcard 表示是起手胡 + getcard = getcard or false + mp = mp or false + local handcard_list = self._mask_data["handcard_list"] + local oder = handcard_list["oder"] + local _player = self._player + local comp_back = handcard_list["comp_back"] + local comp = handcard_list["comp"] + local outcard_list = self._mask_data["outcard_list"] + local card = outcard_list["card"] - self._area_handcard_list:RemoveChildren(0, -1, true) - local opnum = opcard and #opcard or -1 - if not mp and opnum > -1 then - -- 起手胡板牌记录,手牌变化两次后,板牌收回 - self.__show_qs_hu_times = 1 - self.__qs_hu_cards = opcard - elseif self.__qs_hu_cards and opnum == -1 and self.__show_qs_hu_times > 0 then - self.__show_qs_hu_times = self.__show_qs_hu_times - 1 - opcard = self.__qs_hu_cards - opnum = #opcard + self._area_handcard_list:RemoveChildren(0, -1, true) + local opnum = opcard and #opcard or -1 + if not mp and opnum > -1 then + -- 起手胡板牌记录,手牌变化两次后,板牌收回 + self.__show_qs_hu_times = 1 + self.__qs_hu_cards = opcard + elseif self.__qs_hu_cards and opnum == -1 and self.__show_qs_hu_times > 0 then + self.__show_qs_hu_times = self.__show_qs_hu_times - 1 + opcard = self.__qs_hu_cards + opnum = #opcard + end + local loc = 0 + print("===============================UpdateHandCard", getcard, mp, opcard, comp) + if not mp then + local comp_back = handcard_list["comp_back"] + if self._current_card_type == 2 then + comp_back = comp_back .. "_3d" end - local loc = 0 - if not mp then - local comp_back = handcard_list["comp_back"] - if self._current_card_type == 2 then - comp_back = comp_back.."_3d" - end - for i = 0, _player.hand_left_count -1 do - local obj - local offset = getcard and (i == _player.hand_left_count - 1 and 15 or 0) - if i < opnum then - obj = UIPackage.CreateObject("Main_Majiang", comp) - self:fillCard(obj, card, opcard[i + 1]) - else - obj = UIPackage.CreateObject("Main_Majiang", comp_back) - end - if opnum ~= -1 then - loc = CardPos(obj, self._area_handcard_list, oder, loc, offset) - else - ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset) - end - --改变左右两边的手牌的x值 - if self._current_card_type == 2 and (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then - obj.x = i * -7.0 - end - if (oder == AreaOderType.down_up) then - self._area_handcard_list:AddChildAt(obj, 0) - else - self._area_handcard_list:AddChild(obj) - end - end - else - local outcard_list = self._mask_data["outcard_list"] - local comp = handcard_list["comp"] - local card = outcard_list["card"] - --print("comp"..comp) - -- print(vardump(_player.card_list)) - - if self._current_card_type == 2 then - comp = comp.."_3d" - end - for i = 0, #_player.card_list -1 do - local obj = UIPackage.CreateObject("Main_Majiang", comp) - self:fillCard(obj,card,_player.card_list[i+1]) - local offset = getcard and (i == _player.hand_left_count - 1 and 15 or 0) - ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset) - --改变左右两边的手牌的x值 - if self._current_card_type == 2 and (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then - obj.x = i * -7 - end - if (oder == AreaOderType.down_up) then - self._area_handcard_list:AddChildAt(obj, 0) - else - self._area_handcard_list:AddChild(obj) - end - end + for i = 0, _player.hand_left_count - 1 do + local obj + local offset = getcard and (i == _player.hand_left_count - 1 and 15 or 0) + if i < opnum then + obj = UIPackage.CreateObject("Main_Majiang", comp) + self:fillCard(obj, card, opcard[i + 1]) + else + obj = UIPackage.CreateObject("Main_Majiang", comp_back) + end + if opnum ~= -1 then + loc = CardPos(obj, self._area_handcard_list, oder, loc, offset) + else + ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset) + end + --改变左右两边的手牌的x值 + if self._current_card_type == 2 and (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then + obj.x = i * -7.0 + end + if (oder == AreaOderType.down_up) then + self._area_handcard_list:AddChildAt(obj, 0) + else + self._area_handcard_list:AddChild(obj) + end end + else + local outcard_list = self._mask_data["outcard_list"] + local comp = handcard_list["comp"] + local card = outcard_list["card"] + --print("comp"..comp) + -- print(vardump(_player.card_list)) + + if self._current_card_type == 2 then + comp = comp .. "_3d" + end + for i = 0, #_player.card_list - 1 do + local obj = UIPackage.CreateObject("Main_Majiang", comp) + self:fillCard(obj, card, _player.card_list[i + 1]) + local offset = getcard and (i == _player.hand_left_count - 1 and 15 or 0) + ViewUtil.CardPos(obj, self._area_handcard_list, oder, i, offset) + --改变左右两边的手牌的x值 + if self._current_card_type == 2 and (oder == AreaOderType.down_up or oder == AreaOderType.up_down) then + obj.x = i * -7 + end + if (oder == AreaOderType.down_up) then + self._area_handcard_list:AddChildAt(obj, 0) + else + self._area_handcard_list:AddChild(obj) + end + end + end end -return M \ No newline at end of file +return M diff --git a/lua_probject/extend_project/extend/majiang/lichuan/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/lichuan/ExtendConfig.lua index 7a351cc3..172308fb 100644 --- a/lua_probject/extend_project/extend/majiang/lichuan/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/lichuan/ExtendConfig.lua @@ -109,6 +109,7 @@ function M:FillRoomData(s2croom) p.fz_list[#p.fz_list + 1] = fz end if not playing and room.curren_round > 0 then + print("=======================在此进入") self.GetGameController():PlayerReady() end end diff --git a/lua_probject/extend_project/extend/majiang/nancheng/ExtendConfig.lua b/lua_probject/extend_project/extend/majiang/nancheng/ExtendConfig.lua index 1e9a00cb..2294d676 100644 --- a/lua_probject/extend_project/extend/majiang/nancheng/ExtendConfig.lua +++ b/lua_probject/extend_project/extend/majiang/nancheng/ExtendConfig.lua @@ -4,7 +4,7 @@ local EXGameInfo = import(".EXGameInfo") local EXMainView = import(".EXMainView") local EXGameController = import(".EXGameController") local EXRoomConfig = import(".EXRoomConfig") -local EXPlayBackView =import(".EXPlayBackView") +local EXPlayBackView = import(".EXPlayBackView") local MJRoom = require("main.majiang.MJRoom") local ExtendConfig = {} @@ -13,14 +13,14 @@ local M = ExtendConfig function ExtendConfig.new() - setmetatable(M, {__index = IExtendConfig}) - local self = setmetatable({}, {__index = M}) - self.class = "ExtendConfig" - self.extend_id = 33 - self._viewMap = {} - self._viewMap[ViewManager.View_Main] = EXMainView - self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView - return self + setmetatable(M, { __index = IExtendConfig }) + local self = setmetatable({}, { __index = M }) + self.class = "ExtendConfig" + self.extend_id = 33 + self._viewMap = {} + self._viewMap[ViewManager.View_Main] = EXMainView + self._viewMap[ViewManager.View_PlayBack] = EXPlayBackView + return self end --卸载资源 @@ -45,30 +45,30 @@ end local _ctr_game = nil function M:GetGameController() - if _ctr_game == nil then - _ctr_game = EXGameController.new() - end - return _ctr_game + if _ctr_game == nil then + _ctr_game = EXGameController.new() + end + return _ctr_game end function M:NewRoom() return MJRoom.new() end -function M:FillRoomConfig(room,_config) +function M:FillRoomConfig(room, _config) room.room_config = EXRoomConfig.new(_config) end function M:FillRoomData(s2croom) - local room = DataManager.CurrenRoom - + local room = DataManager.CurrenRoom - local reload = s2croom["reload"] + + local reload = s2croom["reload"] local _tableInfo = s2croom["tableInfo"] - + local _config = _tableInfo["config"] - - pt(_config) + + pt(_config) room.room_config = EXRoomConfig.new(_config) local playerList = _tableInfo["playerData"] @@ -77,10 +77,10 @@ function M:FillRoomData(s2croom) if (reload) then local _reloadInfo = s2croom["reloadInfo"] - local _hand_card = _reloadInfo["hand_card"] + local _hand_card = _reloadInfo["hand_card"] room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) - + local active_seat = _reloadInfo["active_seat"] local bank_seat = _reloadInfo["banker_seat"] local playing = _reloadInfo["playing"] @@ -91,24 +91,25 @@ function M:FillRoomData(s2croom) room.curren_outcard_seat = _reloadInfo["curren_outcard_seat"] room.last_outcard_seat = last_outcard_seat room.playing = playing - for i=1,#_info_list do - local tem = _info_list[i] - local playerid = tem["playerid"] - local p = room:GetPlayerById(playerid) - local outcard_list = tem["outcard_list"] - p.outcard_list = outcard_list - p.total_score = tem["score"] - p.hand_left_count = tem["card_count"] - p.piao_niao = tem["piao_niao"] or 0 - local opcard = tem["opcard"] - for k=1,#opcard do - local op = opcard[k] - local fz = {} - fz.type = op["type"] - fz.card = op["card"] - p.fz_list[#p.fz_list+1] = fz - end + for i = 1, #_info_list do + local tem = _info_list[i] + local playerid = tem["playerid"] + local p = room:GetPlayerById(playerid) + local outcard_list = tem["outcard_list"] + p.outcard_list = outcard_list + p.total_score = tem["score"] + p.hand_left_count = tem["card_count"] + p.piao_niao = tem["piao_niao"] or 0 + local opcard = tem["opcard"] + for k = 1, #opcard do + local op = opcard[k] + local fz = {} + fz.type = op["type"] + fz.card = op["card"] + p.fz_list[#p.fz_list + 1] = fz + end if not playing and room.curren_round > 0 then + print("=======================================自动开始") self.GetGameController():PlayerReady() end end @@ -131,7 +132,7 @@ function M:FillPlayBackData(pd_data) room.curren_round = _tableInfo["round"] local _info_list = _tableInfo["playerData"] - for i = 1,#_info_list do + for i = 1, #_info_list do local _jp = _info_list[i] local p = room:NewPlayer() p.seat = _jp["seat"] @@ -146,15 +147,15 @@ function M:FillPlayBackData(pd_data) -- p.self_user = DataManager.SelfUser -- else if p.seat == 1 then room.self_player = p end - local u = User.new() - u.account_id = pid - p.self_user = u - u.nick_name = _jp["nick"] - u.head_url = _jp["portrait"] - u.sex = _jp["sex"] + local u = User.new() + u.account_id = pid + p.self_user = u + u.nick_name = _jp["nick"] + u.head_url = _jp["portrait"] + u.sex = _jp["sex"] -- end p.self_user.host_ip = p.self_user.host_ip - local _hand_card = _jp["hand_card"] + local _hand_card = _jp["hand_card"] p.card_list = _hand_card --room.self_player.card_list = _hand_card table.sort(_hand_card, ViewUtil.HandCardSort) @@ -170,4 +171,4 @@ function M:FillPlayBackData(pd_data) room.cmdList = pd_data["cmdList"] end -return M \ No newline at end of file +return M diff --git a/lua_probject/main_project/main/majiang/MJMainView.lua b/lua_probject/main_project/main/majiang/MJMainView.lua index 621fb687..392ceb6b 100644 --- a/lua_probject/main_project/main/majiang/MJMainView.lua +++ b/lua_probject/main_project/main/majiang/MJMainView.lua @@ -4,15 +4,15 @@ local TableBG = require("Game.Data.TableBG") local MJSettingView = import(".MJSettingViewNew") local MJMainRightPanelView = import(".MJMainRightPanelView") - local bg_config = { - {id = 1, url = "base/main_majiang/bg/bg1", thumb = "ui://Main_Majiang/b01"}, - {id = 2, url = "base/main_majiang/bg/bg2", thumb = "ui://Main_Majiang/b02"}, - {id = 3, url = "base/main_majiang/bg/bg3", thumb = "ui://Main_Majiang/b03"} +local bg_config = { + { id = 1, url = "base/main_majiang/bg/bg1", thumb = "ui://Main_Majiang/b01" }, + { id = 2, url = "base/main_majiang/bg/bg2", thumb = "ui://Main_Majiang/b02" }, + { id = 3, url = "base/main_majiang/bg/bg3", thumb = "ui://Main_Majiang/b03" } } local M = {} -setmetatable(M,{__index = MainView}) +setmetatable(M, { __index = MainView }) local default_bg = 1 function M:InitView(url, use_custom_bg) @@ -28,8 +28,7 @@ function M:InitView(url, use_custom_bg) self._room.card_type = DataManager.CardTypeList[tostring(self._room.game_id)] or 1 UIPackage.AddPackage("base/main_majiang/ui/Main_Majiang") - - MainView.InitView(self,url) + MainView.InitView(self, url) local _view = self._view self._cursor = UIPackage.CreateObjectFromURL("ui://Main_Majiang/Ani_play_bj") if not use_custom_bg then @@ -40,10 +39,10 @@ function M:InitView(url, use_custom_bg) local _cardbox = _view:GetChild("cardbox") - self._zhuanpanCtr=_cardbox:GetController("zuozi") + self._zhuanpanCtr = _cardbox:GetController("zuozi") self._ctr_cardbox = _cardbox:GetController("c1") self._tex_leftTime = _cardbox:GetChild("tex_leftnum") - + if self._room.card_type == 2 then self:Change3d(true) @@ -52,42 +51,41 @@ function M:InitView(url, use_custom_bg) end local rightpanel = self._view:GetChild("com_roominfo") - if self._rightPanelView ~= nil then + if self._rightPanelView ~= nil then self._rightPanelView:Destroy() end - self._rightPanelView = MJMainRightPanelView.new(self, rightpanel) - - --local tempdsaf=self._view:GetChild("btn_back_jiesan") - --tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false) - - --print("2222222222222222222222") - --print(self._view:GetChild("btn_back_jiesan").displayObject.gameObject.name) - --self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false) - --local temp111=self._view:GetChild("btn_back_jiesan").displayObject.gameObject - --temp111:SetActive(false) - self._view:GetChild("btn_back_jiesan").onClick:Set(function () + self._rightPanelView = MJMainRightPanelView.new(self, rightpanel) + + --local tempdsaf=self._view:GetChild("btn_back_jiesan") + --tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false) + + --print("2222222222222222222222") + --print(self._view:GetChild("btn_back_jiesan").displayObject.gameObject.name) + --self._view:GetChild("btn_back_jiesan").displayObject.gameObject:SetActive(false) + --local temp111=self._view:GetChild("btn_back_jiesan").displayObject.gameObject + --temp111:SetActive(false) + self._view:GetChild("btn_back_jiesan").onClick:Set(function() if self.dismiss_room_cd_time > 0 then ViewUtil.ErrorTip(nil, "您还处于解散冷却时间当中,请稍后重试!") else local _gamectr = ControllerManager.GetController(GameController) _gamectr:AskDismissRoom() end - end) self._tex_LeftCard = _view:GetChild("remaining_card") - + self._player_card_info = {} local _player_card_info = self._player_card_info for i = 1, _room.room_config.people_num do local tem = _view:GetChild("player_card_info" .. i) - _player_card_info[i] = self:NewMJPlayerCardInfoView(tem,i) + _player_card_info[i] = self:NewMJPlayerCardInfoView(tem, i) end local list = _room.player_list - for i=1,#list do + for i = 1, #list do local p = list[i] local info = _player_card_info[self:GetPos(p.seat)] info:SetPlayer(p) @@ -96,143 +94,130 @@ function M:InitView(url, use_custom_bg) local list = _room.player_list local readyNum = 0 - for i=1,#list do + for i = 1, #list do local p = list[i] if p.ready then readyNum = readyNum + 1 end end - for i=1,#_room.player_list do - + for i = 1, #_room.player_list do local p = _room.player_list[i] - local zi,icon = self:GetPosString(p.seat) + local zi, icon = self:GetPosString(p.seat) if self._room.card_type == 2 then - _cardbox:GetChild("3d_direction"..self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/"..icon + _cardbox:GetChild("3d_direction" .. self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/" .. icon end - - _cardbox:GetChild("direction"..self:GetIndex(self:GetPos(p.seat))).text = zi + + _cardbox:GetChild("direction" .. self:GetIndex(self:GetPos(p.seat))).text = zi end - self._ctr_action = _view:GetController("action") + self._ctr_action = _view:GetController("action") if _room.banker_seat == _room.self_player.seat and readyNum == _room.room_config.people_num then --self._ctr_action.selectedIndex = 2 elseif not _room.self_player.ready then - local round=DataManager.CurrenRoom.room_config.config.times or 1 - local xpconfig=DataManager.CurrenRoom.room_config.config.xi_pai - if xpconfig then - if round>1 then - self._ctr_action.selectedIndex = 1 - else - self._ctr_action.selectedIndex = 2 - end - - else - self._ctr_action.selectedIndex = 1 - end + local round = DataManager.CurrenRoom.room_config.config.times or 1 + local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai + if xpconfig then + if round > 1 then + self._ctr_action.selectedIndex = 1 + else + self._ctr_action.selectedIndex = 2 + end + else + self._ctr_action.selectedIndex = 1 + end else self._ctr_action.selectedIndex = 0 end - - self:InitXiPai() - self:InitXiPai1() + + self:InitXiPai() + self:InitXiPai1() end - function M:InitXiPai() - self._xipaiPanel = UIPackage.CreateObjectFromURL("ui://Common/panel_handanim") - self._xipaiPanel.visible=false - self._root_view:AddChild(self._xipaiPanel) - - local offset = get_offset(self._full_offset) + self._xipaiPanel = UIPackage.CreateObjectFromURL("ui://Common/panel_handanim") + self._xipaiPanel.visible = false + self._root_view:AddChild(self._xipaiPanel) + + local offset = get_offset(self._full_offset) self._xipaiPanel.width = GRoot.inst.width - (offset * 2) self._xipaiPanel.height = GRoot.inst.height self._xipaiPanel.x = offset - - self._handAnimCtr=self._xipaiPanel:GetController("anim") - self._handAnimCtr.selectedIndex=0 - --self:PlayXiPai() + + self._handAnimCtr = self._xipaiPanel:GetController("anim") + self._handAnimCtr.selectedIndex = 0 + --self:PlayXiPai() end - function M:InitXiPai1() - self._xipaiPanel1 = UIPackage.CreateObjectFromURL("ui://Common/panel_handanim02") - self._xipaiPanel1.visible=false - self._root_view:AddChild(self._xipaiPanel1) - - local offset = get_offset(self._full_offset) + self._xipaiPanel1 = UIPackage.CreateObjectFromURL("ui://Common/panel_handanim02") + self._xipaiPanel1.visible = false + self._root_view:AddChild(self._xipaiPanel1) + + local offset = get_offset(self._full_offset) self._xipaiPanel1.width = GRoot.inst.width - (offset * 2) self._xipaiPanel1.height = GRoot.inst.height self._xipaiPanel1.x = offset - - self._handAnimCtr1=self._xipaiPanel1:GetController("anim1") - self._handAnimCtr1.selectedIndex=0 + + self._handAnimCtr1 = self._xipaiPanel1:GetController("anim1") + self._handAnimCtr1.selectedIndex = 0 end - function M:PlayXiPai(xipaiCallBack) - if self._xipaiPanel then - coroutine.start(function() - self._xipaiPanel.visible=true - self._xipaiPanel:GetTransition("XiPai"):Play() - self._handAnimCtr.selectedIndex=1 - coroutine.wait(3) - self._handAnimCtr.selectedIndex=0 - self._xipaiPanel.visible=false - if xipaiCallBack then - xipaiCallBack() - end - end) - - - end + if self._xipaiPanel then + coroutine.start(function() + self._xipaiPanel.visible = true + self._xipaiPanel:GetTransition("XiPai"):Play() + self._handAnimCtr.selectedIndex = 1 + coroutine.wait(3) + self._handAnimCtr.selectedIndex = 0 + self._xipaiPanel.visible = false + if xipaiCallBack then + xipaiCallBack() + end + end) + end end function M:PlayXiPai1(xipaiCallBack) - if self._xipaiPanel1 then - coroutine.start(function() - self._xipaiPanel1.visible=true - self._xipaiPanel1:GetTransition("XiPai"):Play() - self._handAnimCtr1.selectedIndex=1 - coroutine.wait(3) - self._handAnimCtr1.selectedIndex=0 - self._xipaiPanel1.visible=false - if xipaiCallBack then - xipaiCallBack() - end - end) - - - end + if self._xipaiPanel1 then + coroutine.start(function() + self._xipaiPanel1.visible = true + self._xipaiPanel1:GetTransition("XiPai"):Play() + self._handAnimCtr1.selectedIndex = 1 + coroutine.wait(3) + self._handAnimCtr1.selectedIndex = 0 + self._xipaiPanel1.visible = false + if xipaiCallBack then + xipaiCallBack() + end + end) + end end - function M:EventInit() - MainView.EventInit(self) + MainView.EventInit(self) end function M:Change3d(flag) - local _room = self._room local _view = self._view local _cardbox = _view:GetChild("cardbox") - - for i=1,#_room.player_list do - local p = _room.player_list[i] - local zi,icon = self:GetPosString(p.seat) - if self._room.card_type == 2 then - _cardbox:GetChild("3d_direction"..self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/"..icon - end - - _cardbox:GetChild("direction"..self:GetIndex(self:GetPos(p.seat))).text = zi - end - + for i = 1, #_room.player_list do + local p = _room.player_list[i] + local zi, icon = self:GetPosString(p.seat) + if self._room.card_type == 2 then + _cardbox:GetChild("3d_direction" .. self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/" .. icon + end + + _cardbox:GetChild("direction" .. self:GetIndex(self:GetPos(p.seat))).text = zi + end + -- 如果要切换3d牌桌的cardbox位置及上方文字(剩余牌,回合数)显示不错乱,需要做以下改动 -- 取消文字组合的3d控制器的位置, 并设置对cardbox的关联,左左,顶顶 if flag == true then - if _view:GetController("3d") ~= nil then _view:GetController("3d").selectedIndex = 1 _cardbox.x = (_view.width - _cardbox.width) * 0.5 @@ -245,7 +230,7 @@ function M:Change3d(flag) _view:GetController("3d").selectedIndex = 0 _cardbox.x = (_view.width - _cardbox.width) * 0.5 end - + _cardbox:GetController("3d").selectedIndex = 0 _cardbox.x = (_view.width - _cardbox.width) * 0.5 end @@ -260,7 +245,7 @@ end -- self:Change3d(DataManager.CurrenRoom.card_type == 2) -- self:ReloadRoom() - + -- for i = 1, #self._room.player_list do -- local p = self._room.player_list[i] -- local card_info = self._player_card_info[self:GetPos(p.seat)] @@ -285,9 +270,9 @@ function M:NewSettingView() -- gear:Apply() -- settingView.Change3d = function() end - settingView:FillBgSection(function(url,index) + settingView:FillBgSection(function(url, index) LoadGameBg(url, self._root_view) - self._zhuanpanCtr.selectedIndex=index-1 + self._zhuanpanCtr.selectedIndex = index - 1 end, self._room.game_id, 1, bg_config) settingView.onChangeCardCallback:Add(function() @@ -316,30 +301,29 @@ function M:GetIndex(seat) end function M:GetPosString(seat) - if DataManager.CurrenRoom.room_config.people_num == 4 then if seat == 1 then - return "东","dir_1" + return "东", "dir_1" elseif seat == 2 then - return "南","dir_2" - elseif seat == 3 then - return "西","dir_3" + return "南", "dir_2" + elseif seat == 3 then + return "西", "dir_3" elseif seat == 4 then - return "北","dir_4" + return "北", "dir_4" end elseif DataManager.CurrenRoom.room_config.people_num == 3 then if seat == 1 then - return "东","dir_1" + return "东", "dir_1" elseif seat == 2 then - return "南","dir_2" + return "南", "dir_2" elseif seat == 3 then - return "西","dir_3" + return "西", "dir_3" end elseif DataManager.CurrenRoom.room_config.people_num == 2 then if seat == 1 then - return "东","dir_1" + return "东", "dir_1" elseif seat == 2 then - return "西","dir_3" + return "西", "dir_3" end end end @@ -347,7 +331,7 @@ end function M:SetCardBoxPosition() local _room = self._room for i = 1, _room.room_config.people_num do - local tex = self._view:GetChild("cardbox"):GetChild("direction"..i) + local tex = self._view:GetChild("cardbox"):GetChild("direction" .. i) local index = _room.self_player.seat + i - 1 index = index > 4 and index - 4 or index tex.text = self._gamectr:GetPosString(index) @@ -361,11 +345,11 @@ function M:markOutCards(showTip, data) for j = 1, #p.outcard_list do local card = p.outcard_list[j] if card == data then - for k = 1, #p.outcard_list do + for k = 1, #p.outcard_list do local obj = info:GetOutCardByIndex(k) if obj.data == card then obj:GetController("gray").selectedIndex = showTip and 1 or 0 - end + end end end end @@ -373,20 +357,20 @@ function M:markOutCards(showTip, data) end function M:OnPlayerEnter(...) - MainView.OnPlayerEnter(self,...) - local arg = {...} + MainView.OnPlayerEnter(self, ...) + local arg = { ... } local p = arg[1] local info = self._player_card_info[self:GetPos(p.seat)] info:SetPlayer(p) info:FillData() end -function M:OnPlayerReady( ... ) - local arg = {...} +function M:OnPlayerReady(...) + local arg = { ... } local p = arg[1] local _room = self._room local _view = self._view - + local _player_info = self._player_info if p.seat == _room.self_player.seat then self._ctr_action.selectedIndex = 0 @@ -402,38 +386,36 @@ function M:OnPlayerReady( ... ) if readyNum == _room.room_config.people_num then local _cardbox = _view:GetChild("cardbox") - for i=1,#_room.player_list do - + for i = 1, #_room.player_list do local p = _room.player_list[i] - local zi,icon = self:GetPosString(p.seat) - _cardbox:GetChild("3d_direction"..self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/"..icon - _cardbox:GetChild("direction"..self:GetIndex(self:GetPos(p.seat))).text = zi + local zi, icon = self:GetPosString(p.seat) + _cardbox:GetChild("3d_direction" .. self:GetIndex(self:GetPos(p.seat))).icon = "ui://MajiangCard3d/" .. icon + _cardbox:GetChild("direction" .. self:GetIndex(self:GetPos(p.seat))).text = zi end end - + if _room.banker_seat == _room.self_player.seat and readyNum == _room.room_config.people_num then if self._state.selectedIndex == 2 then - local _gamectr = ControllerManager.GetController(GameController) + local _gamectr = ControllerManager.GetController(GameController) _gamectr:StartGame() end - --self._ctr_action.selectedIndex = 2 + --self._ctr_action.selectedIndex = 2 elseif not _room.self_player.ready then - --self._ctr_action.selectedIndex = 1 - local round=DataManager.CurrenRoom.room_config.config.times or 1 - local xpconfig=DataManager.CurrenRoom.room_config.config.xi_pai - if xpconfig then - if round>1 then - self._ctr_action.selectedIndex = 1 - else - self._ctr_action.selectedIndex = 2 - end - - else - self._ctr_action.selectedIndex = 1 - end + --self._ctr_action.selectedIndex = 1 + local round = DataManager.CurrenRoom.room_config.config.times or 1 + local xpconfig = DataManager.CurrenRoom.room_config.config.xi_pai + if xpconfig then + if round > 1 then + self._ctr_action.selectedIndex = 1 + else + self._ctr_action.selectedIndex = 2 + end + else + self._ctr_action.selectedIndex = 1 + end else - self._ctr_action.selectedIndex = 0 + self._ctr_action.selectedIndex = 0 end end @@ -474,42 +456,42 @@ function M:CountCardLeftNum(card) return count end -function M:OnPlayerLeave( ... ) +function M:OnPlayerLeave(...) MainView.OnPlayerLeave(self, ...) local _room = self._room if _room.banker_seat == _room.self_player.seat then - self._ctr_action.selectedIndex = 0 + self._ctr_action.selectedIndex = 0 end end function M:PlayerChangeLineState() - local isOutCard = true - local str = "玩家 " - for _ , player in ipairs(self._room.player_list) do - if player.line_state == 0 then - isOutCard = false - -- str = str .. self._gamectr:GetPosString(player.seat) .. "、" + local isOutCard = true + local str = "玩家 " + for _, player in ipairs(self._room.player_list) do + if player.line_state == 0 then + isOutCard = false + -- str = str .. self._gamectr:GetPosString(player.seat) .. "、" + end end - end - -- if not isOutCard then - -- str = str.sub(str, 1, string.len(str) - string.len("、")) - -- str = str .. " 正在赶来,请稍等" - -- if self._room.curren_round > 0 then - -- self._waitingView = ModalWaitingView.new(self._view, str) - -- end - -- else - -- if self._waitingView then - -- self._waitingView:CloseWaitingView() - -- end - -- end + -- if not isOutCard then + -- str = str.sub(str, 1, string.len(str) - string.len("、")) + -- str = str .. " 正在赶来,请稍等" + -- if self._room.curren_round > 0 then + -- self._waitingView = ModalWaitingView.new(self._view, str) + -- end + -- else + -- if self._waitingView then + -- self._waitingView:CloseWaitingView() + -- end + -- end self._player_card_info[1]._area_handcard_list.touchable = isOutCard end -function M:NewMJPlayerCardInfoView(view,index) - if index == 1 then - return MJPlayerSelfCardInfoView.new(view,self) - end - return MJPlayerCardInfoView.new(view,self) +function M:NewMJPlayerCardInfoView(view, index) + if index == 1 then + return MJPlayerSelfCardInfoView.new(view, self) + end + return MJPlayerCardInfoView.new(view, self) end function M:RemoveCursor() @@ -523,7 +505,7 @@ function M:Destroy() UIPackage.RemovePackage("base/main_majiang/ui/Main_Majiang") MainView.Destroy(self) self._cursor:Dispose() - self._xipaiPanel:Dispose() + self._xipaiPanel:Dispose() end local majiang_asset_path = "base/main_majiang/sound/" @@ -535,14 +517,14 @@ function M:PlayMJMusic(path) ViewUtil.PlayMuisc(self.asset_group, majiang_asset_path .. path) end -function M:PlaySound(group,sex,path) +function M:PlaySound(group, sex, path) local sex_path = ViewUtil.Sex_Chat[sex] - local path1 = majiang_asset_path .. string.format("%s/%s.mp3",sex_path,path) - ViewUtil.PlaySound(group,path1) + local path1 = majiang_asset_path .. string.format("%s/%s.mp3", sex_path, path) + ViewUtil.PlaySound(group, path1) end function M:GetPrefix() return get_majiang_prefix(DataManager.CurrenRoom.game_id) end -return M \ No newline at end of file +return M diff --git a/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_atlas0.png b/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_atlas0.png index 44d2d5a3..32b651d2 100644 Binary files a/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_atlas0.png and b/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_atlas0.png differ diff --git a/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_atlas0_1.png b/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_atlas0_1.png index d093bd54..6e5b6efc 100644 Binary files a/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_atlas0_1.png and b/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_atlas0_1.png differ diff --git a/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_atlas0_2.png b/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_atlas0_2.png index 4200ac1f..dcf05514 100644 Binary files a/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_atlas0_2.png and b/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_atlas0_2.png differ diff --git a/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_atlas0_3.png b/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_atlas0_3.png index 66740d19..52c1885f 100644 Binary files a/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_atlas0_3.png and b/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_atlas0_3.png differ diff --git a/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_fui.bytes b/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_fui.bytes index 776e2097..772e56c1 100644 Binary files a/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_fui.bytes and b/wb_unity_pro/Assets/ART/base/main_majiang/ui/main_majiang_fui.bytes differ diff --git a/wb_unity_pro/Assets/ART/extend/majiang/nanCheng/ui/Info_MJ_NanCheng_fui.bytes b/wb_unity_pro/Assets/ART/extend/majiang/nanCheng/ui/Info_MJ_NanCheng_fui.bytes index d5afc314..24797202 100644 Binary files a/wb_unity_pro/Assets/ART/extend/majiang/nanCheng/ui/Info_MJ_NanCheng_fui.bytes and b/wb_unity_pro/Assets/ART/extend/majiang/nanCheng/ui/Info_MJ_NanCheng_fui.bytes differ