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

132 lines
4.3 KiB
Lua

require("Base/BasePanel")
StoryMapPanel = Inherit(BasePanel)
local this = StoryMapPanel
local npc = "live2d_npc_map_boy"
local mapCtrl = "StoryMapCtrl"
local playerSpeed = 0
local oriCameraPos = Vector3.New(18.9,-20,-50)
local targetCameraPos = Vector3.New(18.9,54.9,-50)
local oriPlayerPos = Vector3.New(1918,-2086,-50)
--初始化组件(用于子类重写)
function this:InitComponent()
--this.liveNode = Util.GetGameObject(self.gameObject,"scroll/mapParent/TT")
this.startBtn = Util.GetGameObject(self.gameObject,"Start")
this.btnBack = Util.GetGameObject(self.gameObject,"btnBack")
end
--绑定事件(用于子类重写)
function this:BindEvent()
Util.AddClick(this.btnBack, function ()
this:ClosePanel()
end)
Util.AddClick(this.startBtn, function ()
UIManager.camera.clearFlags = CameraClearFlags.Depth
this.liveNode:SetWalkDir(WALK_DIR.RUN_UP)
local timer = 0
local v = Vector3.New(this.liveNode.transform.localPosition.x ,this.liveNode.transform.localPosition.y + 8 ,this.liveNode.transform.localPosition.z )
this:RunMap(v,timer)
end)
end
function this:RunMap(v,timer)
this.liveNode.transform:DOLocalMove(v,1):OnStart(function ()
end):OnUpdate(function()
local y = this.liveNode.transform.localPosition.y -- - (this.camera.orthographicSize/2)
LogGreen("y:"..y)
if y < oriPlayerPos.y then
y = oriPlayerPos.y
elseif y > targetCameraPos.y then
y = targetCameraPos.y
end
this.viewCameraTran.transform.localPosition = Vector3.New(this.viewCameraTran.transform.localPosition.x,y,this.viewCameraTran.transform.localPosition.z)
end):OnComplete(function ()
LogGreen("this.liveNode.transform.localPosition:"..tostring(this.liveNode.transform.localPosition))
v = Vector3.New(this.liveNode.transform.localPosition.x ,this.liveNode.transform.localPosition.y + 8 ,this.liveNode.transform.localPosition.z)
timer = timer + 1
if timer > 5 then
return
else
this:RunMap(v,timer)
end
end):SetEase(Ease.Linear)
end
--添加事件监听(用于子类重写)
function this:AddListener()
end
--移除事件监听(用于子类重写)
function this:RemoveListener()
end
--界面打开时调用(用于子类重写)
function this:OnOpen(_mapData)
this:LoadMapData()
this.LoadTT()
this:SetCameraPos()
end
function this:LoadMapData()
UIManager.camera.clearFlags = CameraClearFlags.Depth
-- 所有物体的根节点
this.mapRoot = poolManager:LoadAsset(mapCtrl, PoolManager.AssetType.GameObject)
this.mapRoot.name = mapCtrl
this.mapRoot.transform:SetParent(UIManager.uiRoot.transform.parent)
this.mapRoot.transform.position = Vector3.New(0, 0, -100)
this.bgRoot = Util.GetGameObject(this.mapRoot,"StoryBG#")
end
function this:SetCameraPos()
this.viewCameraTran = Util.GetGameObject(this.mapRoot,"CameraPos#")
this.camera = Util.GetGameObject(this.viewCameraTran,"Camera"):GetComponent("Camera")
this.camera.orthographic = true
this.camera.orthographicSize = Screen.height / 100 / 2 / (Screen.height / 1920)
LogGreen("this.camera.orthographicSize:"..tostring(this.camera.orthographicSize))
LogGreen("this.liveNode.transform.localPosition:"..tostring(this.liveNode.transform.localPosition))
LogGreen("this.liveNode.transform.Position:"..tostring(this.liveNode.transform.position))
local y = this.liveNode.transform.position.y
this.viewCameraTran.transform.position = Vector3.New(oriCameraPos.x,y,oriCameraPos.z)
end
---加载跑图角色
function this.LoadTT()
if this.liveNode then
this.liveNode:OnClose()
this.liveNode = nil
end
this.liveNode = PlayerLiveView:New(this.mapRoot,1)
this.liveNode:OnOpen(GetPlayerRoleSingleConFig().Scale7)
end
function this:OnShow()
end
--设置跑图角色方向
function this.SetTTDirection()
end
function this:OnSortingOrderChange()
end
--界面关闭时调用(用于子类重写)
function this:OnClose()
poolManager:UnLoadAsset(mapCtrl, this.mapRoot, PoolManager.AssetType.GameObject)
this.mapRoot = nil
this.liveNode:OnClose()
end
--界面销毁时调用(用于子类重写)
function this:OnDestroy()
end
return StoryMapPanel