未完成,上传保存

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
@ -37,23 +37,22 @@ end
function M:SetTuoGuanState()
--printlog("初始化设置托管状态")
if ControllerManager.enterPlayerData and #ControllerManager.enterPlayerData>0 then
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)]
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 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)
if t and t > 0 then
p:IsShowTGTips(true, t)
else
end
end
ControllerManager.enterPlayerData=nil
ControllerManager.enterPlayerData = nil
end
end
@ -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
@ -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
@ -350,20 +350,18 @@ function M:InitView(url, isHideIpAdds)
-- 显示牌友圈助手
if self._room.group_id ~= 0 and not self._hide_assist then
local bShow = true
local l_groups = DataManager.groups
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()
@ -382,11 +380,6 @@ function M:InitView(url, isHideIpAdds)
)
end
end--]]
end
function M:continue_game(continue)
@ -453,7 +446,6 @@ function M:ShowFGAssist()
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
@ -674,22 +666,19 @@ function M:EventInit()
GameEvent.TupGuanOpen,
function(...)
--print("刷新托管数据=====")
local arg = {...}
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])
info:IsShowTGTips(arg[2], arg[3])
end
if info and info.SetShowTGTips then
info:SetShowTGTips(arg[2],arg[3])
info:SetShowTGTips(arg[2], arg[3])
end
end
)
end
-- 设置能否互动,1允许,0禁止
@ -775,7 +764,7 @@ 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
@ -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,19 +793,19 @@ 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
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
if ControllerManager.IsSendCard == true then
--print("以发送开牌======================")
return
else
@ -823,7 +813,7 @@ function M:OnPlayerReady(...)
--ControllerManager.OnConnect(SocketCode.TimeoutDisconnect)
ViewManager.refreshGameView()
end
ControllerManager.IsSendCard=false
ControllerManager.IsSendCard = false
end)
end
@ -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
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
@ -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
@ -1067,9 +1057,11 @@ function M:OnUpdate()
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
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
@ -1124,7 +1114,8 @@ 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
@ -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

