2020-05-09 13:31:21 +08:00
require ( " Base/BasePanel " )
ExpeditionMainPanel = Inherit ( BasePanel )
2020-05-25 19:16:23 +08:00
local this = ExpeditionMainPanel
2020-05-09 13:31:21 +08:00
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 ( )
2020-05-25 19:16:23 +08:00
local liveNodeList = { }
local targetPosGoAndData
2020-06-03 19:09:01 +08:00
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 " } ,
2020-05-25 19:16:23 +08:00
}
2020-06-03 19:09:01 +08:00
local layListGrid = { }
local cursortingOrder = 0
2020-06-13 11:47:13 +08:00
local expeditionNodeConfig = ConfigManager.GetConfig ( ConfigName.ExpeditionNodeConfig )
2020-05-09 13:31:21 +08:00
--初始化组件(用于子类重写)
function ExpeditionMainPanel : InitComponent ( )
2020-06-03 19:09:01 +08:00
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 " )
2020-05-09 13:31:21 +08:00
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
2020-06-03 19:09:01 +08:00
self.mask = Util.GetGameObject ( self.parent , " mask " )
2020-05-09 13:31:21 +08:00
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
2020-06-03 19:09:01 +08:00
self.liveNode = poolManager : LoadLive ( npc , Util.GetTransform ( self.parent , " playerLive " ) , scale , Vector3.zero )
2020-05-09 13:31:21 +08:00
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 " )
2020-06-03 19:09:01 +08:00
self.grid = Util.GetGameObject ( self.transform , " rect/grid " )
2020-05-09 13:31:21 +08:00
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 )
2020-05-25 19:16:23 +08:00
Util.AddClick ( self.Btn4 , function ( )
2020-06-03 19:09:01 +08:00
UIManager.OpenPanel ( UIName.TreasureOfHeavenPanel )
2020-05-25 19:16:23 +08:00
--PopupTipPanel.ShowTip("不可领取奖励!")
2020-05-09 13:31:21 +08:00
end )
Util.AddClick ( self.helpBtn , function ( )
UIManager.OpenPanel ( UIName.HelpPopup , HELP_TYPE.Expedition , self.helpPos . x , self.helpPos . y )
end )
2020-06-03 19:09:01 +08:00
BindRedPointObject ( RedPointType.Expedition_Treasure , self.redPoint )
2020-05-09 13:31:21 +08:00
end
--添加事件监听(用于子类重写)
function ExpeditionMainPanel : AddListener ( )
2020-05-25 19:16:23 +08:00
Game.GlobalEvent : AddEvent ( GameEvent.Expedition . RefreshPlayAniMainPanel , self.PlayerMoveFun , self )
Game.GlobalEvent : AddEvent ( GameEvent.Expedition . RefreshMainPanel , self.OnShowNodeData , self )
2020-05-09 13:31:21 +08:00
end
--移除事件监听(用于子类重写)
function ExpeditionMainPanel : RemoveListener ( )
2020-05-25 19:16:23 +08:00
Game.GlobalEvent : RemoveEvent ( GameEvent.Expedition . RefreshPlayAniMainPanel , self.PlayerMoveFun , self )
Game.GlobalEvent : RemoveEvent ( GameEvent.Expedition . RefreshMainPanel , self.OnShowNodeData , self )
2020-05-09 13:31:21 +08:00
end
2020-05-25 19:16:23 +08:00
--界面打开时调用(用于子类重写)
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 )
2020-05-09 13:31:21 +08:00
end
2020-06-03 19:09:01 +08:00
function ExpeditionMainPanel : OnSortingOrderChange ( )
self.gridMask : GetComponent ( " Canvas " ) . sortingOrder = self.sortingOrder + 1
self.parent : GetComponent ( " Canvas " ) . sortingOrder = self.sortingOrder + 2
--cursortingOrder = self.sortingOrder
end
2020-05-09 13:31:21 +08:00
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
2020-06-03 19:09:01 +08:00
function ExpeditionMainPanel : OnShow ( )
2020-05-25 19:16:23 +08:00
-- isAllHaveAttack = false
-- nodeGoTable = {}
-- self:OnShowNodeData()
2020-06-03 19:09:01 +08:00
--self:StarPlayerMoveFun()
-- 音效
SoundManager.PlayMusic ( SoundConfig.BGM_Carbon )
end
2020-05-09 13:31:21 +08:00
--实例化层数信息
function ExpeditionMainPanel : OnShowNodeData ( )
isPlayerMove = false
2020-05-25 19:16:23 +08:00
isAllHaveAttack = false
nodeGoTable = { }
2020-06-03 19:09:01 +08:00
self.titleImageText . text = " 大闹天宫 第 " .. expeditionLeveTable [ ExpeditionManager.expeditionLeve ] . numStr .. " 层 "
self.bg1 : SetActive ( ExpeditionManager.expeditionLeve ~= 4 )
self.bg2 : SetActive ( ExpeditionManager.expeditionLeve == 4 )
2020-05-25 19:16:23 +08:00
ExpeditionManager.ExpeditionRrefreshFormation ( ) --刷新编队
ExpeditionManager.GetActivityIsShowRedPoint ( false , " 1 " ) --刷新红点
2020-05-09 13:31:21 +08:00
self.mask : SetActive ( isPlayerMove )
self.UI_effect_BaoXiang . transform : SetParent ( self.transform )
self.UI_effect_BaoXiang : SetActive ( false )
2020-05-25 19:16:23 +08:00
--节点
local AllLayNodeList = ExpeditionManager.GetAllLayNodeList ( ) --所有层所有节点信息
2020-05-09 13:31:21 +08:00
if AllLayNodeList == nil then return end
local curAllLayNodeList = { }
2020-05-25 19:16:23 +08:00
for i = # AllLayNodeList , 1 , - 1 do --从下到上显示 所以倒序
2020-05-09 13:31:21 +08:00
table.insert ( curAllLayNodeList , AllLayNodeList [ i ] )
end
GetCurNodeInfo = ExpeditionManager.GetCurNodeInfo ( )
2020-06-03 19:09:01 +08:00
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 )
2020-05-09 13:31:21 +08:00
end
2020-06-03 19:09:01 +08:00
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)
2020-05-09 13:31:21 +08:00
end
--实例化每层信息
2020-06-03 19:09:01 +08:00
function ExpeditionMainPanel : SingleLayNodeShow ( go , layNodeListData )
2020-05-09 13:31:21 +08:00
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 ]
2020-06-13 11:47:13 +08:00
if item then
poolManager : UnLoadLive ( item.name , item.go , PoolManager.AssetType . GameObject )
end
2020-05-09 13:31:21 +08:00
end
end
liveNodeList [ go ] = { }
2020-05-25 19:16:23 +08:00
--判断是否有未打赢过 和 未获取圣物的状态
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
2020-05-09 13:31:21 +08:00
for i = 1 , # layNodeListData do --每个节点显示
2020-06-03 19:09:01 +08:00
--LogError(layNodeListData[i].lay.." "..layNodeListData[i].sortId.." "..layNodeListData[i].state.." "..GetCurNodeInfo.lay)
2020-05-25 19:16:23 +08:00
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 )
2020-05-09 13:31:21 +08:00
---实例化动画---
2020-06-13 11:47:13 +08:00
local goImage = Util.GetGameObject ( curItemGo , " goParent/Image " )
local curexpeditionNodeConfig = expeditionNodeConfig [ layNodeListData [ i ] . type ]
if GetCurNodeInfo.lay <= layNodeListData [ i ] . lay and layNodeListData [ i ] . lay ~= 1 and curexpeditionNodeConfig then
if curexpeditionNodeConfig.AniOrImage == 1 then
liveNodeList [ go ] [ i ] = self : InitLiveSet ( layNodeListData [ i ] . type , Util.GetGameObject ( curItemGo , " goParent " ) )
goImage : SetActive ( false )
else
goImage : SetActive ( true )
goImage : GetComponent ( " Image " ) . sprite = Util.LoadSprite ( curexpeditionNodeConfig.Icon )
goImage : GetComponent ( " Image " ) : SetNativeSize ( )
-- 设置图片大小位置
goImage : GetComponent ( " RectTransform " ) . anchoredPosition = Vector2.New ( curexpeditionNodeConfig.Position [ 1 ] , curexpeditionNodeConfig.Position [ 2 ] )
goImage.transform . localScale = Vector3.one * curexpeditionNodeConfig.Scale
end
2020-05-09 13:31:21 +08:00
end
--------------
2020-05-25 19:16:23 +08:00
Util.GetGameObject ( curItemGo , " infoIcon " ) : SetActive ( true )
2020-06-03 19:09:01 +08:00
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 )
2020-05-09 13:31:21 +08:00
Util.GetGameObject ( curItemGo , " click " ) : SetActive ( true )
2020-06-03 19:09:01 +08:00
local clickbtn = Util.GetGameObject ( curItemGo , " click " )
2020-05-09 13:31:21 +08:00
local pos = Util.GetGameObject ( curItemGo , " pos " ) --节点位置 人物动画用
2020-06-03 19:09:01 +08:00
--pos.transform.localPosition = Vector3.New(0,-10,0)
pedestalImage : SetActive ( true )
goParent : SetActive ( true )
halidomParent : SetActive ( true )
clickbtn : SetActive ( true )
2020-05-25 19:16:23 +08:00
if layNodeListData [ i ] . lay < GetCurNodeInfo.lay then
2020-06-03 19:09:01 +08:00
goParent : SetActive ( false )
halidomParent : SetActive ( false )
okAttackImage : SetActive ( false )
okAttackDi : SetActive ( false )
2020-05-25 19:16:23 +08:00
Util.GetGameObject ( curItemGo , " click " ) : SetActive ( false )
Util.GetGameObject ( curItemGo , " infoIcon " ) : SetActive ( false )
if layNodeListData [ i ] . state == ExpeditionNodeState.Over then --未打但已通过
2020-06-03 19:09:01 +08:00
pedestalImage : SetActive ( false )
2020-05-25 19:16:23 +08:00
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 )
2020-06-03 19:09:01 +08:00
goParent : SetActive ( false )
2020-05-25 19:16:23 +08:00
elseif layNodeListData [ i ] . state == ExpeditionNodeState.Over then --未打但已通过
2020-06-03 19:09:01 +08:00
goParent : SetActive ( false )
halidomParent : SetActive ( false )
okAttackImage : SetActive ( false )
okAttackDi : SetActive ( false )
2020-05-09 13:31:21 +08:00
Util.GetGameObject ( curItemGo , " click " ) : SetActive ( false )
2020-06-03 19:09:01 +08:00
pedestalImage : SetActive ( false )
2020-05-25 19:16:23 +08:00
Util.GetGameObject ( curItemGo , " infoIcon " ) : SetActive ( false )
end
elseif layNodeListData [ i ] . lay > GetCurNodeInfo.lay then
2020-06-03 19:09:01 +08:00
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 --打未通过
2020-05-25 19:16:23 +08:00
elseif layNodeListData [ i ] . state == ExpeditionNodeState.NoGetEquip then --未领取圣物
2020-06-03 19:09:01 +08:00
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 )
2020-05-25 19:16:23 +08:00
elseif layNodeListData [ i ] . state == ExpeditionNodeState.Over then --未打但已通过
2020-06-03 19:09:01 +08:00
pedestalImage : SetActive ( false )
end
2020-05-09 13:31:21 +08:00
end
Util.AddOnceClick ( clickbtn , function ( )
if isPlayerMove then return end
2020-05-25 19:16:23 +08:00
ExpeditionManager.curAttackNodeInfo = layNodeListData [ i ]
targetPosGoAndData = { pos = pos , layGo = nodeGo , layAllData = layNodeListData , curNodeData = layNodeListData [ i ] }
2020-05-09 13:31:21 +08:00
if layNodeListData [ i ] . state == ExpeditionNodeState.No then
2020-05-25 19:16:23 +08:00
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
2020-05-09 13:31:21 +08:00
elseif layNodeListData [ i ] . state == ExpeditionNodeState.NoPass then
2020-05-25 19:16:23 +08:00
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 )
2020-05-09 13:31:21 +08:00
elseif layNodeListData [ i ] . type == ExpeditionNodeType.Halidom then --圣物节点
2020-05-25 19:16:23 +08:00
UIManager.OpenPanel ( UIName.ExpeditionSelectHalidomPanel , false )
2020-05-09 13:31:21 +08:00
elseif layNodeListData [ i ] . type == ExpeditionNodeType.Reply then --回复节点
2020-05-25 19:16:23 +08:00
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 , " 前往 " , " 蟠桃树 " )
2020-05-09 13:31:21 +08:00
elseif layNodeListData [ i ] . type == ExpeditionNodeType.Resurgence then --复活节点
2020-05-25 19:16:23 +08:00
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 ( " 已通关本次大闹天宫! " )
2020-05-09 13:31:21 +08:00
end
end )
end )
end
elseif layNodeListData [ i ] . state == ExpeditionNodeState.NoGetEquip then
2020-05-25 19:16:23 +08:00
UIManager.OpenPanel ( UIName.ExpeditionSelectHalidomPanel , false )
2020-05-09 13:31:21 +08:00
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
2020-06-03 19:09:01 +08:00
layListGrid = { }
ClearRedPointObject ( RedPointType.Expedition_Treasure )
2020-05-09 13:31:21 +08:00
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)
2020-06-13 11:47:13 +08:00
--local skeleton = live2d:GetComponent("SkeletonGraphic")
--if skeleton and iconId == 2 then--首领
-- skeleton.AnimationState:SetAnimation(0, "idle2", true)
--end
2020-05-09 13:31:21 +08:00
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 )
2020-05-25 19:16:23 +08:00
self.liveNode . transform : SetParent ( nodeGo.transform )
2020-05-09 13:31:21 +08:00
self.liveNode . transform.localPosition = Vector3.zero
2020-05-25 19:16:23 +08:00
SkeletonGraphic.AnimationState : SetAnimation ( 0 , " idle " , true )
2020-05-09 13:31:21 +08:00
end
function ExpeditionMainPanel : SingleNodeInfoIconShow ( nodeGo , layNodeData )
local infoIcon = Util.GetGameObject ( nodeGo , " infoIcon " )
local warPowerGo = Util.GetGameObject ( infoIcon , " warPowerGo " )
2020-06-13 11:47:13 +08:00
--local iconImage = Util.GetGameObject(warPowerGo, "iconImage"):GetComponent("Image")
2020-05-09 13:31:21 +08:00
local powerText = Util.GetGameObject ( warPowerGo , " powerText " ) : GetComponent ( " Text " )
local textIconGo = Util.GetGameObject ( infoIcon , " textIconGo " )
2020-06-13 11:47:13 +08:00
--local iconImage2 = Util.GetGameObject(textIconGo, "iconImage"):GetComponent("Image")
infoIcon : SetActive ( false )
warPowerGo : SetActive ( false )
2020-05-09 13:31:21 +08:00
textIconGo : SetActive ( false )
2020-06-13 11:47:13 +08:00
if layNodeData.lay < GetCurNodeInfo.lay + 3 and layNodeData.lay > GetCurNodeInfo.lay then
if layNodeData.type == ExpeditionNodeType.Jy or layNodeData.type == ExpeditionNodeType.Common then
warPowerGo : SetActive ( true )
2020-05-09 13:31:21 +08:00
powerText.text = layNodeData.bossTeaminfo . totalForce
end
end
2020-06-13 11:47:13 +08:00
if layNodeData.type == ExpeditionNodeType.Boss then
warPowerGo : SetActive ( true )
powerText.text = layNodeData.bossTeaminfo . totalForce
end
--if GetCurNodeInfo.lay == layNodeData.lay then--当前层
-- 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
-- --iconImage2.sprite = Util.LoadSprite(ExpeditionManager.NodeInfoIcon[layNodeData .type])
-- end
-- if isAllHaveAttack then
-- if layNodeData.state == ExpeditionNodeState.No then--关闭 状态
-- elseif layNodeData.state == ExpeditionNodeState.NoGetEquip then--未领圣物状态
-- --iconImage2.sprite = Util.LoadSprite(ExpeditionManager.NodeInfoIcon[ExpeditionNodeType.Halidom])
-- end
-- end
--end
2020-05-09 13:31:21 +08:00
end
2020-05-25 19:16:23 +08:00
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
2020-06-03 19:09:01 +08:00
local targetPos = targetPosGoAndData.pos . transform.localPosition - Vector3.New ( 0 , 69 , 0 )
2020-05-25 19:16:23 +08:00
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
2020-05-09 13:31:21 +08:00
self.mask : SetActive ( isPlayerMove )
2020-05-25 19:16:23 +08:00
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 ( )
2020-05-09 13:31:21 +08:00
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
2020-05-25 19:16:23 +08:00
self : SingleLayNodeShow ( curNodeGo , curAllLayNodeList [ 15 - GetCurNodeInfo.lay + 1 ] , GetCurNodeInfo.lay )
2020-05-09 13:31:21 +08:00
end
end
2020-05-25 19:16:23 +08:00
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
2020-05-09 13:31:21 +08:00
return ExpeditionMainPanel