|
|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
require("Base/BasePanel")
|
|
|
|
|
XiaoYaoMapPanel = Inherit(BasePanel)
|
|
|
|
|
local this = XiaoYaoMapPanel
|
|
|
|
|
local cursortingOrder
|
|
|
|
|
local cursortingOrder=0
|
|
|
|
|
local mapData={}
|
|
|
|
|
local curGridIndex=1
|
|
|
|
|
local allGridData={}
|
|
|
|
|
@ -13,6 +13,8 @@ local eventTimer
|
|
|
|
|
local shopLeftTime=0
|
|
|
|
|
local rouleLeftTime=0
|
|
|
|
|
local bossLeftTime=0
|
|
|
|
|
local isPlayMove=0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--初始化组件(用于子类重写)
|
|
|
|
|
function this:InitComponent()
|
|
|
|
|
@ -43,6 +45,13 @@ function this:InitComponent()
|
|
|
|
|
this.actCountTime = Util.GetGameObject(this.bgTime, "time"):GetComponent("Text")
|
|
|
|
|
|
|
|
|
|
this.youliTag = Util.GetGameObject(self.gameObject, "mapParent/TT/youli")
|
|
|
|
|
|
|
|
|
|
-- 挂机特效
|
|
|
|
|
this.moneyEffect = poolManager:LoadAsset("c_xy_0012_skeff_slidesk_ballistic", PoolManager.AssetType.GameObject)
|
|
|
|
|
this.moneyEffect.transform:SetParent(this.transform)
|
|
|
|
|
this.moneyEffect.transform.localScale = Vector3.one
|
|
|
|
|
this.moneyEffect.transform.localPosition = Vector3.New(0, 0, 0)
|
|
|
|
|
this.moneyEffect:SetActive(false)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
@ -142,7 +151,9 @@ function this.RefreshEventBtn()
|
|
|
|
|
rouleLeftTime=XiaoYaoManager.luckyluckyTurnTableRemainTime or 0
|
|
|
|
|
bossLeftTime=XiaoYaoManager.GetMonsterDataReMainTimesAndTime() or 0
|
|
|
|
|
end
|
|
|
|
|
--开始跑图
|
|
|
|
|
function this.RunMap(_data)
|
|
|
|
|
this.startBtn:GetComponent("Button").enabled=false
|
|
|
|
|
Log("开始跑图")
|
|
|
|
|
local targetIndex=0
|
|
|
|
|
for i = 1, #_data.pointes do
|
|
|
|
|
@ -154,28 +165,36 @@ function this.RunMap(_data)
|
|
|
|
|
if targetIndex>#allGridData then
|
|
|
|
|
targetIndex=#allGridData
|
|
|
|
|
end
|
|
|
|
|
this.turnEffect:Reset(function()
|
|
|
|
|
curGridIndex=curGridIndex+1
|
|
|
|
|
this.TT.transform:DOAnchorPos(Vector3(allGridData[curGridIndex].x,allGridData[curGridIndex].y,0),0.3):OnComplete(function ()
|
|
|
|
|
this.SetTTDirection()
|
|
|
|
|
end)
|
|
|
|
|
this.MoveTT(targetIndex,_data)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--主角移动
|
|
|
|
|
function this.MoveTT(targetIndex,_data)
|
|
|
|
|
if isPlayMove==1 then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
this.SetTTDirection()
|
|
|
|
|
curGridIndex=curGridIndex+1
|
|
|
|
|
this.TT.transform:DOAnchorPos(Vector3(allGridData[curGridIndex].x,allGridData[curGridIndex].y,0),0.3):OnComplete(function ()
|
|
|
|
|
this.mapProcess.text=string.format("%d%%",(curGridIndex/#allGridData*100))
|
|
|
|
|
this.MapMove(allGridData[curGridIndex].x,0.3)
|
|
|
|
|
if curGridIndex==targetIndex then--如果停到对应位置
|
|
|
|
|
this.turnEffect:Stop()--暂停
|
|
|
|
|
this.mapProcess.text=string.format("%d%%",(curGridIndex/#allGridData*100))
|
|
|
|
|
if allGridData[curGridIndex].eventData then
|
|
|
|
|
this.EventTrigger(_data)
|
|
|
|
|
end
|
|
|
|
|
if curGridIndex==targetIndex then
|
|
|
|
|
Log("待机动画")
|
|
|
|
|
this.SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true)
|
|
|
|
|
this.startBtn:GetComponent("Button").enabled=true
|
|
|
|
|
this.EventTrigger(_data)
|
|
|
|
|
if curGridIndex>=#allGridData then
|
|
|
|
|
this.StopAuto()
|
|
|
|
|
end
|
|
|
|
|
this.StopAuto()
|
|
|
|
|
end
|
|
|
|
|
if isAuto then
|
|
|
|
|
XiaoYaoManager.StartXiaoYao()
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end,0.3,-1,true)
|
|
|
|
|
this.turnEffect:Start()
|
|
|
|
|
else
|
|
|
|
|
this.MoveTT(targetIndex,_data)
|
|
|
|
|
end
|
|
|
|
|
end):SetEase(Ease.Linear)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--取消自动游历
|
|
|
|
|
function this.StopAuto()
|
|
|
|
|
isAuto=false
|
|
|
|
|
@ -184,6 +203,10 @@ function this.StopAuto()
|
|
|
|
|
end
|
|
|
|
|
--事件触发处理
|
|
|
|
|
function this.EventTrigger(_data)
|
|
|
|
|
if priThread then
|
|
|
|
|
coroutine.stop(priThread)
|
|
|
|
|
priThread = nil
|
|
|
|
|
end
|
|
|
|
|
Util.GetGameObject(this.gridParent.transform:GetChild(curGridIndex-1).gameObject,"eventPoint"):SetActive(false)
|
|
|
|
|
Log("触发事件类型为:".._data.pathType)
|
|
|
|
|
Log("触发事件时间为:".._data.overTime)
|
|
|
|
|
@ -196,25 +219,36 @@ function this.EventTrigger(_data)
|
|
|
|
|
elseif _data.pathType==3 then --额外骰子节点
|
|
|
|
|
PopupTipPanel.ShowTip("骰子x2")
|
|
|
|
|
saiNum=2
|
|
|
|
|
elseif _data.pathType==4 then --东海寻仙节点
|
|
|
|
|
this.shopBtn:SetActive(true)
|
|
|
|
|
shopLeftTime=_data.overTime
|
|
|
|
|
UIManager.OpenPanel(UIName.XiaoYaoEventPanel,_data.pathType,allGridData[curGridIndex].eventData)
|
|
|
|
|
elseif _data.pathType==4 then --东海寻仙节点
|
|
|
|
|
priThread = coroutine.start(function()
|
|
|
|
|
this.PlayEffect(this.shopBtn)
|
|
|
|
|
coroutine.wait(2)
|
|
|
|
|
this.shopBtn:SetActive(true)
|
|
|
|
|
shopLeftTime=_data.overTime
|
|
|
|
|
UIManager.OpenPanel(UIName.XiaoYaoEventPanel,_data.pathType,allGridData[curGridIndex].eventData)
|
|
|
|
|
end)
|
|
|
|
|
elseif _data.pathType==5 then --怪物节点
|
|
|
|
|
this.bossBtn:SetActive(true)
|
|
|
|
|
bossLeftTime=_data.overTime
|
|
|
|
|
UIManager.OpenPanel(UIName.XiaoYaoEventPanel,_data.pathType,allGridData[curGridIndex].eventData)
|
|
|
|
|
priThread = coroutine.start(function()
|
|
|
|
|
this.PlayEffect(this.bossBtn)
|
|
|
|
|
coroutine.wait(2)
|
|
|
|
|
this.bossBtn:SetActive(true)
|
|
|
|
|
bossLeftTime=_data.overTime
|
|
|
|
|
UIManager.OpenPanel(UIName.XiaoYaoEventPanel,_data.pathType,allGridData[curGridIndex].eventData)
|
|
|
|
|
end)
|
|
|
|
|
elseif _data.pathType==6 then --转盘
|
|
|
|
|
this.rouleBtn:SetActive(true)
|
|
|
|
|
rouleLeftTime=_data.overTime
|
|
|
|
|
UIManager.OpenPanel(UIName.XiaoYaoEventPanel,_data.pathType,allGridData[curGridIndex].eventData)
|
|
|
|
|
priThread = coroutine.start(function()
|
|
|
|
|
this.PlayEffect(this.rouleBtn)
|
|
|
|
|
coroutine.wait(2)
|
|
|
|
|
this.rouleBtn:SetActive(true)
|
|
|
|
|
rouleLeftTime=_data.overTime
|
|
|
|
|
UIManager.OpenPanel(UIName.XiaoYaoEventPanel,_data.pathType,allGridData[curGridIndex].eventData)
|
|
|
|
|
end)
|
|
|
|
|
elseif _data.pathType==7 then --终极大奖
|
|
|
|
|
UIManager.OpenPanel(UIName.XiaoYaoEventPanel,0,_data.drop)
|
|
|
|
|
end
|
|
|
|
|
if _data.drop.itemlist ~= nil and #_data.drop.itemlist > 0 then
|
|
|
|
|
if _data.drop.itemlist and #_data.drop.itemlist > 0 and _data.pathType~=7 then
|
|
|
|
|
local content = {}
|
|
|
|
|
for i = 1, #_data.drop.itemlist do
|
|
|
|
|
Log("这是基础奖励")
|
|
|
|
|
for i = 1, #_data.drop.itemlist do
|
|
|
|
|
local itemdata = {}
|
|
|
|
|
itemdata.configData = itemConfig[_data.drop.itemlist[i].itemId]
|
|
|
|
|
itemdata.name = itemdata.configData.Name
|
|
|
|
|
@ -224,14 +258,22 @@ function this.EventTrigger(_data)
|
|
|
|
|
end
|
|
|
|
|
PopupText(content, 0.5, 2)
|
|
|
|
|
end
|
|
|
|
|
if priThread then
|
|
|
|
|
coroutine.stop(priThread)
|
|
|
|
|
priThread = nil
|
|
|
|
|
end
|
|
|
|
|
priThread = coroutine.start(function()
|
|
|
|
|
coroutine.wait(1)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this.PlayEffect(_btnObj)
|
|
|
|
|
-- local v2 = RectTransformUtility.WorldToScreenPoint(TileMapView.GetCamera(), TileMapView.GetLiveTilePos(u, v))
|
|
|
|
|
-- this.TT.transform.position
|
|
|
|
|
this.moneyEffect.transform.position =this.TT.transform.position
|
|
|
|
|
Util.ClearTrailRender(this.moneyEffect)
|
|
|
|
|
this.moneyEffect:SetActive(true)
|
|
|
|
|
this.moneyEffect:GetComponent("RectTransform"):DOMove(_btnObj.transform.position, 0.6, false):OnComplete(function ()
|
|
|
|
|
-- 这些该死的延迟动画
|
|
|
|
|
if isPlayMove==1 then return end
|
|
|
|
|
if this.moneyEffect then
|
|
|
|
|
this.moneyEffect:SetActive(false)
|
|
|
|
|
end
|
|
|
|
|
end)
|
|
|
|
|
SoundManager.PlaySound(SoundConfig.Sound_FightArea_Gold)
|
|
|
|
|
end
|
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
|
|
|
function this:OnOpen(_mapData)
|
|
|
|
|
@ -265,8 +307,6 @@ function this:OnOpen(_mapData)
|
|
|
|
|
obj.transform:DOAnchorPos(Vector3(allGridData[i].x,allGridData[i].y,0),0)
|
|
|
|
|
local eventObj=Util.GetGameObject(obj.gameObject,"eventPoint")
|
|
|
|
|
if allGridData[i].eventData then
|
|
|
|
|
-- local eventObj= newObjToParent(this.eventPoint,obj)
|
|
|
|
|
-- eventObj:GetComponent("RectTransform").localPosition=Vector2.zero
|
|
|
|
|
eventObj:SetActive(true)
|
|
|
|
|
if allGridData[i].rewardId then
|
|
|
|
|
Log("rewardId:"..allGridData[i].rewardId)
|
|
|
|
|
@ -286,8 +326,7 @@ function this:OnOpen(_mapData)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
curGridIndex=mapData.location
|
|
|
|
|
this.LoadTT()
|
|
|
|
|
this.SetTTDirection()
|
|
|
|
|
this.LoadTT()
|
|
|
|
|
Log("当前位置索引:"..curGridIndex)
|
|
|
|
|
this.TT.transform:DOAnchorPos(Vector3(allGridData[curGridIndex].x,allGridData[curGridIndex].y,0),0)
|
|
|
|
|
this.TT.transform:SetAsLastSibling()
|
|
|
|
|
@ -316,13 +355,11 @@ function this.LoadTT()
|
|
|
|
|
end
|
|
|
|
|
this.SkeletonGraphic = this.liveNode:GetComponent("SkeletonGraphic")
|
|
|
|
|
if this.SkeletonGraphic then
|
|
|
|
|
this.SkeletonGraphic.AnimationState:SetAnimation(0, "move2", true)
|
|
|
|
|
this.SkeletonGraphic.transform.localEulerAngles = Vector3.New(0, 180, 0)
|
|
|
|
|
this.SkeletonGraphic.AnimationState:SetAnimation(0, "idle", true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
--设置跑图角色方向
|
|
|
|
|
function this.SetTTDirection()
|
|
|
|
|
|
|
|
|
|
if not this.SkeletonGraphic then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
@ -452,25 +489,21 @@ function this:OnShow()
|
|
|
|
|
--显示资源条
|
|
|
|
|
this.UpView:OnOpen({ showType = UpViewOpenType.ShowLeft, panelType = PanelType.MonsterCamp })
|
|
|
|
|
this.ShowCountTime()
|
|
|
|
|
if not this.turnEffect then
|
|
|
|
|
this.turnEffect=Timer.New(nil,1,-1,true)
|
|
|
|
|
end
|
|
|
|
|
isPlayMove=0
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function this:OnSortingOrderChange(_cursortingOrder)
|
|
|
|
|
cursortingOrder = _cursortingOrder
|
|
|
|
|
function this:OnSortingOrderChange()
|
|
|
|
|
Util.AddParticleSortLayer(this.moneyEffect, self.sortingOrder - cursortingOrder)
|
|
|
|
|
cursortingOrder = self.sortingOrder
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
--界面关闭时调用(用于子类重写)
|
|
|
|
|
function this:OnClose()
|
|
|
|
|
if this.turnEffect then
|
|
|
|
|
this.turnEffect:Stop()
|
|
|
|
|
this.turnEffect=nil
|
|
|
|
|
end
|
|
|
|
|
this.rouleBtn:SetActive(false)
|
|
|
|
|
this.bossBtn:SetActive(false)
|
|
|
|
|
this.shopBtn:SetActive(false)
|
|
|
|
|
this.StopAuto()
|
|
|
|
|
isPlayMove=1
|
|
|
|
|
if this.liveNode then
|
|
|
|
|
poolManager:UnLoadLive(npc, this.liveNode)
|
|
|
|
|
this.liveNode = nil
|
|
|
|
|
@ -483,6 +516,7 @@ function this:OnDestroy()
|
|
|
|
|
eventTimer:Stop()
|
|
|
|
|
eventTimer = nil
|
|
|
|
|
end
|
|
|
|
|
this.liveNode=nil
|
|
|
|
|
if this.liveNode then
|
|
|
|
|
poolManager:UnLoadLive(npc, this.liveNode)
|
|
|
|
|
this.liveNode = nil
|
|
|
|
|
|