miduo_client/Assets/ManagedResources/~Lua/Modules/Story/StoryMapPanel.lua

653 lines
26 KiB
Lua
Raw Normal View History

2021-04-22 15:06:47 +08:00
require("Base/BasePanel")
2021-04-26 09:41:41 +08:00
local StoryMapPanel = Inherit(BasePanel)
2021-04-22 15:06:47 +08:00
local this = StoryMapPanel
2021-04-26 09:41:41 +08:00
--local playerSpeed = 0
local curGroupId = 0
2021-04-22 15:06:47 +08:00
2021-04-26 09:41:41 +08:00
local storyMapConfig = ConfigManager.GetConfig(ConfigName.StoryMapConfig)
local chapterEventPointData = ConfigManager.GetConfig(ConfigName.ChapterEventPointConfig)
local artResConfig = ConfigManager.GetConfig(ConfigName.ArtResourcesConfig)
local curGroupConfig = {}
this.eventIndex = 0
2021-04-26 18:57:54 +08:00
this.showDiaLog = false
2021-04-26 09:41:41 +08:00
local lastLive2DId = 0
2021-04-27 19:51:40 +08:00
local sortingOrder = 0
local newSortingOrder = 0
2021-04-29 15:35:18 +08:00
local isSkip = false
local isFirstEnter = 1
2021-04-22 15:06:47 +08:00
--初始化组件(用于子类重写)
2021-04-26 09:41:41 +08:00
function StoryMapPanel:InitComponent()
this.map = Util.GetGameObject(self.gameObject,"bg/mapParent")
this.mapPre = Util.GetGameObject(self.gameObject,"bg/mapPre")
this.TT = Util.GetGameObject(self.gameObject,"bg/TT")
this.dialog = Util.GetGameObject(self.gameObject,"bg/dialog")
this.diaLogName = Util.GetGameObject(this.dialog,"Image")
this.diaLogNameText = Util.GetGameObject(this.diaLogName,"Name"):GetComponent("Text")
this.diaLogContent = Util.GetGameObject(this.dialog,"context"):GetComponent("Text")
-- 右切入
this.right2dRoot = Util.GetGameObject(self.gameObject, "rightLive2d")
-- 左切入
this.left2dRoot = Util.GetGameObject(self.gameObject, "leftLive2d")
-- 特效的节点
this.effectRoot = Util.GetGameObject(self.gameObject, "effectRoot")
-- 中间乱入的图片
this.showImg = Util.GetGameObject(self.gameObject, "showImg")
this.GoOn = Util.GetGameObject(self.gameObject,"bg/btnGoOn")
this.btnGoOn = Util.GetGameObject(this.GoOn ,"Click")
this.skip = Util.GetGameObject(self.gameObject,"bg/btnSkip")
this.btnSkip = Util.GetGameObject(this.skip,"btnGo")
2021-04-29 15:35:18 +08:00
this.btnSkipBtnComp = Util.GetGameObject(this.skip,"btnGo"):GetComponent("Button")
this.skip.gameObject:SetActive(true)
2021-04-26 09:41:41 +08:00
this.PlayerGrouops = {}
this.Maps = {}
2021-04-29 15:35:18 +08:00
this.mask = Util.GetGameObject(self.gameObject,"mask")
this.maskBtn = Util.GetGameObject(this.mask,"Button")
this.mask.gameObject:SetActive(false)
2021-04-22 15:06:47 +08:00
end
--绑定事件(用于子类重写)
2021-04-26 09:41:41 +08:00
function StoryMapPanel:BindEvent()
Util.AddClick(this.btnSkip, function ()
2021-04-29 15:35:18 +08:00
--StoryMapManager.GetSingleStoryConfig()
isSkip = true
this:StackPop()
2021-04-26 09:41:41 +08:00
end)
Util.AddClick(this.btnGoOn, function ()
this:ShowDialog()
2021-04-22 15:06:47 +08:00
end)
2021-04-29 15:35:18 +08:00
Util.AddClick(this.maskBtn, function ()
this.mask.gameObject:SetActive(false)
this:StackPop()
end)
2021-04-22 15:06:47 +08:00
end
--添加事件监听(用于子类重写)
2021-04-26 09:41:41 +08:00
function StoryMapPanel:AddListener()
2021-04-26 18:29:47 +08:00
Game.GlobalEvent:AddEvent(GameEvent.GuaJi.CloseStoryMapPanel,this.CloseThisPanel)
end
function this.CloseThisPanel()
this:ClosePanel()
2021-04-22 15:06:47 +08:00
end
--移除事件监听(用于子类重写)
2021-04-26 09:41:41 +08:00
function StoryMapPanel:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.GuaJi.CloseStoryMapPanel,this.ClosePanel)
2021-04-22 15:06:47 +08:00
end
--界面打开时调用(用于子类重写)
2021-04-26 09:41:41 +08:00
function StoryMapPanel:OnOpen(config)
2021-04-29 15:35:18 +08:00
this.mask.gameObject:SetActive(false)
this.map.transform.localPosition = Vector3.zero
2021-04-29 15:36:36 +08:00
--LogGreen("this.map.transform.localPosition:"..tostring(this.map.transform.localPosition))
2021-04-27 19:51:40 +08:00
sortingOrder = 0
2021-04-26 09:41:41 +08:00
this.PlayerGrouops = {}
this.triggerEvent = {}
2021-04-29 19:44:41 +08:00
this.callList = Stack.New()
2021-04-26 09:41:41 +08:00
curGroupConfig = config
curGroupId = config.Id
this.LoadMap()
2021-04-22 15:06:47 +08:00
this.LoadTT()
end
2021-04-26 09:41:41 +08:00
---加载跑图角色
function this.LoadTT()
if not curGroupConfig then
return
end
if curGroupConfig.MonsterRoads and #curGroupConfig.MonsterRoads > 0 then
for i = 1 ,#curGroupConfig.MonsterRoads do
this.PlayerGrouops[i] = SubUIManager.Open(SubUIConfig.SingleStoryPlayerView,this.TT.transform,this)
this.PlayerGrouops[i]:SetData(curGroupConfig.MonsterRoads[i],0,this)
end
end
this.PlayerGrouops[0] = SubUIManager.Open(SubUIConfig.SingleStoryPlayerView,this.TT.transform,this)
this.PlayerGrouops[0]:SetData(curGroupConfig.PlayerRoads,1,this)
end
function this.LoadMap()
if not curGroupConfig then
return
end
if not this.Maps then
this.Maps = {}
end
for i = 1 ,#this.Maps do
this.Maps[i].gameObject:SetActive(false)
end
for i = 1 ,#curGroupConfig.Map do
if not this.Maps[i] then
this.Maps[i] = newObjToParent(this.mapPre,this.map)
end
this.Maps[i]:GetComponent("Image").sprite = Util.LoadSprite(curGroupConfig.Map[i][1])
this.Maps[i]:GetComponent("Image"):SetNativeSize()
this.Maps[i].gameObject:SetActive(true)
local vecs = string.split(curGroupConfig.Map[i][2],',')
this.Maps[i]:GetComponent("RectTransform").localPosition = Vector3.New(tonumber(vecs[1]),tonumber(vecs[2]),tonumber(vecs[3]))
end
end
2021-04-22 15:06:47 +08:00
2021-04-26 09:41:41 +08:00
function StoryMapPanel:OnShow()
if not curGroupConfig.TriggerEvent or #curGroupConfig.TriggerEvent < 1 then
return
end
2021-04-29 19:44:41 +08:00
this.triggerEvent = {}
2021-04-26 09:41:41 +08:00
--初始化触发事件
for i = 1,#curGroupConfig.TriggerEvent do
local event = {}
event.eventType = curGroupConfig.TriggerEvent[i][1]
event.groups = {}
for j = 2,#curGroupConfig.TriggerEvent[i] do
table.insert(event.groups,curGroupConfig.TriggerEvent[i][j])
end
table.insert(this.triggerEvent,event)
end
2021-04-29 19:44:41 +08:00
this.callList:Clear()
2021-04-26 09:41:41 +08:00
for i = #this.triggerEvent,1,-1 do
this.callList:Push(function()
this:CheckTrigger(this.triggerEvent[i])
end)
end
this:StackPop()
end
2021-04-22 15:06:47 +08:00
2021-04-26 09:41:41 +08:00
function this:StackPop()
2021-04-27 19:51:40 +08:00
if this.callList:Count() > 0 then
this.callList:Pop()()
else
sortingOrder = newSortingOrder
StoryMapManager.GetSingleStoryConfig()
end
2021-04-26 09:41:41 +08:00
end
2021-04-27 22:21:14 +08:00
local pos = {
[1] = Vector3.New(-130,0,0),
[2] = Vector3.New(0,0,0),
[3] = Vector3.New(130,0,0),
[4] = Vector3.New(-130,-144,0),
2021-04-27 23:37:16 +08:00
[6] = Vector3.New(130,-144,0),
[7] = Vector3.New(-130,-288,0),
[8] = Vector3.New(0,-288,0),
[9] = Vector3.New(130,-288,0),
2021-04-27 22:21:14 +08:00
}
2021-04-22 15:06:47 +08:00
2021-04-26 09:41:41 +08:00
function this:CheckTrigger(data,go)
2021-04-29 15:35:18 +08:00
if isSkip then
2021-04-29 18:55:31 +08:00
--LogGreen("data.eventType:"..tostring(data.eventType).." this.curEvent.eventType:"..tostring(this.curEvent.eventType))
2021-04-29 15:35:18 +08:00
if (data.eventType == this.curEvent.eventType) then--(data.eventType ~= 3 and data.eventType ~= 1 and data.eventType ~= 2 and data.eventType ~= 10) or (data.eventType == this.curEvent.eventType) then
this:CloseDiaLog()
this:StackPop()
return
end
if this.curEvent.eventType == 2 then
for k,v in pairs(this.PlayerGrouops) do
v:StopAction()
end
end
if this.curEvent.eventType == 1 then
this:CloseDiaLog()
end
isSkip = false
end
2021-04-26 09:41:41 +08:00
this.go = go
2021-04-29 15:35:18 +08:00
this.curEvent = data
2021-04-26 09:41:41 +08:00
if data.eventType == 1 then -- 1 对话 2跑图 3假战斗
this.eventIndex = 0
this:ShowDialog()
elseif data.eventType == 2 then
this.eventIndex = 0
2021-04-27 19:51:40 +08:00
this:RunMap(data.eventType)
2021-04-26 09:41:41 +08:00
elseif data.eventType == 3 then
this.eventIndex = 0
--PopupTipPanel.ShowTip("进入一场假战斗")
this:EnterFight()
elseif data.eventType == 4 then --符咒闪烁了一下
this.eventIndex = 0
2021-04-27 19:51:40 +08:00
--PopupTipPanel.ShowTip("符咒闪烁了一下")
-- this:StackPop()
2021-04-29 15:35:18 +08:00
this.btnSkipBtnComp.enabled = false
2021-04-27 19:51:40 +08:00
if not this.UI_Effect_ChuFaEffect_04 then
this.UI_Effect_ChuFaEffect_04 = poolManager:LoadAsset("UI_Effect_ChuFaEffect_04", PoolManager.AssetType.GameObject)
this.UI_Effect_ChuFaEffect_04.name = "UI_Effect_ChuFaEffect_04"
this.UI_Effect_ChuFaEffect_04.transform:SetParent(this.effectRoot.transform)
this.UI_Effect_ChuFaEffect_04.transform.localPosition = Vector3.New(0,550,0)
this.UI_Effect_ChuFaEffect_04.transform.localScale = Vector3.one
end
this.UI_Effect_ChuFaEffect_04.gameObject:SetActive(true)
Util.AddParticleSortLayer(this.UI_Effect_ChuFaEffect_04,newSortingOrder - sortingOrder)
Timer.New(function()
2021-04-29 15:35:18 +08:00
if this.UI_Effect_ChuFaEffect_04 then
this.UI_Effect_ChuFaEffect_04.gameObject:SetActive(false)
this.btnSkipBtnComp.enabled = true
this:StackPop()
end
2021-04-27 19:51:40 +08:00
end,data.groups[1],1,false):Start()
2021-04-26 09:41:41 +08:00
elseif data.eventType == 5 then --符咒闪烁后消失
this.eventIndex = 0
2021-04-27 19:51:40 +08:00
if this.Maps and this.Maps[2] then
this.Maps[2].gameObject:SetActive(false)
end
2021-04-26 09:41:41 +08:00
this:StackPop()
elseif data.eventType == 6 then --符咒消失,金箍棒砸在主角和怪物中间。
this.eventIndex = 0
2021-04-29 15:35:18 +08:00
this.btnSkipBtnComp.enabled = false
2021-04-27 19:51:40 +08:00
if not this.UI_Effect_ChuFaEffect_01 then
this.UI_Effect_ChuFaEffect_01 = poolManager:LoadAsset("UI_Effect_ChuFaEffect_01", PoolManager.AssetType.GameObject)
this.UI_Effect_ChuFaEffect_01.name = "UI_Effect_ChuFaEffect_01"
this.UI_Effect_ChuFaEffect_01.transform:SetParent(this.effectRoot.transform)
this.UI_Effect_ChuFaEffect_01.transform.localPosition = Vector3.zero
this.UI_Effect_ChuFaEffect_01.transform.localScale = Vector3.one
end
Util.AddParticleSortLayer(this.UI_Effect_ChuFaEffect_01,newSortingOrder - sortingOrder)
this.UI_Effect_ChuFaEffect_01.gameObject:SetActive(true)
Timer.New(function()
2021-04-29 15:35:18 +08:00
if this.UI_Effect_ChuFaEffect_01 then
this.UI_Effect_ChuFaEffect_01.gameObject:SetActive(false)
end
this.btnSkipBtnComp.enabled = true
2021-04-27 19:51:40 +08:00
end,data.groups[1],1,false):Start()
2021-04-26 09:41:41 +08:00
this:StackPop()
2021-04-27 19:51:40 +08:00
--PopupTipPanel.ShowTip("符咒消失,金箍棒砸在主角和怪物中间。")
-- this:StackPop()
2021-04-26 09:41:41 +08:00
elseif data.eventType == 7 then
this.eventIndex = 0
2021-04-29 15:35:18 +08:00
this.btnSkipBtnComp.enabled = false
2021-04-27 19:51:40 +08:00
--PopupTipPanel.ShowTip("随着光芒闪烁,一把从天而降的神剑插在了一只怪物面前。")
if not this.UI_Effect_ChuFaEffect_02 then
this.UI_Effect_ChuFaEffect_02 = poolManager:LoadAsset("UI_Effect_ChuFaEffect_02", PoolManager.AssetType.GameObject)
this.UI_Effect_ChuFaEffect_02.name = "UI_Effect_ChuFaEffect_02"
this.UI_Effect_ChuFaEffect_02.transform:SetParent(this.effectRoot.transform)
2021-04-27 23:37:16 +08:00
this.UI_Effect_ChuFaEffect_02.transform.localPosition = Vector3.New(-415,700,0)
2021-04-27 19:51:40 +08:00
this.UI_Effect_ChuFaEffect_02.transform.localScale = Vector3.one
end
if not this.UI_Effect_ChuFaEffect_05 then
this.UI_Effect_ChuFaEffect_05 = poolManager:LoadAsset("UI_Effect_ChuFaEffect_05", PoolManager.AssetType.GameObject)
this.UI_Effect_ChuFaEffect_05.name = "UI_Effect_ChuFaEffect_05"
this.UI_Effect_ChuFaEffect_05.transform:SetParent(this.effectRoot.transform)
2021-04-27 23:37:16 +08:00
this.UI_Effect_ChuFaEffect_05.transform.localPosition = pos[8]
2021-04-27 19:51:40 +08:00
this.UI_Effect_ChuFaEffect_05.transform.localScale = Vector3.one
end
2021-04-27 23:37:16 +08:00
this.UI_Effect_ChuFaEffect_05.gameObject:SetActive(false)
2021-04-27 19:51:40 +08:00
Util.AddParticleSortLayer(this.UI_Effect_ChuFaEffect_02,newSortingOrder - sortingOrder)
Util.AddParticleSortLayer(this.UI_Effect_ChuFaEffect_05,newSortingOrder - sortingOrder)
2021-04-27 23:37:16 +08:00
this.UI_Effect_ChuFaEffect_02.gameObject:SetActive(true)
Timer.New(function()
this.UI_Effect_ChuFaEffect_02.gameObject:SetActive(false)
this.UI_Effect_ChuFaEffect_05.gameObject:SetActive(true)
end,data.groups[1],1,false):Start()
2021-04-27 22:21:14 +08:00
Timer.New(function()
if this.PlayerGrouops and this.PlayerGrouops[7] then
this.PlayerGrouops[7]:SetWalkDir(WALK_DIR.DEAD_BACK)
end
2021-04-27 23:37:16 +08:00
end,(data.groups[1] + 0.5),1,false):Start()
2021-04-27 22:21:14 +08:00
2021-04-27 19:51:40 +08:00
Timer.New(function()
this.UI_Effect_ChuFaEffect_05.gameObject:SetActive(false)
2021-04-29 15:35:18 +08:00
this.btnSkipBtnComp.enabled = true
2021-04-27 19:51:40 +08:00
this:StackPop()
2021-04-27 23:37:16 +08:00
end,(data.groups[1] + 0.5 + 1),1,false):Start()
2021-04-27 19:51:40 +08:00
--this:StackPop()
2021-04-26 09:41:41 +08:00
elseif data.eventType == 8 then
this.eventIndex = 0
2021-04-29 15:35:18 +08:00
this.btnSkipBtnComp.enabled = false
2021-04-27 19:51:40 +08:00
--PopupTipPanel.ShowTip("数把飞剑在主角身边依次落下,将身边一圈的怪物都扎死在剑下。随后剑放出光芒,形成环绕主角的法阵。")
-- this:StackPop()
if not this.effectBrowList then
this.effectBrowList = {}
end
2021-04-27 23:37:16 +08:00
local tempList = {7,4,1,2,3,6,9}
for k,v in pairs(tempList) do
if not this.effectBrowList[v] then
this.effectBrowList[v] = poolManager:LoadAsset("UI_Effect_ChuFaEffect_05", PoolManager.AssetType.GameObject)
this.effectBrowList[v].name = "UI_Effect_ChuFaEffect_05"
this.effectBrowList[v].transform:SetParent(this.effectRoot.transform)
this.effectBrowList[v].transform.localPosition = pos[v]
this.effectBrowList[v].transform.localScale = Vector3.one
this.effectBrowList[v].gameObject:SetActive(false)
2021-04-27 19:51:40 +08:00
end
end
local indexTemp = 0
Timer.New(function()
indexTemp = indexTemp + 1
2021-04-27 23:37:16 +08:00
Util.AddParticleSortLayer(this.effectBrowList[tempList[indexTemp]],newSortingOrder - sortingOrder)
this.effectBrowList[tempList[indexTemp]].gameObject:SetActive(true)
local index = 0
if tempList[indexTemp] < 5 then
index = tempList[indexTemp]
else
index = tempList[indexTemp] - 1
end
2021-04-29 18:55:31 +08:00
--LogGreen("index:"..index.." this.PlayerGrouops[index]:"..tostring(this.PlayerGrouops[index]))
2021-04-27 23:37:16 +08:00
if this.PlayerGrouops and this.PlayerGrouops[index] then
if index > 0 and index < 4 then
this.PlayerGrouops[index]:SetWalkDir(WALK_DIR.DEAD_FRONT)
elseif index == 4 then
this.PlayerGrouops[index]:SetWalkDir(WALK_DIR.DEAD_LEFT)
elseif index == 5 then
this.PlayerGrouops[index]:SetWalkDir(WALK_DIR.DEAD_RIGHT)
elseif index > 5 and index < 9 then
this.PlayerGrouops[index]:SetWalkDir(WALK_DIR.DEAD_BACK)
end
end
end,data.groups[1],7,false):Start()
2021-04-27 22:21:14 +08:00
2021-04-27 19:51:40 +08:00
Timer.New(function()
2021-04-27 23:37:16 +08:00
for k,v in pairs(this.effectBrowList) do
v.gameObject:SetActive(false)
2021-04-27 19:51:40 +08:00
end
2021-04-27 23:37:16 +08:00
2021-04-27 19:51:40 +08:00
if not this.UI_Effect_ChuFaEffect_03 then
this.UI_Effect_ChuFaEffect_03 = poolManager:LoadAsset("UI_Effect_ChuFaEffect_03", PoolManager.AssetType.GameObject)
this.UI_Effect_ChuFaEffect_03.name = "UI_Effect_ChuFaEffect_03"
this.UI_Effect_ChuFaEffect_03.transform:SetParent(this.effectRoot.transform)
2021-04-27 22:21:14 +08:00
this.UI_Effect_ChuFaEffect_03.transform.localPosition = Vector3.New(0,-183,0)
2021-04-27 19:51:40 +08:00
this.UI_Effect_ChuFaEffect_03.transform.localScale = Vector3.one
end
Util.AddParticleSortLayer(this.UI_Effect_ChuFaEffect_03,newSortingOrder - sortingOrder)
this.UI_Effect_ChuFaEffect_03.gameObject:SetActive(true)
Timer.New(function()
2021-04-29 15:35:18 +08:00
this.btnSkipBtnComp.enabled = true
2021-04-27 19:51:40 +08:00
this:StackPop()
2021-04-27 23:37:16 +08:00
end,1.3,1,false):Start()
2021-04-27 19:51:40 +08:00
end,data.groups[2],1,false):Start()
2021-04-26 18:29:47 +08:00
elseif data.eventType == 9 then --等待几秒
this.eventIndex = 0
2021-04-29 15:35:18 +08:00
this.btnSkipBtnComp.enabled = false
2021-04-26 18:29:47 +08:00
Timer.New(function()
2021-04-29 15:35:18 +08:00
this.btnSkipBtnComp.enabled = true
2021-04-26 18:29:47 +08:00
this:StackPop()
end,data.groups[1],1,false):Start()
elseif data.eventType == 10 then --保持某方向移动
this.eventIndex = 0
2021-04-27 19:51:40 +08:00
this:RunMap(data.eventType)
2021-04-29 15:35:18 +08:00
elseif data.eventType == 11 then --设置全屏遮罩,显示高亮位置点击区域
this.eventIndex = 0
2021-04-29 18:55:31 +08:00
this.btnSkipBtnComp.enabled = false
2021-04-29 15:35:18 +08:00
this.mask.gameObject:SetActive(true)
2021-04-29 18:55:31 +08:00
if not this.UI_Effect_ChuFaEffect_06 then
this.UI_Effect_ChuFaEffect_06 = poolManager:LoadAsset("UI_Effect_ChuFaEffect_06", PoolManager.AssetType.GameObject)
this.UI_Effect_ChuFaEffect_06.name = "UI_Effect_ChuFaEffect_06"
this.UI_Effect_ChuFaEffect_06.transform:SetParent(this.effectRoot.transform)
this.UI_Effect_ChuFaEffect_06.transform.localPosition = Vector3.New(50,532.2,0)
this.UI_Effect_ChuFaEffect_06.transform.localScale = Vector3.one
end
if not this.UI_Effect_ChuFaEffect_04 then
this.UI_Effect_ChuFaEffect_04 = poolManager:LoadAsset("UI_Effect_ChuFaEffect_04", PoolManager.AssetType.GameObject)
this.UI_Effect_ChuFaEffect_04.name = "UI_Effect_ChuFaEffect_04"
this.UI_Effect_ChuFaEffect_04.transform:SetParent(this.effectRoot.transform)
this.UI_Effect_ChuFaEffect_04.transform.localPosition = Vector3.New(0,550,0)
this.UI_Effect_ChuFaEffect_04.transform.localScale = Vector3.one
end
Util.AddParticleSortLayer(this.UI_Effect_ChuFaEffect_04,newSortingOrder - sortingOrder)
Util.AddParticleSortLayer(this.UI_Effect_ChuFaEffect_06,newSortingOrder - sortingOrder)
this.UI_Effect_ChuFaEffect_06.gameObject:SetActive(true)
this.UI_Effect_ChuFaEffect_04.gameObject:SetActive(true)
2021-04-29 15:35:18 +08:00
elseif data.eventType == 12 then --光芒四射的特效
--设置上一个特效为false
2021-04-29 18:55:31 +08:00
this.UI_Effect_ChuFaEffect_06.gameObject:SetActive(false)
2021-04-29 15:35:18 +08:00
--加载光芒四射的特效
2021-04-29 18:55:31 +08:00
if not this.UI_Effect_ChuFaEffect_07 then
this.UI_Effect_ChuFaEffect_07 = poolManager:LoadAsset("UI_Effect_ChuFaEffect_07", PoolManager.AssetType.GameObject)
this.UI_Effect_ChuFaEffect_07.name = "UI_Effect_ChuFaEffect_07"
this.UI_Effect_ChuFaEffect_07.transform:SetParent(this.effectRoot.transform)
this.UI_Effect_ChuFaEffect_07.transform.localPosition = Vector3.New(0,532.2,0)
this.UI_Effect_ChuFaEffect_07.transform.localScale = Vector3.one
end
Util.AddParticleSortLayer(this.UI_Effect_ChuFaEffect_07,newSortingOrder - sortingOrder)
this.UI_Effect_ChuFaEffect_07.gameObject:SetActive(true)
2021-04-29 15:35:18 +08:00
this.eventIndex = 0
this.btnSkipBtnComp.enabled = false
Timer.New(function()
2021-04-29 18:55:31 +08:00
this.UI_Effect_ChuFaEffect_04.gameObject:SetActive(false)
this.UI_Effect_ChuFaEffect_07.gameObject:SetActive(false)
2021-04-29 19:44:41 +08:00
this.btnSkipBtnComp.enabled = true
2021-04-29 15:35:18 +08:00
this:StackPop()
end,data.groups[1],1,false):Start()
2021-04-26 09:41:41 +08:00
end
end
2021-04-22 15:06:47 +08:00
2021-04-26 09:41:41 +08:00
function this:EnterFight()
this.eventIndex = this.eventIndex + 1
local fdata, fseed = BattleManager.GetFakeBattleData(this.curEvent.groups[this.eventIndex])
local testFightData = {
fightData = fdata,
fightSeed = fseed,
fightType = 0,
maxRound = 20,
}
2021-04-29 19:44:41 +08:00
UIManager.OpenPanel(UIName.BattlePanel, testFightData, BATTLE_TYPE.Test,function()
2021-04-26 09:41:41 +08:00
this:StackPop()
end)
end
2021-04-22 15:06:47 +08:00
2021-04-29 15:35:18 +08:00
function this:CloseDiaLog()
this.showDiaLog = false
this.dialog.gameObject:SetActive(false)
this.GoOn.gameObject:SetActive(false)
this.showImg:SetActive(false)
this.ReSetLive2d()
end
2021-04-26 09:41:41 +08:00
function this:ShowDialog()
this.eventIndex = this.eventIndex + 1
if #this.curEvent.groups < this.eventIndex then
2021-04-29 15:35:18 +08:00
this:CloseDiaLog()
2021-04-26 09:41:41 +08:00
if this.go then
this.go:StackPop()
this.go = nil
else
this:StackPop()
end
else
this.showImg:SetActive(false)
this.dialog.gameObject:SetActive(true)
this.GoOn.gameObject:SetActive(true)
local config = chapterEventPointData[this.curEvent.groups[this.eventIndex]]
2021-04-26 18:29:47 +08:00
if not config then
2021-04-29 18:55:31 +08:00
--LogGreen("this.curEvent.groups[this.eventIndex]:"..this.curEvent.groups[this.eventIndex].." this.eventIndex:"..this.eventIndex)
2021-04-26 18:29:47 +08:00
end
2021-04-26 09:41:41 +08:00
local showValues = GetLanguageStrById(config.ShowValues)
2021-04-22 15:06:47 +08:00
2021-04-26 09:41:41 +08:00
local options = config.Option
local dir = config.ShowDir
local live2dRoot = dir == 2 and this.left2dRoot or this.right2dRoot
local setId = config.DialogueViewId
2021-04-22 15:06:47 +08:00
2021-04-26 09:41:41 +08:00
-- 角色信息
local contents = string.split(showValues, "|")
local resId = tonumber(contents[1])
local contexts =(contents[2])
contexts = string.gsub(contexts, Language[11248], NameManager.roleName)
--this.diaLogNameText.text = ""
2021-04-29 15:35:18 +08:00
ShowText(this.diaLogContent.transform, contexts, 1)
2021-04-26 09:41:41 +08:00
this.SetList2d(resId,setId,live2dRoot)
2021-04-26 18:57:54 +08:00
if not this.showDiaLog then
PlayUIAnim(this.gameObject)
this.showDiaLog = true
end
2021-04-26 09:41:41 +08:00
--this.diaLogContent.text = contexts
end
end
2021-04-22 15:06:47 +08:00
2021-04-26 09:41:41 +08:00
function this.SetList2d(resId,setId,live2dRoot)
-- 显示立绘
if resId > 0 and resId ~= 999 then
local data = artResConfig[resId]
this.diaLogName.gameObject:SetActive(true)
this.diaLogNameText.text = string.gsub(GetLanguageStrById(data.Desc), Language[11252], NameManager.roleName)
2021-04-22 15:06:47 +08:00
2021-04-26 09:41:41 +08:00
local roleSex = NameManager.roleSex
local resPath
if resId == 8001 then --- 主角专用字段
resPath = roleSex == ROLE_SEX.BOY and StoryManager.boyRes or StoryManager.bitchRes
else
resPath = artResConfig[resId].Name
end
if lastLive2DId ~= resId then
-- 需要加载立绘的时候清除所有
this.ReSetLive2d()
if setId and setId ~= 0 then
StoryManager.InitLive2dState(setId, resPath, live2dRoot, this.effectRoot, true, this)
else
this.LoadLive2D(data, resPath, live2dRoot)
end
else
if setId then
StoryManager.InitLive2dState(setId, resPath, live2dRoot, this.effectRoot, false, this)
end
end
elseif resId == 999 then -- 显示图片
this.showImg:SetActive(true)
this.ReSetLive2d()
this.diaLogName.gameObject:SetActive(false)
if setId then
StoryManager.InitImgState(setId, this.showImg, this.effectRoot, this)
end
else
this.showImg:SetActive(false)
this.ReSetLive2d()
this.diaLogName.gameObject:SetActive(false)
end
lastLive2DId = resId
2021-04-22 15:06:47 +08:00
end
2021-04-26 09:41:41 +08:00
-- 清除立绘
function this.ReSetLive2d()
Util.ClearChild(this.left2dRoot.transform)
Util.ClearChild(this.right2dRoot.transform)
2021-04-22 15:06:47 +08:00
end
2021-04-27 19:51:40 +08:00
function this:RunMap(indexType)
2021-04-26 09:41:41 +08:00
if this.startTimer then
this.startTimer:Stop()
this.startTimer = nil
end
2021-04-29 15:35:18 +08:00
local dua = 0
if isFirstEnter == 1 then
isFirstEnter = 0
dua = 0.1
else
dua = 0
end
2021-04-26 09:41:41 +08:00
this.startTimer = Timer.New(function ()
for k,v in pairs(this.PlayerGrouops) do
2021-04-27 19:51:40 +08:00
v:RunMap(indexType)
2021-04-26 09:41:41 +08:00
end
2021-04-29 15:35:18 +08:00
end,dua)
2021-04-26 09:41:41 +08:00
this.startTimer:Start()
if this.startTimer1 then
this.startTimer1:Stop()
this.startTimer1 = nil
end
local isEnterNext = true
this.startTimer1 = Timer.New(function()
isEnterNext = true
for k,v in pairs(this.PlayerGrouops) do
if v:CheckState() then
isEnterNext = false
break
end
end
if isEnterNext then
this.startTimer1:Stop()
this.startTimer1 = nil
this:StackPop()
end
2021-04-26 18:29:47 +08:00
end,0.01,-1,false)
Timer.New(function()
2021-04-29 15:35:18 +08:00
if this.startTimer1 then
2021-04-26 18:29:47 +08:00
this.startTimer1:Start()
end
2021-04-26 18:57:54 +08:00
end,0.2,1,false):Start()
2021-04-22 15:06:47 +08:00
end
2021-04-26 09:41:41 +08:00
function StoryMapPanel:OnSortingOrderChange()
2021-04-27 19:51:40 +08:00
newSortingOrder = self.sortingOrder
2021-04-22 15:06:47 +08:00
end
--界面关闭时调用(用于子类重写)
2021-04-26 09:41:41 +08:00
function StoryMapPanel:OnClose()
2021-04-29 15:35:18 +08:00
isFirstEnter = 1
2021-04-26 09:41:41 +08:00
for k,v in pairs(this.PlayerGrouops) do
SubUIManager.Close(v)
end
this.PlayerGrouops = {}
if this.startTimer then
this.startTimer:Stop()
this.startTimer = nil
end
lastLive2DId = 0
2021-04-27 19:51:40 +08:00
this.showDiaLog = false
this.dialog.gameObject:SetActive(false)
this.GoOn.gameObject:SetActive(false)
this.showImg:SetActive(false)
2021-04-26 09:41:41 +08:00
this.ReSetLive2d()
this.callList:Clear()
2021-04-29 15:35:18 +08:00
isSkip = false
2021-04-26 09:41:41 +08:00
this.triggerEvent = {}
if this.startTimer then
this.startTimer:Stop()
this.startTimer = nil
end
if this.startTimer1 then
this.startTimer1:Stop()
this.startTimer1 = nil
end
this.map.transform.localPosition = Vector3.New(0,0,0)
2021-04-27 19:51:40 +08:00
if this.effectBrowList then
2021-04-27 23:37:16 +08:00
for k ,v in pairs(this.effectBrowList) do
v.gameObject:SetActive(false)
poolManager:UnLoadAsset(v.name, v, PoolManager.AssetType.GameObject)
2021-04-27 19:51:40 +08:00
end
this.effectBrowList = nil
end
if this.UI_Effect_ChuFaEffect_01 then
poolManager:UnLoadAsset("UI_Effect_ChuFaEffect_01", this.UI_Effect_ChuFaEffect_01, PoolManager.AssetType.GameObject)
this.UI_Effect_ChuFaEffect_01 = nil
end
if this.UI_Effect_ChuFaEffect_02 then
poolManager:UnLoadAsset("UI_Effect_ChuFaEffect_02", this.UI_Effect_ChuFaEffect_02, PoolManager.AssetType.GameObject)
this.UI_Effect_ChuFaEffect_02 = nil
end
if this.UI_Effect_ChuFaEffect_03 then
poolManager:UnLoadAsset("UI_Effect_ChuFaEffect_03", this.UI_Effect_ChuFaEffect_03, PoolManager.AssetType.GameObject)
this.UI_Effect_ChuFaEffect_03 = nil
end
if this.UI_Effect_ChuFaEffect_04 then
poolManager:UnLoadAsset("UI_Effect_ChuFaEffect_04", this.UI_Effect_ChuFaEffect_04, PoolManager.AssetType.GameObject)
this.UI_Effect_ChuFaEffect_04 = nil
end
if this.UI_Effect_ChuFaEffect_05 then
poolManager:UnLoadAsset("UI_Effect_ChuFaEffect_05", this.UI_Effect_ChuFaEffect_05, PoolManager.AssetType.GameObject)
this.UI_Effect_ChuFaEffect_05 = nil
end
2021-04-29 19:44:41 +08:00
if this.UI_Effect_ChuFaEffect_06 then
poolManager:UnLoadAsset("UI_Effect_ChuFaEffect_06", this.UI_Effect_ChuFaEffect_05, PoolManager.AssetType.GameObject)
this.UI_Effect_ChuFaEffect_06 = nil
end
if this.UI_Effect_ChuFaEffect_07 then
poolManager:UnLoadAsset("UI_Effect_ChuFaEffect_07", this.UI_Effect_ChuFaEffect_05, PoolManager.AssetType.GameObject)
this.UI_Effect_ChuFaEffect_07 = nil
end
2021-04-22 15:06:47 +08:00
end
--界面销毁时调用(用于子类重写)
2021-04-26 09:41:41 +08:00
function StoryMapPanel:OnDestroy()
for k,v in pairs(this.PlayerGrouops) do
SubUIManager.Close(v)
end
this.Maps = {}
this.PlayerGrouops = {}
if this.startTimer then
this.startTimer:Stop()
this.startTimer = nil
end
2021-04-22 15:06:47 +08:00
end
2021-04-26 09:41:41 +08:00
return this