PGRData/Script/matrix/xui/xuiguide/XUiGuideNew.lua

195 lines
6.6 KiB
Lua
Raw Normal View History

2024-09-01 20:49:41 +00:00
---@class XUiGuideNew : XLuaUi
---@field Guide XGuide
local XUiGuideNew = XLuaUiManager.Register(XLuaUi, "UiGuide")
2024-09-01 20:49:41 +00:00
function XUiGuideNew:OnAwake()
self:AutoAddListener()
self.PanelInfoRect = self.PanelInfo
self.PanelWarning.gameObject:SetActive(false)
self.BtnSkip.gameObject:SetActive(false)
self.BtnPass.gameObject:SetActive(false)
self.PanelInfo.gameObject:SetActive(false)
self.LastClickTime = 0
self.ContinueClickTimes = 0
self.ClickInterval = 0.5
end
function XUiGuideNew:OnStart(targetImg, isWeakGuide, guideDesc, icon, name, callback)
2024-09-01 20:49:41 +00:00
self.Guide = self.BtnPanelMaskGuide:GetComponent("XGuide")
if (not self.Guide) then
self.Guide = self.BtnPanelMaskGuide.gameObject:AddComponent(typeof(CS.XGuide))
end
self.Guide:SetPass(false)
self.Guide:SetTimeText(self.TxtTime)
self.Callback = callback
self.IsWeakGuide = isWeakGuide
if targetImg then
CS.XGuideEventPass.IsPassEvent = true
CS.XGuideEventPass.IsFightGuide = true
self.IsFight = true
self:ShowMark(true, true)
2024-09-01 20:49:41 +00:00
local anchor = CS.UnityEngine.Vector2(0, 1)
self:ShowDialog(icon, name, guideDesc, anchor, anchor, CS.UnityEngine.Vector2(500, -380))
self:FocusOnFightPanel(targetImg)
self.UiWidget = self.Transform:Find("FullScreenBackground/BtnPanelMaskGuide/BtnPass").gameObject:AddComponent(typeof(CS.XUiWidget))
self.UiWidget:AddPointerDownListener(function(eventData)
self.Transform:Find("SafeAreaContentPane").gameObject:SetActive(false)
self.Transform:Find("FullScreenBackground/BtnPanelMaskGuide"):GetComponent("Image").enabled = false
self.Transform:Find("FullScreenBackground/BtnPanelMaskGuide/BtnPass/Bg").gameObject:SetActive(false)
end)
self.UiWidget:AddPointerUpListener(function(eventData)
self:OnBtnPassClick()
end)
end
-- CsXGameEventManager.Instance:RegisterEvent(CS.XEventId.EVENT_GUIDE_FIGHT_BTNDOWN, function(evt, args)
-- if self.Callback and not self.IsWeakGuide then
-- self.Callback()
-- self.Callback = nil
-- end
-- end)
end
function XUiGuideNew:OnDestroy()
-- CsXGameEventManager.Instance:RemoveEvent(XEventId.EVENT_GUIDE_FIGHT_BTNDOWN, function(evt, args)
-- if self.Callback and not self.IsWeakGuide then
-- self.Callback = nil
-- end
-- end)
end
function XUiGuideNew:AutoAddListener()
self:RegisterClickEvent(self.BtnPanelMaskGuide, self.OnBtnPanelMaskGuideClick)
self:RegisterClickEvent(self.BtnPass, self.OnBtnPassClick)
self:RegisterClickEvent(self.BtnSkip, self.OnBtnSkipClick)
2024-09-01 20:49:41 +00:00
self:RegisterClickEvent(self.BtnConfirm, self.OnBtnConfirmClick)
self:RegisterClickEvent(self.BtnCancel, self.OnBtnCancelClick)
end
-- auto
function XUiGuideNew:OnBtnSkipClick()
self.PanelWarning.gameObject:SetActive(true)
end
2024-09-01 20:49:41 +00:00
function XUiGuideNew:OnBtnConfirmClick()
XDataCenter.GuideManager.ReqCompleteGuideGroup(function()
2024-09-01 20:49:41 +00:00
XDataCenter.GuideManager.RecordBuryingPoint(XDataCenter.GuideManager.BuryingPointType.Skip)
XDataCenter.GuideManager.ResetGuide()
XEventManager.DispatchEvent(XEventId.EVENT_FUNCTION_EVENT_COMPLETE)
end)
end
function XUiGuideNew:CheckDouble()
if XTime.GetServerNowTimestamp() - self.LastClickTime > self.ClickInterval then
self.ContinueClickTimes = 0
else
self.ContinueClickTimes = self.ContinueClickTimes + 1
end
if self.ContinueClickTimes == 3 then
self.ContinueClickTimes = 0
self.BtnSkip.gameObject:SetActive(true)
end
self.LastClickTime = XTime.GetServerNowTimestamp()
end
function XUiGuideNew:OnBtnCancelClick()
self.PanelWarning.gameObject:SetActive(false)
end
function XUiGuideNew:OnBtnPassClick()
self.Guide:Reset()
if self.Callback and not self.IsWeakGuide then
self.Callback()
self.Callback = nil
end
end
function XUiGuideNew:OnBtnPanelMaskGuideClick()
if not XDataCenter.GuideManager.CheckIsFightGuide() and not CS.XGuideEventPass.IsFightGuide then
self:CheckDouble()
end
CsXGameEventManager.Instance:Notify(CS.XEventId.EVENT_GUIDE_ANYCLICK)
end
--显示头像
2024-09-01 20:49:41 +00:00
function XUiGuideNew:ShowDialog(icon, name, content, anchorMax, anchorMin, position)
self.PanelInfo.gameObject:SetActive(true)
self:SetUiSprite(self.ImgRole, icon)
self.TxtName.text = name or ""
self.TxtDesc.text = content
2024-09-01 20:49:41 +00:00
self.PanelInfoRect.anchorMax = anchorMax
self.PanelInfoRect.anchorMin = anchorMin
self.PanelInfoRect.anchoredPosition = position
end
--隐藏头像
function XUiGuideNew:HideDialog()
self.PanelInfo.gameObject:SetActive(false)
end
--聚焦panel
2024-09-01 20:49:41 +00:00
function XUiGuideNew:FocusOnPanel(panel, eulerAngles, passEvent, sizeDelta)
eulerAngles = eulerAngles or CS.UnityEngine.Vector3.zero
sizeDelta = sizeDelta or CS.UnityEngine.Vector2.zero
self.BtnPass.gameObject:SetActive(true)
self.BtnPass.gameObject.transform.eulerAngles = eulerAngles
self.Guide:SetTarget(panel, sizeDelta)
if not XTool.UObjIsNil(panel.gameObject) then
CS.XGuideEventPass.Target = panel.gameObject
end
CS.XGuideEventPass.IsPassEvent = passEvent
if self.AniGuideJiaoLoop then
self.AniGuideJiaoLoop.gameObject:SetActive(false)
self.AniGuideJiaoLoop.gameObject:SetActive(true)
end
end
function XUiGuideNew:FocusOn3DPanel(camera, panel, offset, eulerAngles, passEvent, sizeDelta)
eulerAngles = eulerAngles or CS.UnityEngine.Vector3.zero
2024-09-01 20:49:41 +00:00
sizeDelta = sizeDelta or CS.UnityEngine.Vector2.zero
self.BtnPass.gameObject:SetActive(true)
self.BtnPass.gameObject.transform.eulerAngles = eulerAngles
2024-09-01 20:49:41 +00:00
self.Guide:SetTarget(panel, camera, sizeDelta, offset)
if not XTool.UObjIsNil(panel.gameObject) then
CS.XGuideEventPass.Target = panel.gameObject
end
CS.XGuideEventPass.IsPassEvent = passEvent
if self.AniGuideJiaoLoop then
self.AniGuideJiaoLoop.gameObject:SetActive(false)
self.AniGuideJiaoLoop.gameObject:SetActive(true)
end
end
2024-09-01 20:49:41 +00:00
function XUiGuideNew:FocusOnFightPanel(panel)
self.BtnPass.gameObject:SetActive(true)
2024-09-01 20:49:41 +00:00
self.Guide:SetTarget(panel, CS.UnityEngine.Vector2.zero)
CS.XGuideEventPass.Target = nil
end
--显示遮罩
function XUiGuideNew:ShowMark(isShowMask, isShowRay)
self.PanelMaskAll.gameObject:SetActive(isShowMask)
self.BtnPanelMaskGuide.gameObject:SetActive(true)
self.Guide:SetPass(not isShowMask)
end
--显示遮罩
function XUiGuideNew:ShowMarkNew(isShowMask, isShowRay)
self.PanelMaskAll.gameObject:SetActive(isShowMask)
self.BtnPanelMaskGuide.gameObject:SetActive(isShowRay)
self.Guide:SetPass(not isShowMask)
end