2025-04-01 10:48:36 +08:00
|
|
|
---
|
|
|
|
|
|
|
|
|
|
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 = {}
|
2025-04-11 12:49:08 +08:00
|
|
|
setmetatable(self, { __index = PlayerInfoView })
|
2025-04-01 10:48:36 +08:00
|
|
|
self._view = view
|
|
|
|
|
self._main_view = main_view
|
|
|
|
|
self._isHideIpAdds = isHideIpAdds
|
2025-04-11 12:49:08 +08:00
|
|
|
self.isShowTGTimer = false
|
|
|
|
|
self.currentTime = 0
|
|
|
|
|
self.totalTime = 0
|
2025-04-01 10:48:36 +08:00
|
|
|
--self.isShow = fasle
|
|
|
|
|
self:init()
|
|
|
|
|
return self
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:init()
|
|
|
|
|
local view = self._view
|
|
|
|
|
UIPackage.AddPackage('base/chat/ui/Chat')
|
|
|
|
|
local player_name_score = view:GetChild('info')
|
|
|
|
|
self._tex_player_name = player_name_score:GetChild('tex_player_name')
|
|
|
|
|
self._tex_player_id = player_name_score:GetChild('tex_player_id')
|
|
|
|
|
self._tex_score = player_name_score:GetChild('tex_score')
|
2025-04-11 12:49:08 +08:00
|
|
|
self._tex_score.visible = true
|
|
|
|
|
|
|
|
|
|
self._tex_score1 = self._view:GetChild("info"):GetChild("tex_score1")
|
|
|
|
|
if self._tex_score1 then
|
|
|
|
|
self._tex_score1.visible = true
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
self._tex_score2 = self._view:GetChild("info"):GetChild("tex_score2")
|
2025-04-11 12:49:08 +08:00
|
|
|
if self._tex_score2 then
|
|
|
|
|
self._tex_score2.visible = true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self._tex_n4 = self._view:GetChild("info"):GetChild("n4")
|
|
|
|
|
if self._tex_n4 then
|
|
|
|
|
self._tex_n4.visible = true
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
self._tex_n5 = self._view:GetChild("info"):GetChild("n5")
|
2025-04-11 12:49:08 +08:00
|
|
|
if self._tex_n5 then
|
|
|
|
|
self._tex_n5.visible = true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self.n3Bg = self._view:GetChild("info"):GetChild("n3")
|
|
|
|
|
if self.n3Bg then
|
|
|
|
|
--self.n3Bg:SetSize(138,55)
|
|
|
|
|
end
|
|
|
|
|
self.zhanjitext = self._view:GetChild("text_jifen")
|
|
|
|
|
if self.zhanjitext then
|
|
|
|
|
self.zhanjitext.text = 0
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
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')
|
|
|
|
|
|
2025-04-11 12:49:08 +08:00
|
|
|
self.PlayerTGTips = view:GetChild('tuoguanTips')
|
|
|
|
|
if self.PlayerTGTips and self.PlayerTGTips.displayObject.gameObject then
|
|
|
|
|
self.PlayerTGTips.displayObject.gameObject:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
|
2025-04-11 12:49:08 +08:00
|
|
|
function M:IsShowTGTips(isShow, time)
|
2025-04-01 10:48:36 +08:00
|
|
|
--printlog("isShowisShowisShow==== ",isShow," time ",time)
|
2025-04-11 12:49:08 +08:00
|
|
|
if time == nil then time = 0 end
|
|
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
self.isShowTGTimer = isShow
|
2025-04-11 12:49:08 +08:00
|
|
|
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
|
2025-04-01 10:48:36 +08:00
|
|
|
--UpdateBeat:Remove(self.OnUpdate,self)
|
2025-04-11 12:49:08 +08:00
|
|
|
--UpdateBeat:Add(self.OnUpdate,self)
|
|
|
|
|
-- printlog("aaaaaaaaa111111111111111111111111111111")
|
|
|
|
|
--TimerManager.RemoveTimer(self.OnUpdate)
|
|
|
|
|
TimerManager.AddTimer(self.OnUpdate, self)
|
|
|
|
|
--printlog(self)
|
|
|
|
|
else
|
|
|
|
|
-- printlog("移除IsShowTGTips",self.isShow)
|
|
|
|
|
--UpdateBeat:Remove(self.OnUpdate,self)
|
|
|
|
|
TimerManager.RemoveTimer(self.OnUpdate, self)
|
|
|
|
|
end
|
2025-04-01 10:48:36 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:OnUpdate()
|
2025-04-11 12:49:08 +08:00
|
|
|
--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
|
2025-04-01 10:48:36 +08:00
|
|
|
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
|
2025-04-11 12:49:08 +08:00
|
|
|
)
|
2025-04-01 10:48:36 +08:00
|
|
|
else
|
|
|
|
|
local ctr = self._btn_head:GetController("hidden")
|
|
|
|
|
if ctr then
|
|
|
|
|
ctr.selectedIndex = 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2025-04-11 12:49:08 +08:00
|
|
|
if isHidden
|
|
|
|
|
--and player.self_user.account_id ~= room.self_player.self_user.account_id
|
2025-04-01 10:48:36 +08:00
|
|
|
then
|
|
|
|
|
if player.orgSeat and player.orgSeat > 0 then
|
2025-04-11 12:49:08 +08:00
|
|
|
self._tex_player_name.text = "玩家" .. player.orgSeat
|
2025-04-01 10:48:36 +08:00
|
|
|
else
|
2025-04-11 12:49:08 +08:00
|
|
|
self._tex_player_name.text = "玩家" .. player.seat
|
2025-04-01 10:48:36 +08:00
|
|
|
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
|
2025-04-11 12:49:08 +08:00
|
|
|
self._tex_player_id.text = "ID:" .. player.self_user.account_id
|
2025-04-01 10:48:36 +08:00
|
|
|
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:UpdateScore(score)
|
|
|
|
|
if not score then
|
|
|
|
|
score = self._player.total_score
|
|
|
|
|
local room = DataManager.CurrenRoom
|
|
|
|
|
if room:checkHpNonnegative() then
|
|
|
|
|
if self._player.cur_hp then
|
2025-04-11 12:49:08 +08:00
|
|
|
-- -- print(self._player.total_hp)
|
2025-04-01 10:48:36 +08:00
|
|
|
-- if self._player.total_hp then
|
|
|
|
|
-- score = d2ad(self._player.total_hp).."/"..d2ad(self._player.cur_hp)
|
|
|
|
|
-- else
|
|
|
|
|
score = d2ad(self._player.cur_hp)
|
2025-04-11 12:49:08 +08:00
|
|
|
-- end
|
2025-04-01 10:48:36 +08:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
self._tex_score.text = tostring(score)
|
|
|
|
|
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
|
2025-04-11 12:49:08 +08:00
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
function M:UnmarkTuoguan()
|
|
|
|
|
self:RemoveMarkFromHead('mark_tuoguan')
|
|
|
|
|
end
|
2025-04-11 12:49:08 +08:00
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
-- 动态的往头像上加载组件
|
|
|
|
|
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
|
2025-04-11 12:49:08 +08:00
|
|
|
|
2025-04-01 10:48:36 +08:00
|
|
|
-- 动态移除组件
|
|
|
|
|
function M:RemoveMarkFromHead(key)
|
|
|
|
|
if self[key] then
|
|
|
|
|
self[key]:Dispose()
|
|
|
|
|
self[key] = nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function M:Destroy()
|
2025-04-11 12:49:08 +08:00
|
|
|
self.isShowTGTimer = false
|
|
|
|
|
TimerManager.RemoveTimer(self.OnUpdate, self)
|
|
|
|
|
self.OnUpdate = nil
|
|
|
|
|
self.muShiPlayerUpdate = nil
|
2025-04-01 10:48:36 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return M
|