逍遥游地图界面预设脚本修改

yuanshuai 2020-10-17 14:31:23 +08:00
parent f25854797e
commit ecd4695a7b
4 changed files with 207 additions and 24 deletions

View File

@ -709,11 +709,11 @@ MonoBehaviour:
m_Right: 0
m_Top: 0
m_Bottom: 0
m_ChildAlignment: 0
m_ChildAlignment: 4
m_StartCorner: 0
m_StartAxis: 0
m_CellSize: {x: 100, y: 100}
m_Spacing: {x: 0, y: 0}
m_Spacing: {x: 60, y: 0}
m_Constraint: 0
m_ConstraintCount: 2
--- !u!1 &6263630824520525492
@ -746,7 +746,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4130002184282380623}
m_RootOrder: 0
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
@ -825,11 +825,11 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4130002184282380623}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 58.6}
m_AnchoredPosition: {x: 0, y: 30.799967}
m_SizeDelta: {x: 150, y: 150}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &823541989204434481
@ -860,7 +860,7 @@ MonoBehaviour:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: d090a211e2b853746b5d2662d8f4b3ae, type: 3}
m_Sprite: {fileID: 21300000, guid: aa0e17ef89ef07243a9f0c8107cff2a4, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
@ -897,6 +897,7 @@ RectTransform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 2027098397502747704}
- {fileID: 7087955728876460986}
- {fileID: 209971410732065439}
- {fileID: 4838702532749912415}
@ -916,6 +917,80 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8550504791684956899}
m_CullTransparentMesh: 0
--- !u!1 &9055714059791318376
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2027098397502747704}
- component: {fileID: 4325320704108162774}
- component: {fileID: 2137089575604050908}
m_Layer: 5
m_Name: bg
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2027098397502747704
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9055714059791318376}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4130002184282380623}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: -5}
m_SizeDelta: {x: 256.6, y: 252.3}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4325320704108162774
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9055714059791318376}
m_CullTransparentMesh: 0
--- !u!114 &2137089575604050908
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9055714059791318376}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: f16d2757d6e17b040b2cd444889359b3, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
--- !u!1 &9132433766242789470
GameObject:
m_ObjectHideFlags: 0
@ -946,11 +1021,11 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 4130002184282380623}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: -46.399963}
m_AnchoredPosition: {x: 0, y: -16.9}
m_SizeDelta: {x: 185, y: 193}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4544877072755820538

View File

@ -406,5 +406,6 @@ GameEvent = {
},
XiaoYao={
StartXiaoYao="XiaoYao.StartXiaoYao",--执行逍遥游跑图
RefreshEventShow="XiaoYao.RefreshEventShow",--刷新逍遥游地图界面事件按钮显示隐藏
}
}

View File

