未完成,上传保存

master
罗家炜 2025-04-02 19:03:26 +08:00
parent 948bd04300
commit 8515e03703
14 changed files with 1176 additions and 915 deletions

View File

@ -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
--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
if t and t > 0 then
p:IsShowTGTips(true, t)
else
end
end
ControllerManager.enterPlayerData=nil
end
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
@ -232,18 +232,18 @@ function M:InitView(url, isHideIpAdds)
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_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_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(
@ -670,26 +662,23 @@ function M:EventInit()
end
)
_gamectr:AddEventListener(
_gamectr:AddEventListener(
GameEvent.TupGuanOpen,
function(...)
--print("刷新托管数据=====")
local arg = {...}
local p = arg[1]
local info = self._player_info[self:GetPos(p.seat)]
--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
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,29 +793,29 @@ 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
@ -838,7 +828,7 @@ function M:OnPlayerReady(...)
end
function M:OnUpdateInfo(...)
local arg = {...}
local arg = { ... }
local p = arg[1]
local t = arg[2]
-- 托管状态变化
@ -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
if pcall(func) then
else
self._gamectr = ControllerManager.GetController(GameController)
if self._gamectr then
self._gamectr:ResetConnect()
end
end
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

View File

@ -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

View File

@ -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

View File

@ -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
-- 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
end
local loc = 0
print("===============================UpdateHandCard", getcard, mp, opcard, comp)
if not mp then
local comp_back = handcard_list["comp_back"]
local comp = handcard_list["comp"]
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))
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
if self._current_card_type == 2 then
comp = comp .. "_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.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

View File

@ -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

View File

@ -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"]
@ -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,12 +147,12 @@ 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"]

View File

@ -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,7 +39,7 @@ 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")
@ -52,27 +51,26 @@ 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)
self._rightPanelView = MJMainRightPanelView.new(self, rightpanel)
--local tempdsaf=self._view:GetChild("btn_back_jiesan")
--tempdsaf:GetChild("n3").displayObject.gameObject:SetActive(false)
--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 ()
--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)
@ -83,11 +81,11 @@ function M:InitView(url, use_custom_bg)
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)
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)
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)
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)
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
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
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
_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
@ -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"
return "", "dir_2"
elseif seat == 3 then
return "西","dir_3"
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)
@ -373,16 +357,16 @@ 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
@ -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,10 +517,10 @@ 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()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.0 MiB

After

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 553 KiB

After

Width:  |  Height:  |  Size: 966 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 894 KiB

After

Width:  |  Height:  |  Size: 481 KiB