hengyang_client/lua_probject/base_project/Game/View/WitnessView.lua

115 lines
2.9 KiB
Lua
Raw Normal View History

2025-08-28 15:02:07 +08:00
local MJMainView = require("main.majiang.MJMainView")
2025-07-30 21:56:29 +08:00
local WitnessView = {}
2025-07-30 22:31:32 +08:00
2025-09-08 14:39:21 +08:00
local M = WitnessView
setmetatable(M, { __index = BaseView })
function M:init()
self._gamectr = ControllerManager.GetController(GameController)
self._room = DataManager.CurrenRoom
self._room.Witness = true
UIPackage.AddPackage('base/chat/ui/Chat')
self._eventmap = {}
2025-09-10 20:32:26 +08:00
self._scale = true
self._full_offset = false
self.class = "MainView"
2025-09-08 14:39:21 +08:00
self._style = 1
self._popEvent = true
self:InitView()
2025-07-30 22:31:32 +08:00
end
2025-09-08 14:39:21 +08:00
function M:InitView(url)
local room = self._room
BaseView.InitView(self, url)
2025-09-10 20:32:26 +08:00
2025-07-30 21:56:29 +08:00
2025-07-30 22:31:32 +08:00
self.com_logocType = self._view:GetChild("com_logo"):GetController("cType")
2025-08-28 15:02:07 +08:00
self.com_notice = self._view:GetChild("com_notice")
end
2025-09-08 14:39:21 +08:00
function M:Show()
2025-08-28 15:02:07 +08:00
getmetatable(WitnessView).__index.Show(self)
self:DoNoticeAnimation()
end
2025-09-08 14:39:21 +08:00
function M:DoNoticeAnimation()
2025-08-28 15:02:07 +08:00
self.noticeIndex = self.noticeIndex or 1
if not DataManager.GameNotice or #DataManager.GameNotice == 0 then
return
end
local text_notice = self.com_notice:GetChild("text_notice")
text_notice.text = DataManager.GameNotice[self.noticeIndex]
local speed = 44
local time = text_notice.width / speed
text_notice.x = self.com_notice.width
local tween = text_notice:TweenMove(Vector2(-text_notice.width, text_notice.y), time):OnComplete(function()
self:DoNoticeAnimation()
end)
tween:SetEase(EaseType.Linear)
self.noticeIndex = self.noticeIndex + 1
if self.noticeIndex > #DataManager.GameNotice then
self.noticeIndex = 1
end
2025-09-03 21:58:19 +08:00
--强制让牌类型为1只有一种牌
self._room.card_type = 1
2025-07-30 21:56:29 +08:00
end
2025-09-10 20:32:26 +08:00
function M:OnUpdate()
if (self._popEvent) then
local func = self._gamectr:PopEvent()
if (func ~= nil) then
local success, result = pcall(func)
if success then
else
print("witness error")
print(result)
error(result)
-- self._gamectr = ControllerManager.GetController(GameController)
-- if self._gamectr then
-- self._gamectr:ResetConnect()
-- end
end
--func()
end
end
end
function M:DestroyPlayerInfo()
for i = 1, #self._player_info do
self._player_info[i]:Destroy()
end
end
function M:Destroy()
TimerManager.Clear()
-- self:UnmarkSelfTuoguan()
self:DestroyPlayerInfo()
DSTweenManager.ClearTween()
NetResetConnectWindow.CloseNetReset()
Voice.CrealRecord()
ControllerManager.resetJionRoom = false
self._popEvent = false
GRoot.inst:HidePopup()
ViewUtil.CloseModalWait()
GameApplication.Instance.StopMusic = 0
coroutine.stopAll()
UpdateBeat:Remove(self.OnUpdate, self)
BaseView.Destroy(self)
BaseWindow.DestroyAll()
ResourcesManager.UnLoadGroup('base_chat')
end
2025-09-08 14:39:21 +08:00
return M