@ -38,9 +38,58 @@ function this:OnOpen(_type,_data)
this.title.sprite=Util.LoadSprite("x_xiaoyaoyou_youlichenggong")
this.grid:SetActive(true)
this.xianyuan:SetActive(false)
local showItemdata=this.GetDropReward(_data)
Log("终极大奖:"..#_data.itemlist)
Log("终极大奖:"..#showItemdata)
if showItemdata and #showItemdata>0 then
for i = 1, #showItemdata do
Log("终极大奖:"..showItemdata[i][1])
local _rewardObj= SubUIManager.Open(SubUIConfig.ItemView, this.grid.transform)
_rewardObj:OnOpen(false,showItemdata[i],1)
end
end
end
end
function this.GetDropReward(_drop)
local _rewardList={}
if _drop.itemlist then
for i = 1, #_drop.itemlist do
Log("list有奖励")
local _rewardData={}
_rewardData[1]=_drop.itemlist[i].itemId
_rewardData[2]=_drop.itemlist[i].itemNum
table.insert(_rewardList,_rewardData)
end
end
if not _drop.equipId then
for i = 1, #_drop.equipId do
local _rewardData={}
_rewardData[1]=_drop.equipId[i].id
_rewardData[2]=1
table.insert(_rewardList,_rewardData)
end
end
if not _drop.Hero then
for i = 1, #_drop.Hero do
local _rewardData={}
_rewardData[1]=_drop.Hero[i].id
_rewardData[2]=1
table.insert(_rewardList,_rewardData)
end
end
if not _drop.soulEquip then
for i = 1, #_drop.soulEquip do
local _rewardData={}
_rewardData[1]=_drop.soulEquip[i].id
_rewardData[2]=1
table.insert(_rewardList,_rewardData)
end
end
return _rewardList
end
--界面打开或者重新打开后,界面刷新时调用(用于子类重写)
function this:OnShow()
@ -48,7 +97,10 @@ end
--界面关闭时调用(用于子类重写)
function this:OnClose()
while(this.grid.transform.childCount>0)
do
destroy(this.grid.transform:GetChild(0).gameObject)
end
end
--界面销毁时调用(用于子类重写)

View File

@ -106,17 +106,42 @@ end
--添加事件监听(用于子类重写)
function this:AddListener()
Game.GlobalEvent:AddEvent(GameEvent.XiaoYao.StartXiaoYao, this.RunMap)
Game.GlobalEvent:AddEvent(GameEvent.XiaoYao.RefreshEventShow, this.RefreshEventBtn)
end
--移除事件监听(用于子类重写)
function this:RemoveListener()
Game.GlobalEvent:RemoveEvent(GameEvent.XiaoYao.StartXiaoYao, this.RunMap)
Game.GlobalEvent:RemoveEvent(GameEvent.XiaoYao.RefreshEventShow, this.RefreshEventBtn)
end
--刷新界面事件入口按钮显示隐藏
function this.RefreshEventBtn()
if XiaoYaoManager.luckyluckyTurnTableTimes > 0 and (XiaoYaoManager.luckyluckyTurnTableRemainTime - PlayerManager.serverTime > 0) then
this.rouleBtn:SetActive(true)
else
this.rouleBtn:SetActive(false)
end
local temp = XiaoYaoManager.GetMonsterDatas()
if temp and #temp > 0 then
this.bossBtn:SetActive(true)
else
this.bossBtn:SetActive(false)
end
local temp = XiaoYaoManager.GetHeroDatas()
if temp and #temp > 0 then
this.shopBtn:SetActive(true)
else
this.shopBtn:SetActive(false)
end
shopLeftTime=XiaoYaoManager.GetHeroDataTime() or 0
rouleLeftTime=XiaoYaoManager.luckyluckyTurnTableRemainTime or 0
bossLeftTime=XiaoYaoManager.GetMonsterDataReMainTimesAndTime() or 0
end
function this.RunMap(_data)
Log("开始跑图")
local targetIndex=0
for i = 1, #_data.pointes do
for i = 1, #_data.pointes do
Log("当前点数:".._data.pointes[i])
targetIndex=targetIndex+_data.pointes[i]
end
targetIndex=targetIndex+curGridIndex
@ -126,7 +151,9 @@ function this.RunMap(_data)
end
this.turnEffect:Reset(function()
curGridIndex=curGridIndex+1
this.TT.transform:DOAnchorPos(Vector3(allGridData[curGridIndex].x,allGridData[curGridIndex].y,0),0.3)
this.TT.transform:DOAnchorPos(Vector3(allGridData[curGridIndex].x,allGridData[curGridIndex].y,0),0.3):OnComplete(function ()
this.SetTTDirection()
end)
this.MapMove(allGridData[curGridIndex].x,0.3)
if curGridIndex==targetIndex then--如果停到对应位置
this.turnEffect:Stop()--暂停
@ -135,8 +162,7 @@ function this.RunMap(_data)
this.EventTrigger(_data)
end
if curGridIndex>=#allGridData then
this.StopAuto()
UIManager.OpenPanel(UIName.XiaoYaoEventPanel,0)
this.StopAuto()
end
if isAuto then
XiaoYaoManager.StartXiaoYao()
@ -157,9 +183,9 @@ function this.EventTrigger(_data)
Log("触发事件类型为:".._data.pathType)
Log("触发事件时间为:".._data.overTime)
if _data.pathType==0 then --普通节点
UIManager.OpenPanel(UIName.XiaoYaoEventPanel,0,_data.drop)
elseif _data.pathType==1 then --宝箱
PopupTipPanel.ShowTip("获得一个宝箱!")
Log("获得一个宝箱!")
elseif _data.pathType==2 then --双倍节点
PopupTipPanel.ShowTip("奖励翻倍!")
elseif _data.pathType==3 then --额外骰子节点
@ -177,6 +203,8 @@ function this.EventTrigger(_data)
this.rouleBtn:SetActive(true)
rouleLeftTime=_data.overTime
UIManager.OpenPanel(UIName.XiaoYaoEventPanel,_data.pathType,allGridData[curGridIndex].eventData)
elseif _data.pathType==7 then --终极大奖
UIManager.OpenPanel(UIName.XiaoYaoEventPanel,0,_data.drop)
end
if _data.drop.itemlist ~= nil and #_data.drop.itemlist > 0 then
local content = {}
@ -204,7 +232,6 @@ end
function this:OnOpen(_mapData)
mapData=_mapData
this.InitShowEvent()
this.LoadTT()
--初始化地图
for i = 1, #mapData.cell do
local x, y=Map_Pos2UV(mapData.cell[i].cellId)
@ -254,6 +281,8 @@ function this:OnOpen(_mapData)
end
end
curGridIndex=mapData.location
this.LoadTT()
this.SetTTDirection()
Log("当前位置索引:"..curGridIndex)
this.TT.transform:DOAnchorPos(Vector3(allGridData[curGridIndex].x,allGridData[curGridIndex].y,0),0)
this.TT.transform:SetAsLastSibling()
@ -278,12 +307,38 @@ function this.LoadTT()
if not this.liveNode then
this.liveNode = poolManager:LoadLive(npc, this.TT.transform, scale, Vector3.New(0,-42.4,0))
end
local SkeletonGraphic = this.liveNode:GetComponent("SkeletonGraphic")
if SkeletonGraphic then
SkeletonGraphic.AnimationState:SetAnimation(0, "move2", true)
SkeletonGraphic.transform.localEulerAngles = Vector3.New(0, 0, 0)
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)
end
end
--设置跑图角色方向
function this.SetTTDirection()
if not this.SkeletonGraphic then
return
end
local nexIndex=curGridIndex+1
if nexIndex>#allGridData then
this.SkeletonGraphic.AnimationState:SetAnimation(0, "touch", true)
return
end
if allGridData[curGridIndex].y==allGridData[nexIndex].y then
this.SkeletonGraphic.AnimationState:SetAnimation(0, "move2", true)
if allGridData[curGridIndex].x<allGridData[nexIndex].x then
this.SkeletonGraphic.transform.localEulerAngles = Vector3.New(0, 0, 0)
else
this.SkeletonGraphic.transform.localEulerAngles = Vector3.New(0, 180, 0)
end
elseif allGridData[curGridIndex].x==allGridData[nexIndex].x then
if allGridData[curGridIndex].y<allGridData[nexIndex].y then
this.SkeletonGraphic.AnimationState:SetAnimation(0, "move3", true)
else
this.SkeletonGraphic.AnimationState:SetAnimation(0, "move", true)
end
end
end
--初始化地图事件显示
function this.InitShowEvent()
@ -307,9 +362,9 @@ function this.InitShowEvent()
else
this.shopBtn:SetActive(false)
end
shopLeftTime=XiaoYaoManager.GetHeroDataTime()
rouleLeftTime=XiaoYaoManager.luckyluckyTurnTableRemainTime
bossLeftTime=XiaoYaoManager.GetMonsterDataReMainTimesAndTime()
shopLeftTime=XiaoYaoManager.GetHeroDataTime() or 0
rouleLeftTime=XiaoYaoManager.luckyluckyTurnTableRemainTime or 0
bossLeftTime=XiaoYaoManager.GetMonsterDataReMainTimesAndTime() or 0
if not eventTimer then
eventTimer=this.DownTime()
end