miduo_client/Assets/ManagedResources/~Lua/Modules/Guide/GuidePanel.lua

736 lines
31 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.

require("Base/BasePanel")
GuidePanel = Inherit(BasePanel)
local this = GuidePanel
local GuideConfig = ConfigManager.GetConfig(ConfigName.GuideConfig)
local curId
local args
local audio
local orginLayer
--local live2d
--local SkeletonGraphic
local nextDelayTime=0
local nextDelayChange = false
--初始化组件(用于子类重写)
function this:InitComponent()
this.spLoader = SpriteLoader.New()
orginLayer = 0
self.mask = Util.GetGameObject (self.gameObject, "mask")
self.dialogRoot = Util.GetGameObject (self.gameObject, "dialog")
self.desc = Util.GetGameObject (self.dialogRoot, "Text"):GetComponent("Text")
self.dialogTip = Util.GetGameObject (self.dialogRoot, "Tip")
self.tipButtomRoot = Util.GetGameObject (self.gameObject, "tipButtom")
self.tipButtomMat = self.tipButtomRoot:GetComponent("Image").material
self.tipButtomMat:SetFloat("_ScaleX", Screen.width / Screen.height)
self.tipButtomMat:SetFloat("_R", 0.1)
self.tipButtomMat:SetFloat("_CutOff", 0.22)
self.button = Util.GetGameObject (self.tipButtomRoot, "button")
self.upArrow = Util.GetGameObject (self.gameObject, "upArrow")
self.buttonIcon = poolManager:LoadAsset("GuideEffect", PoolManager.AssetType.GameObject)
self.buttonIcon.name = "icon"
self.buttonIcon.transform:SetParent(self.tipButtomRoot.transform)
self.buttonIcon.transform.localPosition = Vector3.zero
self.buttonIcon.transform.localScale = Vector3.one
self.buttonIcon.transform:SetAsFirstSibling()
self.buttonIcon:SetActive(true)
self.hand = Util.GetGameObject (self.buttonIcon, "GameObject")
self.handPoint = Util.GetGameObject(self.buttonIcon,"GameObject")
--live2d = poolManager:LoadLive("live2d_sgtn", self.dialogRoot.transform, Vector3.one * 0.42, Vector3.New(-337, -170))
end
--绑定事件(用于子类重写)
function this:BindEvent()
Util.AddClick(this.button, this.NextGuide)
Util.AddClick(this.mask, this.NextGuide)
end
--添加事件监听(用于子类重写)
function this:AddListener()
end
--移除事件监听(用于子类重写)
function this:RemoveListener()
end
function this.SetArrowPosition(id, pos)
-- this.SetPosition(this.button, pos)
-- this.SetPosition(this.buttonIcon, pos)
local v2 = RectTransformUtility.WorldToScreenPoint(UIManager.camera, this.button.transform.position)
this.tipButtomMat:SetFloat("_X", v2.x / Screen.width)
this.tipButtomMat:SetFloat("_Y", v2.y / Screen.height)
this.ExecuteBehavior(GuideConfig[id].BehaviorType, GuideConfig[id].BehaviorArgs)
this.handPoint:SetActive(true)--GuideConfig[id].BehaviorType ~= 13)
end
function this.SetPosition(targetGO, pos)
local rect = targetGO:GetComponent("RectTransform")
if pos[3] == 0 then --中心对齐
rect.anchorMin = Vector2.New(0.5, 0.5)
rect.anchorMax = Vector2.New(0.5, 0.5)
elseif pos[3] == 1 then --上对齐
rect.anchorMin = Vector2.New(0.5, 1)
rect.anchorMax = Vector2.New(0.5, 1)
elseif pos[3] == 2 then --下对齐
rect.anchorMin = Vector2.New(0.5, 0)
rect.anchorMax = Vector2.New(0.5, 0)
elseif pos[3] == 3 then --左对齐
rect.anchorMin = Vector2.New(0, 0.5)
rect.anchorMax = Vector2.New(0, 0.5)
elseif pos[3] == 4 then --右对齐
rect.anchorMin = Vector2.New(1, 0.5)
rect.anchorMax = Vector2.New(1, 0.5)
elseif pos[3] == 5 then --左上对齐
rect.anchorMin = Vector2.New(0, 1)
rect.anchorMax = Vector2.New(0, 1)
elseif pos[3] == 6 then --右上对齐
rect.anchorMin = Vector2.New(1, 1)
rect.anchorMax = Vector2.New(1, 1)
elseif pos[3] == 7 then --左下对齐
rect.anchorMin = Vector2.New(0, 0)
rect.anchorMax = Vector2.New(0, 0)
elseif pos[3] == 8 then --右下对齐
rect.anchorMin = Vector2.New(1, 0)
rect.anchorMax = Vector2.New(1, 0)
end
rect.anchoredPosition = Vector2.New(pos[1], pos[2])
end
function this.SetBtnGOPosition(v3)
local pos = GuideConfig[this.id].ArrowPosition
local targetPos = v3 + Vector3.New(pos[1], pos[2], 0)*0.00375
this.button:GetComponent("RectTransform").position = targetPos
local v2 = RectTransformUtility.WorldToScreenPoint(UIManager.camera, targetPos)
this.tipButtomMat:SetFloat("_X", v2.x / Screen.width)
this.tipButtomMat:SetFloat("_Y", v2.y / Screen.height)
-- 播放聚焦动画
this:PlayFoucsAnim(targetPos)
end
--function this.SetBtnGOSizeData(v2)
-- this.button:GetComponent("RectTransform").sizeDelta = v2
--end
function this.ExecuteBehavior(beType, beArgs)
if this.canvas.enabled==false then
this.canvas.enabled=true
end
if beType == 1 then --点击地图行走
local _trigger = Util.GetEventTriggerListener(this.button)
local endFunc
_trigger.onPointerDown = _trigger.onPointerDown + TileMapController.OnPointerDown
_trigger.onPointerUp = _trigger.onPointerUp + TileMapController.OnPointerUp
endFunc = function()
_trigger.onPointerDown = _trigger.onPointerDown - TileMapController.OnPointerDown
_trigger.onPointerUp = _trigger.onPointerUp - TileMapController.OnPointerUp
_trigger.onPointerUp = _trigger.onPointerUp - endFunc
end
_trigger.onPointerUp = _trigger.onPointerUp + endFunc
elseif beType == 2 then --点击界面按钮
LogRed("beArgs========================"..beArgs)
local btn = Util.GetGameObject(UIManager.uiRoot, beArgs):GetComponent("Button")
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, function()
-- if UIManager.IsOpen(UIName.FightPointPassMainPanel) then
-- FightPointPassMainPanel.BtView:SetBtnNewIcon(btn, false)
-- elseif UIManager.IsOpen(UIName.CarbonTypePanel) then
-- CarbonTypePanel.SetNewTextShow(btn, false)
-- end
local curGuideId = curId
btn.onClick:Invoke() --该按钮事件有可能会触发下一步引导,因此需要监听变化
-- 触发按钮事件后,检测服务器延迟,收到服务器回调后继续下一步引导
GuideManager.CheckServer(function()
if curGuideId == curId then
this.NextGuide()
end
end)
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, this.NextGuide)
end)
if UIManager.IsOpen(UIName.MainPanel) and (string.find(btn.transform.parent.name, "layer") ~= nil or btn.transform.name == "btnXingYunTanBao" or btn.transform.name == "btnExplore") then --主界面的ui按钮位置可能会超框所以做位移处理
for k, v in pairs(MainPanel.operateIcon) do
if v.go == btn.gameObject then
MainPanel:SetPosFunc(Vector2.New(v.pos, 0))
break
end
end
--elseif UIManager.IsOpen(UIName.FightPointPassMainPanel) then
-- FightPointPassMainPanel.BtView:SetBtnNewIcon(btn, true)
--elseif UIManager.IsOpen(UIName.CarbonTypePanel) then
-- CarbonTypePanel.SetNewTextShow(btn, true)
end
this.SetBtnGOPosition(btn.gameObject:GetComponent("RectTransform").position)
elseif beType == 3 then --点击释放技能
local _trigger = Util.GetEventTriggerListener(this.button)
local endFunc
_trigger.onPointerClick = _trigger.onPointerClick + args[1]._onPointerClick
endFunc = function()
_trigger.onPointerClick = _trigger.onPointerClick - args[1]._onPointerClick
_trigger.onPointerClick = _trigger.onPointerClick - endFunc
--BattlePanel.BtnPlay:GetComponent("Button").onClick:Invoke() --还原暂停
BattleManager.ResumeBattle()
end
_trigger.onPointerClick = _trigger.onPointerClick + endFunc
this.SetBtnGOPosition(args[1].RoleIconTran.position)
elseif beType == 4 then --点击设置战斗自动
if BattleManager.IsBattlePlaying() then
BattleManager.PauseBattle()
end
local btn = Util.GetGameObject (UIManager.uiNode, beArgs):GetComponent("Button")
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, function()
btn.onClick:Invoke()
if curId == 19 then
-- for i=1,5 do --TODO自动设置完强制全部自动以处理后续上阵的妖灵师默认自动并且默认显示策略面板
-- BattlePanel.RoleManualList[i].auto = true
-- end
-- BattlePanel.ShowManual = true
end
this.NextGuide()
this.button:GetComponent("Button").onClick:RemoveAllListeners()
BattleManager.ResumeBattle()
Util.AddClick(this.button, this.NextGuide)
end)
this.SetBtnGOPosition(btn.gameObject:GetComponent("RectTransform").position)
elseif beType == 5 then --镜头切到位置行走
local button2 = newObjToParent(this.button, this.button.transform.parent)
this.button:SetActive(false)
button2.transform.position = this.button.transform.position
this.dialogRoot:SetActive(false)
this.tipButtomRoot:SetActive(false)
local strs = string.split(beArgs, "#")
local x = tonumber(strs[1])
local y = tonumber(strs[2])
TileMapView.CameraTween(x, y, 0.5, function ()
local v2 = RectTransformUtility.WorldToScreenPoint(TileMapView.GetCamera(), TileMapView.GetLiveTilePos(x, y))
v2 = v2 / math.min(Screen.width/1080, Screen.height/1920)
local pos = {v2.x,v2.y,7}
this.SetPosition(button2, pos)
this.SetPosition(this.buttonIcon, pos)
v2 = RectTransformUtility.WorldToScreenPoint(UIManager.camera, button2.transform.position)
this.tipButtomMat:SetFloat("_X", v2.x / Screen.width)
this.tipButtomMat:SetFloat("_Y", v2.y / Screen.height)
button2:GetComponent("Button").onClick:RemoveAllListeners()
this.dialogRoot:SetActive(true)
this.tipButtomRoot:SetActive(true)
Util.AddClick(button2, function()
TileMapController.OnLongClickShowPath(x, y)
TileMapController.OnLongClickTile()
this.NextGuide()
this.button:SetActive(true)
GameObject.DestroyImmediate(button2)
end)
end)
elseif beType == 6 then --滑动释放技能
this.button:GetComponent("Button").onClick:RemoveAllListeners()
local _trigger = Util.GetEventTriggerListener(this.button)
local endFunc, dragFunc
local isCanCast = false
_trigger.onBeginDrag = _trigger.onBeginDrag + args[1]._onBeginDrag
_trigger.onDrag = _trigger.onDrag + args[1]._onDrag
_trigger.onEndDrag = _trigger.onEndDrag + args[1]._onEndDrag
dragFunc = function()
isCanCast = Vector2.Distance(args[1].RoleIconTran.anchoredPosition, Vector2.zero) > 150
this.button:GetComponent("RectTransform").position = args[1].RoleIconTran.position
this.buttonIcon:GetComponent("RectTransform").position = args[1].RoleIconTran.position
local v2 = RectTransformUtility.WorldToScreenPoint(UIManager.camera, this.button.transform.position)
this.tipButtomMat:SetFloat("_X", v2.x / Screen.width)
this.tipButtomMat:SetFloat("_Y", v2.y / Screen.height)
Util.GetGameObject (this.buttonIcon, "GameObject/Image"):SetActive(false)
Util.GetGameObject (this.buttonIcon, "Image"):SetActive(false)
end
endFunc = function()
if isCanCast then
_trigger.onBeginDrag = _trigger.onBeginDrag - args[1]._onBeginDrag
_trigger.onDrag = _trigger.onDrag - args[1]._onDrag
_trigger.onEndDrag = _trigger.onEndDrag - args[1]._onEndDrag
_trigger.onDrag = _trigger.onDrag - dragFunc
_trigger.onEndDrag = _trigger.onEndDrag - endFunc
BattleManager.ResumeBattle()
this.upArrow:SetActive(false)
this.NextGuide()
Util.AddClick(this.button, this.NextGuide)
Util.GetGameObject (this.buttonIcon, "GameObject/Image"):SetActive(true)
Util.GetGameObject (this.buttonIcon, "Image"):SetActive(false)
else
Util.GetGameObject (this.buttonIcon, "GameObject/Image"):SetActive(false)
Util.GetGameObject (this.buttonIcon, "Image"):SetActive(true)
end
end
_trigger.onDrag = _trigger.onDrag + dragFunc
_trigger.onEndDrag = _trigger.onEndDrag + endFunc
this.SetBtnGOPosition(args[1].RoleIconTran.position)
this.upArrow.transform.position = this.button.transform.position
this.upArrow:SetActive(true)
Util.GetGameObject (this.buttonIcon, "GameObject/Image"):SetActive(false)
Util.GetGameObject (this.buttonIcon, "Image"):SetActive(true)
elseif beType == 7 then --释放异妖技能
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, function()
args[1]:GetComponent("Button").onClick:Invoke()
this.NextGuide()
BattleManager.ResumeBattle()
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, this.NextGuide)
end)
elseif beType == 8 then --长按连续升级操作
this.button:GetComponent("Button").onClick:RemoveAllListeners()
local _trigger = Util.GetEventTriggerListener(this.button)
local startFunc
local endFunc
local timePressStarted
_trigger.onPointerDown = _trigger.onPointerDown + RoleInfoPanel.PageList[1]._onPointerDown
startFunc = function()
timePressStarted = Time.realtimeSinceStartup
end
_trigger.onPointerDown = _trigger.onPointerDown + startFunc
_trigger.onPointerUp = _trigger.onPointerUp + RoleInfoPanel.PageList[1]._onPointerUp
endFunc = function()
_trigger.onPointerDown = _trigger.onPointerDown - RoleInfoPanel.PageList[1]._onPointerDown
_trigger.onPointerDown = _trigger.onPointerDown - startFunc
_trigger.onPointerUp = _trigger.onPointerUp - RoleInfoPanel.PageList[1]._onPointerUp
_trigger.onPointerUp = _trigger.onPointerUp - endFunc
-- 长按时间小于4秒
if Time.realtimeSinceStartup - timePressStarted <= 0.4 then
RoleInfoPanel.PageList[1].timePressStarted = timePressStarted
local btn = Util.GetGameObject(UIManager.uiNode, beArgs):GetComponent("Button")
btn.onClick:Invoke()
end
this.NextGuide()
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, this.NextGuide)
end
_trigger.onPointerUp = _trigger.onPointerUp + endFunc
this.SetBtnGOPosition(RoleInfoPanel.PageList[1].upLvTrigger.gameObject:GetComponent("RectTransform").position)
elseif beType == 9 then --关联上阵成员界面对应名字的预设
local item = RoleListPanel.GetRoleItemByName(beArgs)
if item then
local btn = Util.GetGameObject (item, "card"):GetComponent("Button")
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, function()
local curGuideId = curId
btn.onClick:Invoke() --该按钮事件有可能会触发下一步引导,因此需要监听变化
if curGuideId == curId then
this.NextGuide()
end
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, this.NextGuide)
end)
this.SetBtnGOPosition(item.gameObject:GetComponent("RectTransform").position)
end
elseif beType == 10 then --连续升级后突破
local btn = RoleInfoPanel.PageList[1].upLvBtn:GetComponent("Button")
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, function()
RoleInfoPanel.PageList[1]:LvUpClick(true)
this.NextGuide()
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, this.NextGuide)
end)
this.SetBtnGOPosition(btn.gameObject:GetComponent("RectTransform").position)
elseif beType == 11 then --点击设置战斗2倍速
local btn = Util.GetGameObject (UIManager.uiNode, beArgs):GetComponent("Button")
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, function()
BattleManager.SetTimeScale(BATTLE_TIME_SCALE_TWO)
this.NextGuide()
this.button:GetComponent("Button").onClick:RemoveAllListeners()
BattleManager.ResumeBattle()
Util.AddClick(this.button, this.NextGuide)
end)
this.SetBtnGOPosition(btn.gameObject:GetComponent("RectTransform").position)
elseif beType == 12 then --点击fixedNode下界面按钮
this:SetSortingOrder(6300)
local btn = Util.GetGameObject (UIManager.fixedNode, beArgs):GetComponent("Button")
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, function()
local curGuideId = curId
btn.onClick:Invoke() --该按钮事件有可能会触发下一步引导,因此需要监听变化
if curGuideId == curId then
this.NextGuide()
end
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, this.NextGuide)
end)
this.SetBtnGOPosition(btn.gameObject:GetComponent("RectTransform").position)
elseif beType == 13 then --指示界面按钮提醒
local btn = Util.GetGameObject (UIManager.uiNode, beArgs)
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, function()
this.NextGuide()
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, this.NextGuide)
end)
this.SetBtnGOPosition(btn:GetComponent("RectTransform").position)
elseif beType == 14 then -- 根据当前显示的界面id跳转下一个引导节点如果当前界面没有显示则等待其显示
this.dialogRoot:SetActive(false)
this.mask:SetActive(false)
this.tipButtomRoot:SetActive(false)
this.gameObject:GetComponent("Image").raycastTarget = false
-- 条件节点
local conditions = {}
local strs = string.split(beArgs, "|")
for i, s in ipairs(strs) do
local ss = string.split(s, "#")
table.insert(conditions, {tonumber(ss[1]), tonumber(ss[2])})
end
-- 检测是否有在最上层的界面
for _, c in ipairs(conditions) do
local panel = c[1]
local nextId = c[2]
if UIManager.IsTopShow(panel) then
this.NextGuide(nextId)
return
end
end
-- 当有符合条件的界面时
local function OnFocus(id)
if not UIManager.IsTopShow(id) then return end
Timer.New(function()
for _, c in ipairs(conditions) do
local panel = c[1]
local nextId = c[2]
if id == panel and UIManager.IsTopShow(panel) then
this.ShowStory(nextId,OnFocus)
return
end
end
end, 0.2, 1):Start()
end
Game.GlobalEvent:AddEvent(GameEvent.UI.OnOpen, OnFocus)
Game.GlobalEvent:AddEvent(GameEvent.UI.OnFocus, OnFocus)
elseif beType == 15 then -- 强制跳转,关闭目前所有界面,跳转到指定界面
this.dialogRoot:SetActive(false)
this.mask:SetActive(false)
this.tipButtomRoot:SetActive(false)
local ss = string.split(beArgs, "#")
local params = {}
for i, s in ipairs(ss) do
local p = tonumber(s)
if p then
params[i] = p
else
params[i] = s
end
end
UIManager.CloseAllStack(true)
-- 先跳转引导
this.NextGuide()
-- 在跳转界面
UIManager.OpenPanel(unpack(params))
elseif beType == 16 then
this.canvas.enabled=false
this.dialogRoot:SetActive(false)
this.mask:SetActive(false)
this.tipButtomRoot:SetActive(false)
local isSkip=false
local function OnBtnClick(id,str)
nextDelayTime=0
nextDelayChange=true
isSkip=true
-- 先跳转引导
this.NextGuide()
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnBtnClicked, OnBtnClick)
end
Game.GlobalEvent:AddEvent(GameEvent.UI.OnBtnClicked, OnBtnClick)
local function OnUpdateData(id)
if isSkip then
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnUpdateData, OnUpdateData)
return
end
nextDelayTime=0
nextDelayChange=true
-- 先跳转引导
this.NextGuide()
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnUpdateData, OnUpdateData)
end
Game.GlobalEvent:AddEvent(GameEvent.UI.OnUpdateData, OnUpdateData)
elseif beType == 17 then
local HeroLikeAbilityPanel = UIManager.GetOpenPanel(UIName.HeroLikeAbilityPanel)
this.button:GetComponent("Button").onClick:RemoveAllListeners()
local _trigger = Util.GetEventTriggerListener(this.button)
local startFunc
local endFunc
local timePressStarted
_trigger.onPointerDown = _trigger.onPointerDown + HeroLikeAbilityPanel.OnPointerDo
startFunc = function()
timePressStarted = Time.realtimeSinceStartup
end
_trigger.onPointerDown = _trigger.onPointerDown + startFunc
_trigger.onPointerUp = _trigger.onPointerUp + HeroLikeAbilityPanel.OnPointerUp
endFunc = function()
_trigger.onPointerDown = _trigger.onPointerDown - HeroLikeAbilityPanel.OnPointerDo
_trigger.onPointerDown = _trigger.onPointerDown - startFunc
_trigger.onPointerUp = _trigger.onPointerUp - HeroLikeAbilityPanel.OnPointerUp
_trigger.onPointerUp = _trigger.onPointerUp - endFunc
this.NextGuide()
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, this.NextGuide)
end
_trigger.onPointerUp = _trigger.onPointerUp + endFunc
this.SetBtnGOPosition(HeroLikeAbilityPanel.giveBtn.gameObject:GetComponent("RectTransform").position)
elseif beType == 18 then -- 触发剧情节点
this.canvas.enabled=false
this.dialogRoot:SetActive(false)
this.mask:SetActive(false)
this.tipButtomRoot:SetActive(false)
StoryManager.EventTrigger(tonumber(beArgs), function()
this.NextGuide()
end)
elseif beType == 19 then -- 三倍速引导点击直接切换到3倍速
local btn = Util.GetGameObject(UIManager.uiRoot, beArgs):GetComponent("Button")
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, function()
-- 设置战斗3倍速
BattleManager.SetTimeScale(BATTLE_TIME_SCALE_THREE)
--
this.NextGuide()
this.button:GetComponent("Button").onClick:RemoveAllListeners()
Util.AddClick(this.button, this.NextGuide)
end)
this.SetBtnGOPosition(btn.gameObject:GetComponent("RectTransform").position)
elseif beType == 20 then -- 进入假战斗
this.canvas.enabled=false
this.dialogRoot:SetActive(false)
this.mask:SetActive(false)
this.tipButtomRoot:SetActive(false)
local fdata, fseed = BattleManager.GetFakeBattleData(tonumber(beArgs))
local testFightData = {
fightData = fdata,
fightSeed = fseed,
fightType = 0,
maxRound = 20
}
UIManager.OpenPanel(UIName.BattlePanel, testFightData, BATTLE_TYPE.Test)
end
end
function this.ShowStory(nextId,OnFocus)
if StoryMapManager.isShowStory ~= 0 then
local isShowStory = 1
if PlayerPrefs.HasKey("StoryMapPanel"..StoryMapManager.isShowStory..PlayerManager.uid) then
isShowStory = PlayerPrefs.GetInt("StoryMapPanel"..StoryMapManager.isShowStory..PlayerManager.uid)
end
if isShowStory == 1 then
this.gameObject:SetActive(false)
local function onCloseStoryMapPanel()
this.GameSetActive(nextId, OnFocus)
Game.GlobalEvent:RemoveEvent(GameEvent.GuaJi.CloseStoryMapPanel,onCloseStoryMapPanel)
end
Game.GlobalEvent:AddEvent(GameEvent.GuaJi.CloseStoryMapPanel,onCloseStoryMapPanel)
PlayerPrefs.SetInt("StoryMapPanel"..StoryMapManager.isShowStory..PlayerManager.uid,0)
StoryMapManager.InitData(StoryMapManager.isShowStory)
else
this.NextGuide(nextId)
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnOpen, OnFocus)
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnFocus, OnFocus)
end
else
this.NextGuide(nextId)
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnOpen, OnFocus)
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnFocus, OnFocus)
end
end
function this.GameSetActive(nextId, OnFocus)
this.gameObject:SetActive(true)
this.NextGuide(nextId)
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnOpen, OnFocus)
Game.GlobalEvent:RemoveEvent(GameEvent.UI.OnFocus, OnFocus)
end
function this.ShowGuide(id)
this.id = id
this.canvas.enabled = true
this.gameObject:GetComponent("Image").raycastTarget = true
if GuideConfig[id].Position then
this.dialogRoot:SetActive(true)
this.SetPosition(this.dialogRoot, GuideConfig[id].Position)
if GuideConfig[id].ArrowPosition[3] ~= -1 then
this.mask:SetActive(false)
this.tipButtomRoot:SetActive(true)
this.SetArrowPosition(id, GuideConfig[id].ArrowPosition)
this.dialogTip:SetActive(false)
else
this.mask:SetActive(true)
this.tipButtomRoot:SetActive(false)
this.dialogTip:SetActive(true)
end
else
this.dialogRoot:SetActive(false)
if GuideConfig[id].ArrowPosition[3] ~= -1 then
this.mask:SetActive(false)
this.tipButtomRoot:SetActive(true)
this.SetArrowPosition(id, GuideConfig[id].ArrowPosition)
elseif GuideConfig[id].BehaviorType and GuideConfig[id].BehaviorType ~= 0 then
this.ExecuteBehavior(GuideConfig[id].BehaviorType, GuideConfig[id].BehaviorArgs)
else
-- 直接进入下一步引导
this.NextGuide()
return
end
end
if GuideConfig[id].Desc then
local str = GetLanguageStrById(GuideConfig[id].Desc)
str = string.gsub(str, "{", "<color=#1F9E46>")
str = string.gsub(str, "}", "</color>")
this.desc.text = str
end
if IS_PLAY_VOICE and GuideConfig[id].Audio and GuideConfig[id].Audio ~= "" and GetCurLanguage() == 0 then
audio = SoundManager.PlaySound(GuideConfig[id].Audio)
end
PlayUIAnim(this.tipButtomRoot)
end
-- 下一个
function this.NextGuide(nextId)
if audio then
SoundManager.StopSound(audio)
end
GuideManager.SyncServer(curId)
local next = type(nextId) == "number" and nextId or GuideConfig[curId].Next
GuideManager.curId = next
Log("下一个引导Id = ".. tostring(next))
if next ~= 0 and GuideConfig[next].OpenType == 0 then --触发方式为0时直接跳转
GuideManager.ShowGuide(next)
elseif next ~= 0 and GuideConfig[next].OpenType == 27 then
GuideManager.ShowGuide(next)
elseif next ~= 0 and GuideConfig[next].OpenType == 39 then
if ActivityGiftManager.IsActivityTypeOpen(GuideConfig[next].OpenArgs[1]) then
GuideManager.ShowGuide(next)
else
this.NextGuide(GuideConfig[next].Next)
end
elseif next == 0 and GuideConfig[curId].BehaviorType == 14 then -- 分支节点特殊处理
this.ExecuteBehavior(GuideConfig[curId].BehaviorType, GuideConfig[curId].BehaviorArgs)
else
this:ClosePanel()
end
end
function this:OnSortingOrderChange()
self.upArrow:GetComponent("Canvas").sortingOrder = this.sortingOrder + 1
Util.AddParticleSortLayer(this.buttonIcon, this.sortingOrder - orginLayer)
orginLayer = this.sortingOrder
end
--界面打开时调用(用于子类重写)
function this:OnOpen(id, func, ...)
if not id then
return
end
this.closeFunc = func
curId = id
args = {...}
--if curId == 706 then
-- Game.GlobalEvent:DispatchEvent(GameEvent.Guide.GuidePanelScrollViewPos)
--end
LogError("id========================"..id)
if id==1 then
--疯体屏蔽创角奖励界面
-- UIManager.OpenPanel(UIName.GMEspecially)
end
this.gameObject:GetComponent("Image").raycastTarget = true
local delay = GuideConfig[id].DelayShow
if nextDelayChange then
delay=nextDelayTime
nextDelayChange=false
end
if delay > 0 then
this.dialogRoot:SetActive(false)
this.tipButtomRoot:SetActive(false)
this.mask:SetActive(false)
Timer.New(function () this.ShowGuide(id) end, delay):Start()
else
this.ShowGuide(id)
end
-- SkeletonGraphic = live2d:GetComponent("SkeletonGraphic")
-- SkeletonGraphic.AnimationState:SetAnimation(0, "touch", true)
-- Timer.New(function () SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true) end, 1.7):Start()
end
-- 播放动画
function this:PlayFoucsAnim(targetPos)
local startPos = UIManager.camera:ScreenToWorldPoint(Vector2.New(Screen.width/2, Screen.height/2))
this.buttonIcon:GetComponent("RectTransform").position = startPos
if this.moveTween then
this.moveTween:Kill()
end
this.tipButtomMat:SetFloat("_R", 1)
this.dialogRoot:SetActive(false)
this.moveTween = this.buttonIcon:GetComponent("RectTransform").transform:DOMove(targetPos,0.5):OnComplete(function()
if GuideConfig[this.id].Position then
this.dialogRoot:SetActive(true)
end
if self.tween then
self.tween:Kill()
end
self.tween = DoTween.To(DG.Tweening.Core.DOGetter_float( function () return 1 end),
DG.Tweening.Core.DOSetter_float(function (progress)
self.tipButtomMat:SetFloat("_R",progress)
end), 0.1, 0.2):SetEase(Ease.Linear)
end)
end
--界面关闭时调用(用于子类重写)
function this:OnClose()
--SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true)
if this.sortingOrder == 6300 then
this:SetSortingOrder(6000)
end
--防止频繁修改mat文件造成冲突
this.tipButtomMat:SetFloat("_X", 0.5)
this.tipButtomMat:SetFloat("_Y", 0.5)
this.tipButtomMat:SetFloat("_ScaleX", Screen.width / Screen.height)
if this.closeFunc then
this.closeFunc()
this.closeFunc = nil
end
end
--界面销毁时调用(用于子类重写)
function this:OnDestroy()
this.spLoader:Destroy()
end
return GuidePanel