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

68 lines
2.0 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

local MJSettingView = require("main.majiang.MJSettingViewNew")
local TableBG = require("Game.Data.TableBG")
local MJMainView = require("main.majiang.MJMainView")
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" },
{ id = 3, url = "base/main_majiang/bg/bg4", thumb = "ui://Main_Majiang/b04" }
}
local WitnessView = {}
setmetatable(WitnessView, { __index = BaseView })
function WitnessView:init()
end
function WitnessView:InitView()
self.btn_setting = self._view:GetChild("btn_setting")
self.com_logocType = self._view:GetChild("com_logo"):GetController("cType")
self.btn_setting.onClick:Set(function()
local view = MJSettingView.new(self, true)
view:Show()
end)
local default_bg = 1
TableBG.LoadTableBG(default_bg, self._room.game_id, self._root_view, bg_config)
self.com_notice = self._view:GetChild("com_notice")
end
function WitnessView:Show()
getmetatable(WitnessView).__index.Show(self)
self:DoNoticeAnimation()
end
function WitnessView: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
return WitnessView