@ -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()
@ -46,20 +46,22 @@ function M:InitView(url)
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.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()
@ -70,12 +72,11 @@ function M:InitView(url)
end
end
function M:NewMJPlayerCardInfoView(view,index)
function M:NewMJPlayerCardInfoView(view, index)
if index == 1 then
return MJPlayerSelfCardInfoView.new(view,self)
return MJPlayerSelfCardInfoView.new(view, self)
end
return MJPlayerCardInfoView.new(view,self)
return MJPlayerCardInfoView.new(view, self)
end
function M:EventInit()
@ -86,41 +87,37 @@ function M:EventInit()
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)
end
if ( currentPlayer2 ) then
if (currentPlayer2) then
--self._popEvent = false
local xipaiCB2=function ()
local xipaiCB2 = function()
self._popEvent = true
end
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)
@ -131,14 +128,14 @@ function M:EventInit()
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,12 +154,12 @@ 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]
@ -171,7 +168,7 @@ function M:EventInit()
info:UpdateHandCard()
local outcard = UIPackage.CreateObjectFromURL(_gcm_outcard_url)
info:UpdateOutCardList(outcard, card, self._cursor)
self:PlaySound(p.self_user.sex,tostring(card))
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)
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]
@ -225,7 +222,7 @@ function M:EventInit()
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))
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
@ -264,7 +261,7 @@ function M:EventInit()
pNode:AddChild(he_list)
he_list:Center()
coroutine.start(function()
for i = 1 ,#win_list do
for i = 1, #win_list do
local tem = win_list[i]
local com_name = "he" .. tem.type
if tem.type == 1 then
@ -285,12 +282,12 @@ function M:EventInit()
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
@ -345,7 +342,7 @@ 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
@ -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]
@ -400,7 +397,7 @@ function M:EventInit()
end)
_gamectr:AddEventListener(CS_GameEvent.EventQSTip, function(...)
local arg = {...}
local arg = { ... }
local data = arg[1]
local tip = data["types"]
local lit = data["tip_list"]
@ -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
@ -456,7 +452,7 @@ function M:EventInit()
self:UpdateRound()
self._tex_LeftCard.text = "0"
self._state.selectedIndex = 1
if oldGameVersion==1 then
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
@ -490,13 +486,13 @@ 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( ... )
_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( ... )
_btn_pass.onClick:Set(function(...)
_gamectr:SendAction(0)
self._chipeng_tip:Dispose()
self._chipeng_tip = nil
@ -506,7 +502,7 @@ function M:EventInit()
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]
@ -518,8 +514,8 @@ function M:EventInit()
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()
@ -527,7 +523,7 @@ function M:InitPlayerInfoView()
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)
_player_info[i] = PlayerInfoView.new(tem, self)
tem.visible = false
end
end
@ -549,7 +545,7 @@ 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
@ -574,7 +570,7 @@ function M:__FangziTip(tip)
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
@ -587,12 +583,12 @@ function M:__FangziTip(tip)
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
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")
@ -644,7 +640,8 @@ 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
@ -657,7 +654,8 @@ function M:_ChiView(tiplist, callback)
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,9 +666,12 @@ 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
@ -678,7 +679,8 @@ function M:_ChiView(tiplist, callback)
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)
_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
@ -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,7 +774,7 @@ 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
@ -783,7 +785,7 @@ function M:__QsHu(data)
coroutine.wait(0.5)
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)
@ -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,8 +850,8 @@ 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)
self._popEvent = true
@ -877,14 +877,13 @@ function M:__Haidi()
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
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)
@ -894,46 +893,43 @@ function M:__PiaoNiaoTip()
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 piaoState = obj_piao:GetController('piao')
local tconfig=DataManager.CurrenRoom.room_config.config
local tconfig = DataManager.CurrenRoom.room_config.config
local piaoList={}
local piaoList = {}
for i = 1, 4 do
local piaoT=obj_piao:GetChild("btn_" .. i)
table.insert(piaoList,piaoT)
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
if tconfig.piao_niao < 2 then
for i = 1, #piaoList do
piaoList[i].visible = true
end
piaoState.selectedIndex=1
piaoState.selectedIndex = 1
else
piaoList[1].visible=false
for i=2,#piaoList do
piaoList[i].visible=tconfig["piao"..(i-1)]
piaoList[1].visible = false
for i = 2, #piaoList do
piaoList[i].visible = tconfig["piao" .. (i - 1)]
end
piaoState.selectedIndex=2
piaoState.selectedIndex = 2
end
end
function M:OnFangziAction(...)
@ -942,7 +938,7 @@ function M:OnFangziAction(...)
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,20 +952,20 @@ 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
fangzi = ""
fz_sound = "gang"..math.random(1, 2)
fz_sound = "gang" .. math.random(1, 2)
else
fangzi = ""
fz_sound = "buzhang"
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)
@ -998,12 +994,12 @@ 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
@ -1021,7 +1017,7 @@ function M:RunNiao(list, start_seat)
local card = list[i].card
-- coroutine.wait(0.3)
item:GetTransition("appear"):Play()
item.icon = UIPackage.GetItemURL("Main_Majiang", self:GetPrefix() .. "201_"..card)
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()
@ -1041,7 +1037,6 @@ function M:ReloadRoom(bskip)
self._state.selectedIndex = 1
self._room._reload_flag = true
end
end
if room.kg_card and #room.kg_card ~= 0 then
@ -1057,7 +1052,6 @@ function M:ReloadRoom(bskip)
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
@ -1085,7 +1079,7 @@ function M:ReloadRoom(bskip)
info:UpdateHandCard()
if p.seat == room.last_outcard_seat then
local card = p.outcard_list[#p.outcard_list]
info:UpdateOutCardList(nil,card, self._cursor)
info:UpdateOutCardList(nil, card, self._cursor)
elseif p.seat == room.curren_outcard_seat then
info:UpdateHandCard(true)
info:UpdateOutCardList()
@ -1102,7 +1096,7 @@ function M:ReloadRoom(bskip)
self._player_info[self:GetPos(p.seat)]:Ready(true)
end
end
if p.piao_niao~=nil and p.piao_niao > 0 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
@ -1129,7 +1123,7 @@ function M:GetPos(seat)
return pos
end
function M:PlaySound(sex,path)
function M:PlaySound(sex, path)
MJMainView.PlaySound(self, "ChangSha_MJ", sex, path)
end

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,11 +27,11 @@ 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
@ -49,28 +46,6 @@ 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,9 +2,9 @@ local MJPlayerCardInfoView = require("main.majiang.MJPlayerCardInfoView")
local M = {}
function M.new(view,mainView)
setmetatable(M, {__index = MJPlayerCardInfoView})
local self = setmetatable({},{__index = M})
function M.new(view, mainView)
setmetatable(M, { __index = MJPlayerCardInfoView })
local self = setmetatable({}, { __index = M })
self.class = "PlayerCardInfoView"
self._view = view
self._mainView = mainView
@ -56,12 +56,13 @@ function M:UpdateHandCard(getcard, mp, opcard)
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"
comp_back = comp_back .. "_3d"
end
for i = 0, _player.hand_left_count -1 do
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
@ -93,11 +94,11 @@ function M:UpdateHandCard(getcard, mp, opcard)
-- print(vardump(_player.card_list))
if self._current_card_type == 2 then
comp = comp.."_3d"
comp = comp .. "_3d"
end
for i = 0, #_player.card_list -1 do
for i = 0, #_player.card_list - 1 do
local obj = UIPackage.CreateObject("Main_Majiang", comp)
self:fillCard(obj,card,_player.card_list[i+1])
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值

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,8 +13,8 @@ local M = ExtendConfig
function ExtendConfig.new()
setmetatable(M, {__index = IExtendConfig})
local self = setmetatable({}, {__index = M})
setmetatable(M, { __index = IExtendConfig })
local self = setmetatable({}, { __index = M })
self.class = "ExtendConfig"
self.extend_id = 33
self._viewMap = {}
@ -55,7 +55,7 @@ function M:NewRoom()
return MJRoom.new()
end
function M:FillRoomConfig(room,_config)
function M:FillRoomConfig(room, _config)
room.room_config = EXRoomConfig.new(_config)
end
@ -91,7 +91,7 @@ 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
for i = 1, #_info_list do
local tem = _info_list[i]
local playerid = tem["playerid"]
local p = room:GetPlayerById(playerid)
@ -101,14 +101,15 @@ function M:FillRoomData(s2croom)
p.hand_left_count = tem["card_count"]
p.piao_niao = tem["piao_niao"] or 0
local opcard = tem["opcard"]
for k=1,#opcard do
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
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"]

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")
@ -65,14 +64,13 @@ function M:InitView(url, use_custom_bg)
--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._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,35 +94,33 @@ 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")
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
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
if round > 1 then
self._ctr_action.selectedIndex = 1
else
self._ctr_action.selectedIndex = 2
end
else
self._ctr_action.selectedIndex = 1
end
@ -136,10 +132,9 @@ function M:InitView(url, use_custom_bg)
self:InitXiPai1()
end
function M:InitXiPai()
self._xipaiPanel = UIPackage.CreateObjectFromURL("ui://Common/panel_handanim")
self._xipaiPanel.visible=false
self._xipaiPanel.visible = false
self._root_view:AddChild(self._xipaiPanel)
local offset = get_offset(self._full_offset)
@ -148,15 +143,14 @@ function M:InitXiPai()
self._xipaiPanel.height = GRoot.inst.height
self._xipaiPanel.x = offset
self._handAnimCtr=self._xipaiPanel:GetController("anim")
self._handAnimCtr.selectedIndex=0
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._xipaiPanel1.visible = false
self._root_view:AddChild(self._xipaiPanel1)
local offset = get_offset(self._full_offset)
@ -165,74 +159,65 @@ function M:InitXiPai1()
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.visible = true
self._xipaiPanel:GetTransition("XiPai"):Play()
self._handAnimCtr.selectedIndex=1
self._handAnimCtr.selectedIndex = 1
coroutine.wait(3)
self._handAnimCtr.selectedIndex=0
self._xipaiPanel.visible=false
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.visible = true
self._xipaiPanel1:GetTransition("XiPai"):Play()
self._handAnimCtr1.selectedIndex=1
self._handAnimCtr1.selectedIndex = 1
coroutine.wait(3)
self._handAnimCtr1.selectedIndex=0
self._xipaiPanel1.visible=false
self._handAnimCtr1.selectedIndex = 0
self._xipaiPanel1.visible = false
if xipaiCallBack then
xipaiCallBack()
end
end)
end
end
function M:EventInit()
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)
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
-- 如果要切换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,12 +386,11 @@ 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
@ -420,15 +403,14 @@ function M:OnPlayerReady( ... )
--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
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
if round > 1 then
self._ctr_action.selectedIndex = 1
else
self._ctr_action.selectedIndex = 2
end
else
self._ctr_action.selectedIndex = 1
end
@ -474,7 +456,7 @@ 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
@ -485,7 +467,7 @@ end
function M:PlayerChangeLineState()
local isOutCard = true
local str = "玩家 "
for _ , player in ipairs(self._room.player_list) do
for _, player in ipairs(self._room.player_list) do
if player.line_state == 0 then
isOutCard = false
-- str = str .. self._gamectr:GetPosString(player.seat) .. "、"
@ -505,11 +487,11 @@ function M:PlayerChangeLineState()
self._player_card_info[1]._area_handcard_list.touchable = isOutCard
end
function M:NewMJPlayerCardInfoView(view,index)
function M:NewMJPlayerCardInfoView(view, index)
if index == 1 then
return MJPlayerSelfCardInfoView.new(view,self)
return MJPlayerSelfCardInfoView.new(view, self)
end
return MJPlayerCardInfoView.new(view,self)
return MJPlayerCardInfoView.new(view, self)
end
function M:RemoveCursor()
@ -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