640 lines
33 KiB
Lua
640 lines
33 KiB
Lua
require("Base/BasePanel")
|
|
ExpeditionMainPanel = Inherit(BasePanel)
|
|
local this = ExpeditionMainPanel
|
|
local nodeGrid = {}
|
|
local nodeItemGrid = {}
|
|
local timer = Timer.New()
|
|
local npc = ""
|
|
local GetCurNodeInfo = {}--当前操作层数据
|
|
local SkeletonGraphic--动画组件
|
|
local isPlayerMove = false--是否在播放人物行走动画
|
|
local isAllHaveAttack = false--是否有状态不一致情况 说明不是失败过 就是未领取圣物状态
|
|
local nodeGoTable = {}
|
|
local timer2 = Timer.New()
|
|
local liveNodeList = {}
|
|
local targetPosGoAndData
|
|
local expeditionLeveTable = {
|
|
[1] = {numStr = "一",nodDi1 = "d_danaotiangong_taizi_01",nodDi2 = "d_danaotiangong_xuanzhongguang_01"},
|
|
[2] = {numStr = "二",nodDi1 = "d_danaotiangong_taizi_01",nodDi2 = "d_danaotiangong_xuanzhongguang_01"},
|
|
[3] = {numStr = "三",nodDi1 = "d_danaotiangong_taizi_01",nodDi2 = "d_danaotiangong_xuanzhongguang_01"},
|
|
[4] = {numStr = "三",nodDi1 = "d_danaotiangong_taizi_02",nodDi2 = "d_danaotiangong_xuanzhongguang_02"},
|
|
}
|
|
local layListGrid = {}
|
|
local cursortingOrder = 0
|
|
--初始化组件(用于子类重写)
|
|
function ExpeditionMainPanel:InitComponent()
|
|
cursortingOrder = 0
|
|
self.parent = Util.GetGameObject(self.gameObject, "parent")
|
|
self.gridMask = Util.GetGameObject(self.gameObject, "rect/grid/mask")
|
|
self.gridMaskImage = Util.GetGameObject(self.gameObject, "rect/grid/mask/Image"):GetComponent("RectTransform")
|
|
self.bg1 = Util.GetGameObject(self.gameObject, "bg/bg (1)")
|
|
self.bg2 = Util.GetGameObject(self.gameObject, "bg/bg (2)")
|
|
self.backBtn = Util.GetGameObject(self.parent, "lowGO/btnBack")
|
|
self.Btn1 = Util.GetGameObject(self.parent, "lowGO/Btn1")
|
|
self.Btn2 = Util.GetGameObject(self.parent, "lowGO/Btn2")
|
|
self.Btn3 = Util.GetGameObject(self.parent, "lowGO/Btn3")
|
|
self.Btn4 = Util.GetGameObject(self.parent, "upLeftGo/Btn4")
|
|
self.helpBtn = Util.GetGameObject(self.parent, "upLeftGo/helpBtn")
|
|
self.redPoint = Util.GetGameObject(self.parent, "upLeftGo/Btn4/redPoint")
|
|
self.helpPos = Util.GetGameObject(self.parent, "upLeftGo/helpBtn"):GetComponent("RectTransform").localPosition
|
|
self.titleImageText = Util.GetGameObject(self.parent, "titleImage/titleImage (1)"):GetComponent("Text")
|
|
self.timeTextGo = Util.GetGameObject(self.parent, "titleImage/timeText")
|
|
self.timeText = Util.GetGameObject(self.parent, "titleImage/timeText"):GetComponent("Text")
|
|
nodeGrid = {}
|
|
nodeItemGrid = {}
|
|
for i = 1, 1 do
|
|
nodeGrid[i] = Util.GetGameObject(self.gameObject, "rect/grid/singlePre ("..i..")")
|
|
local nodeGridItemsGri = {}
|
|
for j = 1, 3 do
|
|
nodeGridItemsGri[j] = Util.GetGameObject(nodeGrid[i], "itemList/item ("..j..")")
|
|
end
|
|
nodeItemGrid[i] = nodeGridItemsGri
|
|
end
|
|
self.mask = Util.GetGameObject(self.parent, "mask")
|
|
self.mask:SetActive(false)
|
|
self.UI_effect_BaoXiang = Util.GetGameObject(self.gameObject, "bg/UI_effect_BaoXiang")
|
|
npc = NameManager.roleSex == ROLE_SEX.BOY and "live2d_npc_map" or "live2d_npc_map_nv"
|
|
local scale = NameManager.roleSex == ROLE_SEX.BOY and Vector3.one*0.2 or Vector3.one * 0.12
|
|
self.liveNode = poolManager:LoadLive(npc, Util.GetTransform(self.parent, "playerLive"), scale, Vector3.zero)
|
|
SkeletonGraphic = self.liveNode:GetComponent("SkeletonGraphic")
|
|
if SkeletonGraphic then
|
|
SkeletonGraphic.AnimationState:SetAnimation(0, "move2", true)
|
|
SkeletonGraphic.transform.localEulerAngles = Vector3.New(0, 0, 0)
|
|
end
|
|
self.singlePre = Util.GetGameObject(self.transform, "singlePre")
|
|
self.grid = Util.GetGameObject(self.transform, "rect/grid")
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function ExpeditionMainPanel:BindEvent()
|
|
Util.AddClick(self.backBtn, function()
|
|
if isPlayerMove == false then
|
|
self:ClosePanel()
|
|
end
|
|
end)
|
|
Util.AddClick(self.Btn1, function()
|
|
UIManager.OpenPanel(UIName.ExpeditionHeroListResurgencePopup)
|
|
end)
|
|
Util.AddClick(self.Btn2, function()
|
|
UIManager.OpenPanel(UIName.ExpeditionHeroListInfoPopup)
|
|
end)
|
|
Util.AddClick(self.Btn3, function()
|
|
UIManager.OpenPanel(UIName.ExpeditionHalidomPanel)
|
|
end)
|
|
Util.AddClick(self.Btn4, function()
|
|
UIManager.OpenPanel(UIName.TreasureOfHeavenPanel)
|
|
--PopupTipPanel.ShowTip("不可领取奖励!")
|
|
end)
|
|
Util.AddClick(self.helpBtn, function()
|
|
UIManager.OpenPanel(UIName.HelpPopup,HELP_TYPE.Expedition,self.helpPos.x,self.helpPos.y)
|
|
end)
|
|
BindRedPointObject(RedPointType.Expedition_Treasure, self.redPoint)
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function ExpeditionMainPanel:AddListener()
|
|
Game.GlobalEvent:AddEvent(GameEvent.Expedition.RefreshPlayAniMainPanel, self.PlayerMoveFun, self)
|
|
Game.GlobalEvent:AddEvent(GameEvent.Expedition.RefreshMainPanel, self.OnShowNodeData, self)
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function ExpeditionMainPanel:RemoveListener()
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Expedition.RefreshPlayAniMainPanel, self.PlayerMoveFun, self)
|
|
Game.GlobalEvent:RemoveEvent(GameEvent.Expedition.RefreshMainPanel, self.OnShowNodeData, self)
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function ExpeditionMainPanel:OnOpen()
|
|
self:OnShowNodeData()
|
|
if ExpeditionManager.GetActivityStarOpenRedPoint() then
|
|
PlayerPrefs.SetInt(PlayerManager.uid.."Expedition", 1)
|
|
end
|
|
local timeNum = (ExpeditionManager.startTime + ConfigManager.GetConfigData(ConfigName.GlobalSystemConfig,JumpType.Expedition).SeasonInterval ) - GetTimeStamp()
|
|
self:RemainTimeDown(self.timeTextGo,self.timeText,timeNum)
|
|
end
|
|
function ExpeditionMainPanel:OnSortingOrderChange()
|
|
self.gridMask:GetComponent("Canvas").sortingOrder = self.sortingOrder + 1
|
|
self.parent:GetComponent("Canvas").sortingOrder = self.sortingOrder + 2
|
|
--cursortingOrder = self.sortingOrder
|
|
end
|
|
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
|
|
function ExpeditionMainPanel:OnShow()
|
|
-- isAllHaveAttack = false
|
|
-- nodeGoTable = {}
|
|
-- self:OnShowNodeData()
|
|
--self:StarPlayerMoveFun()
|
|
-- 音效
|
|
SoundManager.PlayMusic(SoundConfig.BGM_Carbon)
|
|
end
|
|
--实例化层数信息
|
|
function ExpeditionMainPanel:OnShowNodeData()
|
|
isPlayerMove = false
|
|
isAllHaveAttack = false
|
|
nodeGoTable = {}
|
|
self.titleImageText.text = "大闹天宫 第"..expeditionLeveTable[ExpeditionManager.expeditionLeve].numStr.."层"
|
|
self.bg1:SetActive(ExpeditionManager.expeditionLeve ~= 4)
|
|
self.bg2:SetActive(ExpeditionManager.expeditionLeve == 4)
|
|
ExpeditionManager.ExpeditionRrefreshFormation()--刷新编队
|
|
ExpeditionManager.GetActivityIsShowRedPoint(false,"1")--刷新红点
|
|
self.mask:SetActive(isPlayerMove)
|
|
self.UI_effect_BaoXiang.transform:SetParent(self.transform)
|
|
self.UI_effect_BaoXiang:SetActive(false)
|
|
--节点
|
|
local AllLayNodeList = ExpeditionManager.GetAllLayNodeList()--所有层所有节点信息
|
|
if AllLayNodeList == nil then return end
|
|
local curAllLayNodeList = {}
|
|
for i = #AllLayNodeList, 1, -1 do--从下到上显示 所以倒序
|
|
table.insert(curAllLayNodeList,AllLayNodeList[i])
|
|
end
|
|
GetCurNodeInfo = ExpeditionManager.GetCurNodeInfo()
|
|
self.gridMaskImage.sizeDelta = Vector2.New(0,(3000/#curAllLayNodeList)*(#curAllLayNodeList - (GetCurNodeInfo.lay + 2)))
|
|
for i = 1, math.max(#curAllLayNodeList, #layListGrid) do
|
|
local go = layListGrid[i]
|
|
if not go then
|
|
go = newObject(self.singlePre)
|
|
go.transform:SetParent(self.grid.transform)
|
|
go.transform.localScale = Vector3.one
|
|
go.transform.localPosition = Vector3.zero
|
|
layListGrid[i] = go
|
|
end
|
|
go.gameObject:SetActive(false)
|
|
end
|
|
for i = 1, #AllLayNodeList do
|
|
ExpeditionMainPanel:SingleLayNodeShow(layListGrid[i],curAllLayNodeList[i])
|
|
layListGrid[i]:SetActive(true)
|
|
end
|
|
local gridH = 2566--self.grid:GetComponent("RectTransform").sizeDelta.y
|
|
local rectH = 1656--self.grid.transform.parent:GetComponent("RectTransform").sizeDelta.y
|
|
local endH = gridH - rectH
|
|
local curlay = GetCurNodeInfo.lay
|
|
if curlay <= 4 then
|
|
local y = endH / 4
|
|
y = endH - (curlay - 1) * y
|
|
self.grid:GetComponent("RectTransform").anchoredPosition = Vector3.New(0,y,0)
|
|
end
|
|
--self.ScrollView:SetData(curAllLayNodeList, function (index, go)
|
|
-- self:SingleLayNodeShow(go,curAllLayNodeList[index],(#AllLayNodeList - index) + 1)
|
|
--end)
|
|
--LogError("#AllLayNodeList - GetCurNodeInfo.lay "..#AllLayNodeList - GetCurNodeInfo.lay)
|
|
--local curIndex = #AllLayNodeList - GetCurNodeInfo.lay
|
|
--if curIndex == 0 then
|
|
-- curIndex = curIndex + 1
|
|
--end
|
|
--self.ScrollView:SetIndex(curIndex)
|
|
end
|
|
|
|
--实例化每层信息
|
|
function ExpeditionMainPanel:SingleLayNodeShow(go,layNodeListData)
|
|
nodeGoTable[go.name] = {data = layNodeListData,goData = go}
|
|
local nodeGo = go
|
|
--卸载加载的立绘
|
|
if liveNodeList[go] then
|
|
for i = 1, #liveNodeList[go] do
|
|
local item = liveNodeList[go][i]
|
|
poolManager:UnLoadLive(item.name, item.go, PoolManager.AssetType.GameObject)
|
|
end
|
|
end
|
|
liveNodeList[go] = {}
|
|
--判断是否有未打赢过 和 未获取圣物的状态
|
|
local isAttack = false
|
|
for j = 1, 3 do
|
|
Util.GetGameObject(nodeGo, "itemList/item ("..j..")"):SetActive(false)
|
|
if #layNodeListData >= j then
|
|
if (layNodeListData[j].state == ExpeditionNodeState.NoPass or layNodeListData[j].state == ExpeditionNodeState.NoGetEquip) and GetCurNodeInfo.lay == layNodeListData[j].lay then
|
|
isAttack = true
|
|
isAllHaveAttack = true
|
|
end
|
|
end
|
|
end
|
|
if self.liveNode then
|
|
self.liveNode:SetActive(true)--玩家形象立绘
|
|
end
|
|
for i = 1, #layNodeListData do--每个节点显示
|
|
--LogError(layNodeListData[i].lay.." "..layNodeListData[i].sortId.." "..layNodeListData[i].state.." "..GetCurNodeInfo.lay)
|
|
Util.GetGameObject(nodeGo, "itemList/item ("..i..")"):SetActive(true)
|
|
--Util.GetGameObject(nodeGo, "itemList/item ("..i..")"):GetComponent("PlayFlyAnim"):PlayHideAnim()
|
|
Util.GetGameObject(nodeGo, "itemList/item ("..i..")/parent").transform.localPosition = Vector3.zero
|
|
local curItemGo = Util.GetGameObject(nodeGo, "itemList/item ("..i..")/parent")
|
|
self:SingleNodeInfoIconShow(curItemGo,layNodeListData[i],isAttack)
|
|
---实例化动画---
|
|
if GetCurNodeInfo.lay <= layNodeListData[i].lay and layNodeListData[i].lay ~= 1 then
|
|
liveNodeList[go][i] = self:InitLiveSet(layNodeListData[i].type, Util.GetGameObject(curItemGo, "goParent"))
|
|
end
|
|
--------------
|
|
Util.GetGameObject(curItemGo, "infoIcon"):SetActive(true)
|
|
local pedestalImage = Util.GetGameObject(curItemGo, "pedestalImage")
|
|
local goParent = Util.GetGameObject(curItemGo, "goParent")
|
|
local halidomParent = Util.GetGameObject(curItemGo, "halidomParent")
|
|
pedestalImage:GetComponent("Image").sprite = Util.LoadSprite(expeditionLeveTable[ExpeditionManager.expeditionLeve].nodDi1)
|
|
local okAttackDi = Util.GetGameObject(curItemGo, "okAttackDi")
|
|
okAttackDi:GetComponent("Image").sprite = Util.LoadSprite(expeditionLeveTable[ExpeditionManager.expeditionLeve].nodDi2)
|
|
local okAttackImage = Util.GetGameObject(curItemGo, "okAttackImage")
|
|
okAttackImage:SetActive(layNodeListData[i].state == ExpeditionNodeState.NoPass or layNodeListData[i].state == ExpeditionNodeState.NoGetEquip)
|
|
okAttackDi:SetActive(layNodeListData[i].state == ExpeditionNodeState.NoPass or layNodeListData[i].state == ExpeditionNodeState.NoGetEquip)
|
|
Util.GetGameObject(curItemGo, "click"):SetActive(true)
|
|
local clickbtn = Util.GetGameObject(curItemGo, "click")
|
|
local pos = Util.GetGameObject(curItemGo, "pos")--节点位置 人物动画用
|
|
--pos.transform.localPosition = Vector3.New(0,-10,0)
|
|
pedestalImage:SetActive(true)
|
|
goParent:SetActive(true)
|
|
halidomParent:SetActive(true)
|
|
clickbtn:SetActive(true)
|
|
if layNodeListData[i].lay < GetCurNodeInfo.lay then
|
|
goParent:SetActive(false)
|
|
halidomParent:SetActive(false)
|
|
okAttackImage:SetActive(false)
|
|
okAttackDi:SetActive(false)
|
|
Util.GetGameObject(curItemGo, "click"):SetActive(false)
|
|
Util.GetGameObject(curItemGo, "infoIcon"):SetActive(false)
|
|
if layNodeListData[i].state == ExpeditionNodeState.Over then--未打但已通过
|
|
pedestalImage:SetActive(false)
|
|
end
|
|
elseif layNodeListData[i].lay == GetCurNodeInfo.lay then
|
|
if layNodeListData[i].state == ExpeditionNodeState.No then--未打过
|
|
elseif layNodeListData[i].state == ExpeditionNodeState.NoPass then--打未通过
|
|
elseif layNodeListData[i].state == ExpeditionNodeState.NoGetEquip then--未领取圣物
|
|
elseif layNodeListData[i].state == ExpeditionNodeState.Finish then--已打过
|
|
self:PlayerMovePosFun(pos,nodeGo,curItemGo)
|
|
goParent:SetActive(false)
|
|
elseif layNodeListData[i].state == ExpeditionNodeState.Over then--未打但已通过
|
|
goParent:SetActive(false)
|
|
halidomParent:SetActive(false)
|
|
okAttackImage:SetActive(false)
|
|
okAttackDi:SetActive(false)
|
|
Util.GetGameObject(curItemGo, "click"):SetActive(false)
|
|
pedestalImage:SetActive(false)
|
|
Util.GetGameObject(curItemGo, "infoIcon"):SetActive(false)
|
|
end
|
|
elseif layNodeListData[i].lay > GetCurNodeInfo.lay then
|
|
if layNodeListData[i].state == ExpeditionNodeState.No then--打未通过
|
|
if layNodeListData[i].lay >= GetCurNodeInfo.lay + 3 then
|
|
if layNodeListData[i].type == ExpeditionNodeType.Jy or layNodeListData[i].type == ExpeditionNodeType.Common then
|
|
goParent:SetActive(false)
|
|
clickbtn:SetActive(false)
|
|
end
|
|
end
|
|
elseif layNodeListData[i].state == ExpeditionNodeState.NoPass then--打未通过
|
|
elseif layNodeListData[i].state == ExpeditionNodeState.NoGetEquip then--未领取圣物
|
|
goParent:SetActive(false)
|
|
self.UI_effect_BaoXiang.transform:SetParent(halidomParent.transform)
|
|
self.UI_effect_BaoXiang.transform.localPosition=Vector3.zero;
|
|
self.UI_effect_BaoXiang:SetActive(true)
|
|
elseif layNodeListData[i].state == ExpeditionNodeState.Over then--未打但已通过
|
|
pedestalImage:SetActive(false)
|
|
end
|
|
end
|
|
Util.AddOnceClick(clickbtn, function()
|
|
if isPlayerMove then return end
|
|
ExpeditionManager.curAttackNodeInfo = layNodeListData[i]
|
|
targetPosGoAndData = {pos = pos,layGo = nodeGo,layAllData = layNodeListData,curNodeData = layNodeListData[i]}
|
|
if layNodeListData[i].state == ExpeditionNodeState.No then
|
|
if layNodeListData[i].type == ExpeditionNodeType.Boss or layNodeListData[i].type == ExpeditionNodeType.Jy or layNodeListData[i].type == ExpeditionNodeType.Common then
|
|
UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.Monster,layNodeListData[i],1)
|
|
elseif layNodeListData[i].type == ExpeditionNodeType.Reply then--回复节点
|
|
local num = ConfigManager.GetConfigData(ConfigName.ExpeditionSetting,1).RegeneratePercent/100
|
|
MsgPanel.ShowOne("一眼神奇的甘泉,可使所有存活的猎妖师回复生命上限"..num.."%的生命值!", nil, "确定", "蟠桃树")
|
|
elseif layNodeListData[i].type == ExpeditionNodeType.Resurgence then--复活节点
|
|
MsgPanel.ShowOne("神灵赐福的玉蝶,散发着五彩神光,可复活一个已死亡的猎妖师,若无猎妖师死亡,则随机将一个猎妖师恢复至满血。", nil, "确定", "八卦炼丹炉")
|
|
elseif layNodeListData[i].type == ExpeditionNodeType.Recruit then--招募节点
|
|
UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.Recruit,layNodeListData[i],1)
|
|
elseif layNodeListData[i].type == ExpeditionNodeType.Shop then--商店节点
|
|
UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.Shop,layNodeListData[i],1)
|
|
elseif layNodeListData[i].type == ExpeditionNodeType.Trail then--试炼节点
|
|
UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.Trail,layNodeListData[i],1)
|
|
elseif layNodeListData[i].type == ExpeditionNodeType.Greed then--贪婪节点
|
|
UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.Greed,layNodeListData[i],1)
|
|
elseif layNodeListData[i].type == ExpeditionNodeType.Reward then--最后奖励节点
|
|
PopupTipPanel.ShowTip("不可领取奖励!")
|
|
end
|
|
elseif layNodeListData[i].state == ExpeditionNodeState.NoPass then
|
|
if layNodeListData[i].type == ExpeditionNodeType.Boss or layNodeListData[i].type == ExpeditionNodeType.Jy or layNodeListData[i].type == ExpeditionNodeType.Common then
|
|
UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.Monster,layNodeListData[i],2)
|
|
elseif layNodeListData[i].type == ExpeditionNodeType.Halidom then--圣物节点
|
|
UIManager.OpenPanel(UIName.ExpeditionSelectHalidomPanel,false)
|
|
elseif layNodeListData[i].type == ExpeditionNodeType.Reply then--回复节点
|
|
local num = ConfigManager.GetConfigData(ConfigName.ExpeditionSetting,1).RegeneratePercent/100
|
|
MsgPanel.ShowOne("一眼神奇的甘泉,可使所有存活的猎妖师回复生命上限"..num.."%的生命值,是否前往?", function()
|
|
NetManager.ReCoverExpeditionHeroRequest(layNodeListData[i].sortId,function (msg)
|
|
ExpeditionManager.UpdateHeroHpValue(msg.heroInfo)
|
|
self:PlayerMoveFun()
|
|
PopupTipPanel.ShowTip("已成功复活猎妖师!")
|
|
end)
|
|
end, "前往", "蟠桃树")
|
|
elseif layNodeListData[i].type == ExpeditionNodeType.Resurgence then--复活节点
|
|
MsgPanel.ShowOne("神灵赐福的玉蝶,散发着五彩神光,可复活一个已死亡的猎妖师,若无猎妖师死亡,则随机将一个猎妖师恢复至满血。", function()
|
|
local cueSelectHeroDid = self:HeroResurgence()
|
|
--LogError("cueSelectHeroDid "..cueSelectHeroDid)
|
|
NetManager.ReliveExpeditionHeroRequest(cueSelectHeroDid,layNodeListData[i].sortId,function()
|
|
PopupTipPanel.ShowTip("已成功复活猎妖师!")
|
|
self:PlayerMoveFun()
|
|
end)
|
|
end, "前往", "八卦炼丹炉")
|
|
elseif layNodeListData[i].type == ExpeditionNodeType.Recruit then--招募节点
|
|
UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.Recruit,layNodeListData[i],2,function ()
|
|
self:PlayerMoveFun()
|
|
end)
|
|
elseif layNodeListData[i].type == ExpeditionNodeType.Shop then--商店节点
|
|
UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.Shop,layNodeListData[i],2,function ()
|
|
self:PlayerMoveFun()
|
|
end)
|
|
|
|
elseif layNodeListData[i].type == ExpeditionNodeType.Trail then--试炼节点
|
|
UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.Trail,layNodeListData[i],2)
|
|
elseif layNodeListData[i].type == ExpeditionNodeType.Greed then--贪婪节点
|
|
UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.Greed,layNodeListData[i],2)
|
|
elseif layNodeListData[i].type == ExpeditionNodeType.Reward then--最后奖励节点
|
|
NetManager.TakeExpeditionBoxRewardRequest( layNodeListData[i].sortId,function (msg)
|
|
UIManager.OpenPanel(UIName.RewardItemPopup,msg.drop,1,function ()
|
|
--LogError("#msg.leve "..#msg.leve)
|
|
if #msg.leve > 1 then
|
|
MsgPanel.ShowTwo("普通模式 or 困难模式?", function()
|
|
ExpeditionManager.expeditionLeve = msg.leve[1]
|
|
self:RefreshManagerData()
|
|
end, function()
|
|
ExpeditionManager.expeditionLeve = msg.leve[2]
|
|
self:RefreshManagerData()
|
|
end, "普通","困难")
|
|
elseif #msg.leve == 1 then
|
|
ExpeditionManager.expeditionLeve = msg.leve[1]
|
|
MsgPanel.ShowOne("前往下一层", function()
|
|
self:RefreshManagerData()
|
|
end)
|
|
else
|
|
PopupTipPanel.ShowTip("已通关本次大闹天宫!")
|
|
end
|
|
end)
|
|
end)
|
|
end
|
|
elseif layNodeListData[i].state == ExpeditionNodeState.NoGetEquip then
|
|
UIManager.OpenPanel(UIName.ExpeditionSelectHalidomPanel,false)
|
|
elseif layNodeListData[i].state == ExpeditionNodeState.Finish then
|
|
PopupTipPanel.ShowTip("已完成!")
|
|
elseif layNodeListData[i].state == ExpeditionNodeState.Over then
|
|
PopupTipPanel.ShowTip("已通过!")
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
--刷新倒计时显示
|
|
function ExpeditionMainPanel:RemainTimeDown(_timeTextExpertgo,_timeTextExpert,timeDown)
|
|
if timeDown > 0 then
|
|
_timeTextExpertgo:SetActive(true)
|
|
_timeTextExpert.text = "剩余时间:"..self:TimeStampToDateString(timeDown)
|
|
if timer then
|
|
timer:Stop()
|
|
timer = nil
|
|
end
|
|
timer = Timer.New(function()
|
|
_timeTextExpert.text = "剩余时间:"..self:TimeStampToDateString(timeDown)
|
|
if timeDown < 0 then
|
|
_timeTextExpertgo:SetActive(false)
|
|
timer:Stop()
|
|
timer = nil
|
|
end
|
|
timeDown = timeDown - 1
|
|
end, 1, -1, true)
|
|
timer:Start()
|
|
else
|
|
_timeTextExpertgo:SetActive(false)
|
|
end
|
|
end
|
|
|
|
function ExpeditionMainPanel:TimeStampToDateString(second)
|
|
local day = math.floor(second / (24 * 3600))
|
|
local minute = math.floor(second / 60) % 60
|
|
local sec = second % 60
|
|
local hour = math.floor(math.floor(second - day * 24 * 3600 - sec - minute * 60) / 3600)
|
|
return string.format("%02d时%02d分%02d秒", hour, minute, sec)
|
|
end
|
|
--界面关闭时调用(用于子类重写)
|
|
function ExpeditionMainPanel:OnClose()
|
|
|
|
if timer then
|
|
timer:Stop()
|
|
timer = nil
|
|
end
|
|
if timer2 then
|
|
timer2:Stop()
|
|
timer2 = nil
|
|
end
|
|
end
|
|
|
|
--界面销毁时调用(用于子类重写)
|
|
function ExpeditionMainPanel:OnDestroy()
|
|
|
|
--if live2dList and #live2dList > 0 then
|
|
-- for i = 1, #live2dList do
|
|
-- poolManager:UnLoadLive(live2dList[i][1], live2dList[i][2], PoolManager.AssetType.GameObject)
|
|
-- live2dList[i] = nil
|
|
-- end
|
|
--end
|
|
--live2dList = {}
|
|
if self.liveNode then
|
|
poolManager:UnLoadLive(npc, self.liveNode, PoolManager.AssetType.GameObject)
|
|
self.liveNode = nil
|
|
end
|
|
layListGrid = {}
|
|
|
|
ClearRedPointObject(RedPointType.Expedition_Treasure)
|
|
end
|
|
--实例化节点立绘
|
|
function ExpeditionMainPanel:InitLiveSet(iconId, go)
|
|
local configData = ConfigManager.GetConfigData(ConfigName.ExpeditionNodeConfig,iconId)
|
|
local live2d = poolManager:LoadLive(configData.Icon, Util.GetTransform(go, "goParent"),
|
|
Vector3.one * configData.Scale, Vector3.New(configData.Position[1], configData.Position[2],0))
|
|
--local curLive = {configData.Icon,live2d}
|
|
--table.insert(live2dList,curLive)
|
|
local skeleton = live2d:GetComponent("SkeletonGraphic")
|
|
if skeleton and iconId == 2 then--首领
|
|
skeleton.AnimationState:SetAnimation(0, "idle2", true)
|
|
end
|
|
return {name=configData.Icon, go=live2d}
|
|
end
|
|
-- 设置文本透明度
|
|
function ExpeditionMainPanel:SetCurAlpha(text, a)
|
|
local color = text.color
|
|
color.a = a
|
|
text.color = color
|
|
end
|
|
function ExpeditionMainPanel:StarPlayerMoveFun()
|
|
--Log("isAllHaveAttack "..tostring(isAllHaveAttack))
|
|
if isAllHaveAttack then return end
|
|
self.liveNode.transform.localPosition = Vector3.zero
|
|
local targetPos = self.liveNode.transform.localPosition + Vector3.New(430,0,0)
|
|
SkeletonGraphic.transform.localEulerAngles = Vector3.New(0, 0, 0)
|
|
isPlayerMove = true
|
|
self.mask:SetActive(isPlayerMove)
|
|
--Log("self.mask "..tostring(isPlayerMove))
|
|
SkeletonGraphic.AnimationState:SetAnimation(0, "move2", true)
|
|
self.liveNode.transform:DOLocalMove(targetPos, 1, false):OnStart(function ()
|
|
end):OnComplete(function ()
|
|
--Log("行走完毕")
|
|
SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true)
|
|
isPlayerMove = false
|
|
self.mask:SetActive(isPlayerMove)
|
|
--Log("self.mask "..tostring(isPlayerMove))
|
|
end):SetEase(Ease.Linear)
|
|
end
|
|
function ExpeditionMainPanel:EndPlayerMoveFun(fun)
|
|
if curNodeGo then
|
|
Util.GetGameObject(curNodeGo, "finish"):SetActive(true)
|
|
Util.GetGameObject(curNodeGo, "itemList"):SetActive(false)
|
|
end
|
|
local targetPos = Vector3.New(1706,0,0)
|
|
SkeletonGraphic.transform.localEulerAngles = Vector3.New(0, 0, 0)
|
|
isPlayerMove = true
|
|
self.mask:SetActive(isPlayerMove)
|
|
--Log("self.mask "..tostring(isPlayerMove))
|
|
SkeletonGraphic.AnimationState:SetAnimation(0, "move2", true)
|
|
local timeNum = math.abs(self.liveNode.transform.localPosition.x - targetPos.x)/350--350/1s
|
|
self.liveNode.transform:DOLocalMove(targetPos, timeNum, false):OnStart(function ()
|
|
end):OnComplete(function ()
|
|
--Log("行走完毕")
|
|
SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true)
|
|
isPlayerMove = false
|
|
self.mask:SetActive(isPlayerMove)
|
|
self:SelfUpdataPanelShow()
|
|
end):SetEase(Ease.Linear)
|
|
end
|
|
function ExpeditionMainPanel:PlayerMovePosFun(nodeGo,curItemGo)
|
|
self.liveNode.transform:SetParent(nodeGo.transform)
|
|
self.liveNode.transform.localPosition = Vector3.zero
|
|
SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true)
|
|
end
|
|
function ExpeditionMainPanel:SingleNodeInfoIconShow(nodeGo,layNodeData)
|
|
local infoIcon = Util.GetGameObject(nodeGo, "infoIcon")
|
|
infoIcon :SetActive(false)
|
|
local warPowerGo = Util.GetGameObject(infoIcon, "warPowerGo")
|
|
warPowerGo:SetActive(false)
|
|
local iconImage = Util.GetGameObject(warPowerGo, "iconImage"):GetComponent("Image")
|
|
local powerText = Util.GetGameObject(warPowerGo, "powerText"):GetComponent("Text")
|
|
local textIconGo = Util.GetGameObject(infoIcon, "textIconGo")
|
|
textIconGo:SetActive(false)
|
|
local iconImage2 = Util.GetGameObject(textIconGo, "iconImage"):GetComponent("Image")
|
|
if GetCurNodeInfo.lay == layNodeData.lay then--当前层
|
|
infoIcon:SetActive(false)
|
|
if layNodeData.type == ExpeditionNodeType.Jy or layNodeData.type == ExpeditionNodeType.Boss or layNodeData.type == ExpeditionNodeType.Common then
|
|
warPowerGo:SetActive(false)
|
|
iconImage.sprite = Util.LoadSprite(ExpeditionManager.NodeInfoIcon[layNodeData.type])
|
|
powerText.text = layNodeData.bossTeaminfo.totalForce
|
|
elseif layNodeData.type == ExpeditionNodeType.Resurgence or layNodeData.type == ExpeditionNodeType.Reply or layNodeData.type == ExpeditionNodeType.Halidom then
|
|
textIconGo:SetActive(false)
|
|
iconImage2.sprite = Util.LoadSprite(ExpeditionManager.NodeInfoIcon[layNodeData .type])
|
|
end
|
|
if isAllHaveAttack then
|
|
if layNodeData.state == ExpeditionNodeState.No then--关闭 状态
|
|
infoIcon:SetActive(false)
|
|
elseif layNodeData.state == ExpeditionNodeState.NoGetEquip then--未领圣物状态
|
|
warPowerGo:SetActive(false)
|
|
textIconGo:SetActive(false)
|
|
iconImage2.sprite = Util.LoadSprite(ExpeditionManager.NodeInfoIcon[ExpeditionNodeType.Halidom])
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function ExpeditionMainPanel:PlayerMoveFun()
|
|
if not targetPosGoAndData.pos then return end
|
|
targetPosGoAndData.pos:SetActive(true)
|
|
self.liveNode.transform:SetParent(targetPosGoAndData.pos.transform)
|
|
local oldPos = self.liveNode.transform.localPosition
|
|
local targetPos = targetPosGoAndData.pos.transform.localPosition - Vector3.New(0,69,0)
|
|
if oldPos.x - targetPos.x > 0 then
|
|
SkeletonGraphic.transform.localEulerAngles = Vector3.New(0, 180, 0)
|
|
else
|
|
SkeletonGraphic.transform.localEulerAngles = Vector3.New(0, 0, 0)
|
|
end
|
|
isPlayerMove = true
|
|
self.mask:SetActive(isPlayerMove)
|
|
SkeletonGraphic.AnimationState:SetAnimation(0, "move2", true)
|
|
local timeNum = math.abs(oldPos.y - targetPos.y)/350--350/1s
|
|
self.liveNode.transform:DOLocalMove(targetPos, timeNum, false):OnStart(function ()
|
|
end):OnComplete(function ()
|
|
--Log("行走完毕")
|
|
SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true)
|
|
isPlayerMove = false
|
|
self.mask:SetActive(isPlayerMove)
|
|
--self:SelfUpdataPanelShow()
|
|
for i = 1, #targetPosGoAndData.layAllData do
|
|
if targetPosGoAndData.layAllData[i].sortId ~= targetPosGoAndData.curNodeData.sortId then
|
|
local curItemGoPlayFly = Util.GetGameObject(targetPosGoAndData.layGo, "itemList/item ("..i..")"):GetComponent("PlayFlyAnim")
|
|
curItemGoPlayFly:PlayAnim(true)
|
|
end
|
|
end
|
|
if timer2 then
|
|
timer2:Stop()
|
|
timer2 = nil
|
|
end
|
|
timer2 = Timer.New(function()
|
|
if targetPosGoAndData.curNodeData.type == ExpeditionNodeType.Shop then
|
|
NetManager.StoreNodeRequest(targetPosGoAndData.curNodeData.sortId,function ()
|
|
UIManager.OpenPanel(UIName.ExpeditionMonsterInfoPopup,EXPEDITON_POPUP_TYPE.Shop,targetPosGoAndData.curNodeData,3,function ()
|
|
self:OnShowNodeData()
|
|
end)
|
|
end)
|
|
else
|
|
self:OnShowNodeData()
|
|
end
|
|
end, 1.5)
|
|
timer2:Start()
|
|
end):SetEase(Ease.Linear)
|
|
end
|
|
function ExpeditionMainPanel:SelfUpdataPanelShow()
|
|
self.UI_effect_BaoXiang.transform:SetParent(self.transform)
|
|
self.UI_effect_BaoXiang:SetActive(false)
|
|
local AllLayNodeList = ExpeditionManager.GetAllLayNodeList()
|
|
if AllLayNodeList == nil then return end
|
|
local curAllLayNodeList = {}
|
|
for i = #AllLayNodeList, 1, -1 do
|
|
table.insert(curAllLayNodeList,AllLayNodeList[i])
|
|
end
|
|
GetCurNodeInfo = ExpeditionManager.GetCurNodeInfo()
|
|
isAllHaveAttack = false
|
|
local curNodeGo
|
|
--nodeGoTable data = layNodeListData,goData = go
|
|
for i, v in pairs(nodeGoTable) do
|
|
if v.data[1].lay == GetCurNodeInfo.lay then
|
|
curNodeGo = v.goData
|
|
--Log("v.goData "..v.goData.name)
|
|
end
|
|
end
|
|
if curNodeGo then
|
|
self:SingleLayNodeShow(curNodeGo,curAllLayNodeList[15 - GetCurNodeInfo.lay + 1],GetCurNodeInfo.lay)
|
|
end
|
|
end
|
|
function ExpeditionMainPanel:RefreshManagerData()
|
|
--LogError("ExpeditionManager.expeditionLeve "..ExpeditionManager.expeditionLeve)
|
|
NetManager.GetExpeditionRequest(ExpeditionManager.expeditionLeve,function ()
|
|
self:OnShowNodeData()
|
|
end)
|
|
end
|
|
function ExpeditionMainPanel:HeroResurgence()
|
|
local heroDid = ""
|
|
local roleDidDatas = {}
|
|
local roleHurtDatas = {}
|
|
local _roleDatas = HeroManager.GetAllHeroDatas(1)
|
|
for i = 1, #_roleDatas do
|
|
local heroHp = 0
|
|
if ExpeditionManager.heroInfo[_roleDatas[i].dynamicId] then
|
|
heroHp = ExpeditionManager.heroInfo[_roleDatas[i].dynamicId].remainHp
|
|
if heroHp <= 0 then
|
|
table.insert(roleDidDatas,_roleDatas[i])
|
|
elseif heroHp < 1 then
|
|
table.insert(roleHurtDatas,_roleDatas[i])
|
|
end
|
|
end
|
|
end
|
|
local cuSelectHeroIndex = 0
|
|
if roleDidDatas and #roleDidDatas > 0 then
|
|
cuSelectHeroIndex = math.random(1,#roleDidDatas)
|
|
heroDid = roleDidDatas[cuSelectHeroIndex].dynamicId
|
|
elseif roleHurtDatas and #roleHurtDatas > 0 then
|
|
cuSelectHeroIndex = math.random(1,#roleHurtDatas)
|
|
heroDid = roleHurtDatas[cuSelectHeroIndex].dynamicId
|
|
else
|
|
heroDid = _roleDatas[1].dynamicId
|
|
end
|
|
return heroDid
|
|
end
|
|
return ExpeditionMainPanel
|