115 lines
2.9 KiB
Lua
115 lines
2.9 KiB
Lua
local MJMainView = require("main.majiang.MJMainView")
|
||
|
||
local WitnessView = {}
|
||
|
||
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 = {}
|
||
self._scale = true
|
||
self._full_offset = false
|
||
self.class = "MainView"
|
||
self._style = 1
|
||
self._popEvent = true
|
||
self:InitView()
|
||
end
|
||
|
||
function M:InitView(url)
|
||
local room = self._room
|
||
BaseView.InitView(self, url)
|
||
|
||
|
||
|
||
self.com_logocType = self._view:GetChild("com_logo"):GetController("cType")
|
||
|
||
self.com_notice = self._view:GetChild("com_notice")
|
||
end
|
||
|
||
function M:Show()
|
||
getmetatable(WitnessView).__index.Show(self)
|
||
self:DoNoticeAnimation()
|
||
end
|
||
|
||
function M:DoNoticeAnimation()
|
||
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
|
||
|
||
--强制让牌类型为1,只有一种牌
|
||
self._room.card_type = 1
|
||
end
|
||
|
||
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
|
||
|
||
return M
|