603 lines
28 KiB
Lua
603 lines
28 KiB
Lua
PlayerLiveView = {}
|
|
local this=PlayerLiveView
|
|
local mapNpcOp = "PlayerLiveView"
|
|
local settingValue = ServerConfigManager.GetSettingValue(ServerConfigManager.SettingConfig.IS_TITLE_EFFECT_SCALE)
|
|
-- PlayerLiveViewData = {
|
|
-- ride = 80008
|
|
-- skin = 80012
|
|
-- designation = 80010
|
|
-- }
|
|
|
|
function PlayerLiveView:New(gameObject,_Type, PlayerLiveViewData,orginLayer,posType,_hideRide)
|
|
-- Type = _Type
|
|
-- local b = {}
|
|
-- b.gameObject = gameObject
|
|
-- b.transform = gameObject.transform
|
|
-- setmetatable(b, { __index = PlayerLiveView })
|
|
-- return b
|
|
local instance = {}
|
|
instance.leader = poolManager:LoadAsset(mapNpcOp, PoolManager.AssetType.GameObject)
|
|
instance.gameObject = gameObject
|
|
instance._Type = _Type--1 自己的数据 2 传入PlayerLiveViewData
|
|
if _Type == 2 then
|
|
instance.PlayerLiveViewData = PlayerLiveViewData
|
|
else
|
|
instance.PlayerLiveViewData = {
|
|
ride = PlayerManager.GetPlayerRide(),
|
|
skin = PlayerManager.GetPlayerSkin(),
|
|
sex = NameManager.roleSex,
|
|
designation = PlayerManager.GetPlayerDesignation()
|
|
}
|
|
end
|
|
if _hideRide then
|
|
instance.PlayerLiveViewData.ride = nil
|
|
end
|
|
instance.orginLayer = orginLayer
|
|
instance.transform = gameObject.transform
|
|
instance.leader:SetActive(true)
|
|
instance.leader.transform:SetParent(gameObject.transform)
|
|
instance.leader.transform.localPosition = Vector3.zero
|
|
instance.leader.transform.localScale = Vector3.one
|
|
instance.liveParent = Util.GetGameObject(instance.leader, "liveParent")
|
|
instance.rideLiveGo = Util.GetGameObject(instance.leader, "liveParent/rideLive")
|
|
instance.playerLiveGo = Util.GetGameObject(instance.leader, "liveParent/playerLive")
|
|
instance.titleLiveGo = Util.GetGameObject(instance.leader, "liveParent/titleLive")
|
|
instance.selfTagParent = Util.GetGameObject(instance.leader, "selfTagParent")
|
|
-- instance.liveParentCanvas = instance.liveParent:GetComponent("Canvas")
|
|
instance.nameHeight=0
|
|
instance.posType=posType
|
|
--立绘对象
|
|
instance.rideLive = nil
|
|
instance.playerLive = nil
|
|
instance.titleLive = SubUIManager.Open(SubUIConfig.PlayerTitle, instance.titleLiveGo.transform)
|
|
--立绘资源名字
|
|
instance.rideLiveStr = ""
|
|
instance.playerLiveStr = ""
|
|
instance.titleLiveStr = ""
|
|
--立绘动画控制
|
|
instance.rideLivSkeletonGraphic = nil
|
|
instance.playerLiveSkeletonGraphic = nil
|
|
instance.titleLiveSkeletonGraphic = nil
|
|
|
|
|
|
instance.oldPlayerDirAnimation = nil
|
|
instance.oldPlayerDiry = nil
|
|
instance.oldRideDirAnimation = nil
|
|
instance.oldRideDiry = nil
|
|
setmetatable(instance, { __index = PlayerLiveView })
|
|
return instance
|
|
end
|
|
--初始化组件(用于子类重写)
|
|
function PlayerLiveView:InitComponent()
|
|
end
|
|
|
|
--绑定事件(用于子类重写)
|
|
function PlayerLiveView:BindEvent()
|
|
|
|
end
|
|
|
|
--添加事件监听(用于子类重写)
|
|
function PlayerLiveView:AddListener()
|
|
|
|
end
|
|
|
|
--移除事件监听(用于子类重写)
|
|
function PlayerLiveView:RemoveListener()
|
|
|
|
end
|
|
|
|
--界面打开时调用(用于子类重写)
|
|
function PlayerLiveView:OnOpen(scale,pos,dir,isMap)
|
|
if scale then
|
|
self.leader.transform.localScale = Vector3.New(scale,scale,scale)
|
|
end
|
|
if pos then
|
|
self.leader.transform.localPosition = pos
|
|
end
|
|
self:OnShowLive(isMap)
|
|
if dir then
|
|
self:SetWalkDir(dir)
|
|
end
|
|
self.selfTagParent:SetActive(false)
|
|
-- self.liveParentCanvas.overrideSorting = false
|
|
end
|
|
local sortingorder=0
|
|
|
|
function PlayerLiveView:OnSortingOrderChange(sortingOrder1)
|
|
if sortingOrder1 then
|
|
sortingorder=sortingOrder1
|
|
if self.titleLive then
|
|
self.titleLive:SetLayer(sortingOrder1)
|
|
end
|
|
-- self.liveParentCanvas.overrideSorting = true
|
|
-- self.liveParentCanvas.sortingOrder = sortingorder + 1
|
|
if self.SelfTagGo then
|
|
Util.SetParticleSortLayer(self.SelfTagGo, self:GetSelfTagLayer())
|
|
end
|
|
end
|
|
end
|
|
function PlayerLiveView:RemoveTitleCanvas()
|
|
if self.titleLive then
|
|
self.titleLive:RemoveCanvas()
|
|
end
|
|
end
|
|
|
|
|
|
--加载三个立绘(称号 坐骑 皮肤)
|
|
function PlayerLiveView:OnShowLive(isMap)
|
|
-- LogBlue("self.rideLiveGo "..self.rideLiveGo.name)
|
|
local IsMap=false
|
|
if isMap==nil then
|
|
IsMap=false
|
|
else
|
|
IsMap=isMap
|
|
end
|
|
self.rideLiveGo:SetActive(false)
|
|
self.playerLiveGo:SetActive(false)
|
|
self.titleLiveGo:SetActive(false)
|
|
if self.rideLive then
|
|
poolManager:UnLoadLive(self.rideLiveStr, self.rideLive, PoolManager.AssetType.GameObject)
|
|
self.rideLive = nil
|
|
end
|
|
if self.playerLive then
|
|
poolManager:UnLoadLive(self.playerLiveStr, self.playerLive, PoolManager.AssetType.GameObject)
|
|
self.playerLive = nil
|
|
end
|
|
--时装
|
|
if self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0 then
|
|
self.playerLiveGo:SetActive(true)
|
|
local skinId = tonumber( tostring(self.PlayerLiveViewData.skin) .. tostring(IsMap==true and 2 or self.PlayerLiveViewData.sex))--皮肤 有男女之分 所以在id后加0 or 1
|
|
local curPlayerRole = ConfigManager.GetConfigData(ConfigName.PlayerRole,skinId)
|
|
local curArtResourcesConfig = ConfigManager.GetConfigData(ConfigName.ArtResourcesConfig,curPlayerRole.LiveAnimName)
|
|
local curLocalScale = Vector3.New(curArtResourcesConfig.Scale,curArtResourcesConfig.Scale,curArtResourcesConfig.Scale)
|
|
local curLocalPosition = Vector3.New(curArtResourcesConfig.Position[1],curArtResourcesConfig.Position[2],0)
|
|
self.playerLiveStr = curArtResourcesConfig.Name--"live2d_npc_map"
|
|
self.playerLive = poolManager:LoadLive(self.playerLiveStr, self.playerLiveGo.transform, curLocalScale, curLocalPosition)
|
|
self.playerLiveSkeletonGraphic = self.playerLive:GetComponent("SkeletonGraphic")
|
|
if self.playerLiveSkeletonGraphic then
|
|
if self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0 then
|
|
if self.PlayerLiveViewData.ride == PlayerRide.YUJIAN then
|
|
self.playerLiveSkeletonGraphic.AnimationState:SetAnimation(0, PLAYER_WALK_DIR.IDLE.animation, true)
|
|
else
|
|
self.playerLiveSkeletonGraphic.AnimationState:SetAnimation(0, PLAYER_WALK_DIR.IDLE_FRONT.animation, true)
|
|
end
|
|
else
|
|
self.playerLiveSkeletonGraphic.AnimationState:SetAnimation(0, PLAYER_WALK_DIR.IDLE.animation, true)
|
|
end
|
|
end
|
|
end
|
|
--坐骑
|
|
local isRide=false
|
|
if self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0 then
|
|
isRide = true
|
|
self.rideLiveGo:SetActive(true)
|
|
self.RideConfig = ConfigManager.GetConfigData(ConfigName.PlayerRole,self.PlayerLiveViewData.ride)
|
|
local curArtResourcesConfig = ConfigManager.GetConfigData(ConfigName.ArtResourcesConfig,self.RideConfig.LiveAnimName)
|
|
local curLocalScale = Vector3.New(curArtResourcesConfig.Scale,curArtResourcesConfig.Scale,curArtResourcesConfig.Scale)
|
|
self.RidePosition = Vector3.New(curArtResourcesConfig.Position[1],curArtResourcesConfig.Position[2],0)
|
|
self.rideLiveStr = curArtResourcesConfig.Name
|
|
self.rideLive = poolManager:LoadLive(self.rideLiveStr, self.rideLiveGo.transform, curLocalScale, self.RidePosition)
|
|
self.rideLivSkeletonGraphic = self.rideLive:GetComponent("SkeletonGraphic")
|
|
if self.rideLivSkeletonGraphic then
|
|
self.rideLivSkeletonGraphic.AnimationState:SetAnimation(0, RIDE_WALK_DIR.IDLE_FRONT.animation, true)
|
|
end
|
|
-- 默认向前,设置层级
|
|
self:SetSiblingIndexPlayerOrRide(1)
|
|
end
|
|
|
|
--称号
|
|
if self.PlayerLiveViewData.designation and self.PlayerLiveViewData.designation > 0 then
|
|
self.titleLiveGo:SetActive(true)
|
|
local curPlayerRole = ConfigManager.GetConfigData(ConfigName.PlayerRole,self.PlayerLiveViewData.designation)
|
|
local curArtResourcesConfig = ConfigManager.GetConfigData(ConfigName.ArtResourcesConfig,curPlayerRole.LiveAnimName)
|
|
local curLocalScale = Vector3.New(curArtResourcesConfig.Scale,curArtResourcesConfig.Scale,curArtResourcesConfig.Scale)
|
|
local y=curPlayerRole.Height+2
|
|
if curArtResourcesConfig.Position[2] then
|
|
y=y+curArtResourcesConfig.Position[2]
|
|
end
|
|
if isRide then
|
|
y=y+3+self.nameHeight
|
|
end
|
|
local curLocalPosition = Vector3.New(curArtResourcesConfig.Position[1],y,0)
|
|
-- curArtResourcesConfig.Scale* self.transform.localScale.x
|
|
local effect=0
|
|
if self.posType==NPCPosType.maincity then
|
|
effect=self.transform.localScale.x
|
|
elseif self.posType==NPCPosType.onHook then
|
|
effect=50
|
|
elseif self.posType==NPCPosType.smallMap then
|
|
effect=self.leader.transform.localScale.x
|
|
else
|
|
--effect=self.leader.transform.localScale.x
|
|
effect=45
|
|
end
|
|
self.titleLive:SetShow(self.PlayerLiveViewData.designation, curLocalPosition, curArtResourcesConfig.Scale, curArtResourcesConfig.Scale * effect,self.orginLayer)
|
|
end
|
|
self:SetWalkDir(WALK_DIR.IDLE_FRONT)
|
|
end
|
|
function PlayerLiveView:SetNameHeight(hei)
|
|
self.nameHeight=hei
|
|
end
|
|
|
|
function PlayerLiveView:SetTitleHide()
|
|
self.titleLiveGo:SetActive(false)
|
|
end
|
|
|
|
function PlayerLiveView:SetWalkDir(dir)
|
|
-- LogBlue("PlayerLiveView dir : "..dir)
|
|
if dir == WALK_DIR.IDLE_FRONT then-- 站立_向前
|
|
if (self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0) and (self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0) then
|
|
if self.PlayerLiveViewData.ride == PlayerRide.YUJIAN then
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE,RIDE_WALK_DIR.IDLE_FRONT)
|
|
else
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE_FRONT,RIDE_WALK_DIR.IDLE_FRONT)
|
|
end
|
|
elseif self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0 and (not self.PlayerLiveViewData.ride or self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride <= 0) then
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE,nil)
|
|
elseif self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0 and (not self.PlayerLiveViewData.skin or self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin <= 0) then
|
|
self:SetWalkDirInfo(nil,RIDE_WALK_DIR.IDLE_FRONT)
|
|
end
|
|
-- 设置层级
|
|
self:SetSiblingIndexPlayerOrRide(1)
|
|
self:SetRideOffset(1)
|
|
elseif dir == WALK_DIR.IDLE_BACK then-- 站立_向后
|
|
if (self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0) and (self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0) then
|
|
if self.PlayerLiveViewData.ride == PlayerRide.YUJIAN then
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLEBACK,RIDE_WALK_DIR.IDLE_BACK)
|
|
else
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE_BACK,RIDE_WALK_DIR.IDLE_BACK)
|
|
end
|
|
elseif self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0 and (not self.PlayerLiveViewData.ride or self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride <= 0) then
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLEBACK,nil)
|
|
elseif self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0 and (not self.PlayerLiveViewData.skin or self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin <= 0) then
|
|
self:SetWalkDirInfo(nil,RIDE_WALK_DIR.IDLE_BACK)
|
|
end
|
|
|
|
-- 设置层级
|
|
self:SetSiblingIndexPlayerOrRide(2)
|
|
self:SetRideOffset(2)
|
|
elseif dir == WALK_DIR.IDLE_LEFT then-- 站立_向左
|
|
if (self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0) and (self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0) then
|
|
if self.PlayerLiveViewData.ride == PlayerRide.YUJIAN then
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE_LSTOP,RIDE_WALK_DIR.IDLE_LEFT)
|
|
else
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE_LEFT,RIDE_WALK_DIR.IDLE_LEFT)
|
|
end
|
|
elseif self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0 and (not self.PlayerLiveViewData.ride or self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride <= 0) then
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE_LSTOP,nil)
|
|
elseif self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0 and (not self.PlayerLiveViewData.skin or self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin <= 0) then
|
|
self:SetWalkDirInfo(nil,RIDE_WALK_DIR.IDLE_LEFT)
|
|
end
|
|
-- 设置层级
|
|
self:SetSiblingIndexPlayerOrRide(3)
|
|
self:SetRideOffset(3)
|
|
elseif dir == WALK_DIR.IDLE_RIGHT then-- 站立_向右
|
|
if (self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0) and (self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0) then
|
|
if self.PlayerLiveViewData.ride == PlayerRide.YUJIAN then
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE_RSTOP,RIDE_WALK_DIR.IDLE_RIGHT)
|
|
else
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE_RIGHT,RIDE_WALK_DIR.IDLE_RIGHT)
|
|
end
|
|
elseif self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0 and (not self.PlayerLiveViewData.ride or self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride <= 0) then
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE_RSTOP,nil)
|
|
elseif self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0 and (not self.PlayerLiveViewData.skin or self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin <= 0) then
|
|
self:SetWalkDirInfo(nil,RIDE_WALK_DIR.IDLE_RIGHT)
|
|
end
|
|
|
|
-- 设置层级
|
|
self:SetSiblingIndexPlayerOrRide(4)
|
|
self:SetRideOffset(4)
|
|
elseif dir == WALK_DIR.RUN_RIGHT then-- 跑_向右
|
|
if (self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0) and (self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0) then
|
|
if self.PlayerLiveViewData.ride == PlayerRide.YUJIAN then
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE_RSTOP,RIDE_WALK_DIR.RUN_RIGHT)
|
|
else
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.RUN_RIGHT,RIDE_WALK_DIR.RUN_RIGHT)
|
|
end
|
|
elseif self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0 and (not self.PlayerLiveViewData.ride or self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride <= 0) then
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.RIGHT,nil)
|
|
elseif self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0 and (not self.PlayerLiveViewData.skin or self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin <= 0) then
|
|
self:SetWalkDirInfo(nil,RIDE_WALK_DIR.RUN_RIGHT)
|
|
end
|
|
-- 设置层级
|
|
self:SetSiblingIndexPlayerOrRide(4)
|
|
self:SetRideOffset(4)
|
|
elseif dir == WALK_DIR.RUN_LEFT then-- 跑_向左
|
|
if (self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0) and (self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0) then
|
|
if self.PlayerLiveViewData.ride == PlayerRide.YUJIAN then
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE_LSTOP,RIDE_WALK_DIR.RUN_LEFT)
|
|
else
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.RUN_LEFT,RIDE_WALK_DIR.RUN_LEFT)
|
|
end
|
|
elseif self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0 and (not self.PlayerLiveViewData.ride or self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride <= 0) then
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.LEFT,nil)
|
|
elseif self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0 and (not self.PlayerLiveViewData.skin or self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin <= 0) then
|
|
self:SetWalkDirInfo(nil,RIDE_WALK_DIR.RUN_LEFT)
|
|
end
|
|
-- 设置层级
|
|
self:SetSiblingIndexPlayerOrRide(3)
|
|
self:SetRideOffset(3)
|
|
elseif dir == WALK_DIR.RUN_UP then-- 跑_向上
|
|
if (self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0) and (self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0) then
|
|
if self.PlayerLiveViewData.ride == PlayerRide.YUJIAN then
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLEBACK,RIDE_WALK_DIR.RUN_UP)
|
|
else
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.RUN_UP,RIDE_WALK_DIR.RUN_UP)
|
|
|
|
end
|
|
elseif self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0 and (not self.PlayerLiveViewData.ride or self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride <= 0) then
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.UP,nil)
|
|
elseif self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0 and (not self.PlayerLiveViewData.skin or self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin <= 0) then
|
|
self:SetWalkDirInfo(nil,RIDE_WALK_DIR.RUN_UP)
|
|
end
|
|
-- 设置层级
|
|
self:SetSiblingIndexPlayerOrRide(2)
|
|
self:SetRideOffset(2)
|
|
elseif dir == WALK_DIR.RUN_DOWN then-- 跑_向下
|
|
if (self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0) and (self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0) then
|
|
if self.PlayerLiveViewData.ride == PlayerRide.YUJIAN then
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE,RIDE_WALK_DIR.RUN_DOWN)
|
|
else
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.RUN_DOWN,RIDE_WALK_DIR.RUN_DOWN)
|
|
end
|
|
elseif self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin > 0 and (not self.PlayerLiveViewData.ride or self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride <= 0) then
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.DOWN,nil)
|
|
elseif self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0 and (not self.PlayerLiveViewData.skin or self.PlayerLiveViewData.skin and self.PlayerLiveViewData.skin <= 0) then
|
|
self:SetWalkDirInfo(nil,RIDE_WALK_DIR.DOWN)
|
|
end
|
|
-- 设置层级
|
|
self:SetSiblingIndexPlayerOrRide(1)
|
|
self:SetRideOffset(1)
|
|
elseif dir == WALK_DIR.JINGYA then-- 惊讶
|
|
if self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0 then
|
|
-- self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE_FRONT,RIDE_WALK_DIR.IDLE_FRONT)
|
|
else
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.JINGYA)
|
|
end
|
|
-- self:SetSiblingIndexPlayerOrRide(1)
|
|
elseif dir == WALK_DIR.LAUCH then-- 发射
|
|
if self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0 then
|
|
-- self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE_FRONT,RIDE_WALK_DIR.IDLE_FRONT)
|
|
else
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.LAUCH)
|
|
end
|
|
-- self:SetSiblingIndexPlayerOrRide(1)
|
|
elseif dir == WALK_DIR.TOUCH then-- 轻按
|
|
if self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0 then
|
|
-- self:SetWalkDirInfo(PLAYER_WALK_DIR.IDLE_FRONT,RIDE_WALK_DIR.IDLE_FRONT)
|
|
else
|
|
self:SetWalkDirInfo(PLAYER_WALK_DIR.TOUCH)
|
|
end
|
|
-- self:SetSiblingIndexPlayerOrRide(1)
|
|
end
|
|
end
|
|
function PlayerLiveView:SetWalkDirInfo(playerDir,RideDir)
|
|
if playerDir and (self.oldPlayerDirAnimation ~= playerDir.animation or self.oldPlayerDiry ~= playerDir.y) then
|
|
-- LogBlue("PlayerLiveView playerDir : "..playerDir.animation .." ".. playerDir.y)
|
|
self.playerLiveSkeletonGraphic.transform.localEulerAngles = Vector3.New(0, playerDir.y, 0)
|
|
self.playerLiveSkeletonGraphic.AnimationState:SetAnimation(0, playerDir.animation, true)
|
|
self.oldPlayerDirAnimation = playerDir.animation
|
|
self.oldPlayerDiry = playerDir.y
|
|
end
|
|
if RideDir and (self.oldRideDirAnimation ~= RideDir.animation or self.oldRideDiry ~= RideDir.y) then
|
|
-- LogBlue("PlayerLiveView RideDir : "..RideDir.animation .." ".. RideDir.y)
|
|
self.rideLivSkeletonGraphic.transform.localEulerAngles = Vector3.New(0, RideDir.y, 0)
|
|
self.rideLivSkeletonGraphic.AnimationState:SetAnimation(0, RideDir.animation, true)
|
|
self.oldRideDirAnimation = RideDir.animation
|
|
self.oldRideDiry = RideDir.y
|
|
end
|
|
end
|
|
-- 根据人物方向设置人物和坐骑的层级关系
|
|
function PlayerLiveView:SetSiblingIndexPlayerOrRide(dir)
|
|
if not dir then
|
|
return
|
|
end
|
|
local type = nil
|
|
-- 有坐骑时
|
|
if self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0
|
|
and self.RideConfig and self.RideConfig.RideLayer then
|
|
type = self.RideConfig.RideLayer[dir]
|
|
end
|
|
-- 没有坐骑时
|
|
if not type then
|
|
local dirSibling = {1, 2, 2, 2} -- 前,后,左,右
|
|
type = dirSibling[dir]
|
|
end
|
|
-- 根据类型设置层级
|
|
if type == 1 then--坐骑靠前
|
|
self.playerLiveGo.transform:SetSiblingIndex(2)
|
|
self.rideLiveGo.transform:SetSiblingIndex(3)
|
|
else--时装靠前
|
|
self.rideLiveGo.transform:SetSiblingIndex(2)
|
|
self.playerLiveGo.transform:SetSiblingIndex(3)
|
|
end
|
|
end
|
|
-- 根据人物方向设置设置坐骑的偏移值
|
|
function PlayerLiveView:SetRideOffset(dir)
|
|
if not dir then
|
|
return
|
|
end
|
|
local offset = {0, 0}
|
|
-- 有坐骑时
|
|
if self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0
|
|
and self.RideConfig and self.RideConfig.RideOffset and self.RideConfig.RideOffset[dir] then
|
|
offset = self.RideConfig.RideOffset[dir]
|
|
end
|
|
if self.RidePosition then
|
|
self.rideLive.transform.localPosition = Vector3.New(self.RidePosition.x + offset[1], self.RidePosition.y + offset[2], self.RidePosition.z)
|
|
end
|
|
end
|
|
--界面销毁时调用(用于子类重写)
|
|
function PlayerLiveView:OnClose()
|
|
if self.rideLive then
|
|
poolManager:UnLoadLive(self.rideLiveStr, self.rideLive, PoolManager.AssetType.GameObject)
|
|
self.rideLive = nil
|
|
sortingorder=0
|
|
end
|
|
if self.playerLive then
|
|
poolManager:UnLoadLive(self.playerLiveStr, self.playerLive, PoolManager.AssetType.GameObject)
|
|
self.playerLive = nil
|
|
end
|
|
if self.leader then
|
|
poolManager:UnLoadAsset("PlayerLiveView",self.leader, PoolManager.AssetType.GameObject)
|
|
self.leader = nil
|
|
end
|
|
if self.titleLive then
|
|
SubUIManager.Close(self.titleLive)
|
|
end
|
|
destroy(self.SelfTagGo)
|
|
if self.SelfTagGo then
|
|
destroy(self.SelfTagGo)
|
|
self.SelfTagGo = nil
|
|
end
|
|
end
|
|
|
|
--判断动画是否存在
|
|
-- function PlayerLiveView:CurAnimationState()
|
|
-- -- SkeletonGraphic and SkeletonGraphic.AnimationState
|
|
-- return true
|
|
-- end
|
|
--判断动画是否存在
|
|
function PlayerLiveView:CurAnimationCompleteAddFun(idleFunc)
|
|
if self.playerLiveSkeletonGraphic then
|
|
if self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0 then
|
|
if self.rideLivSkeletonGraphic then
|
|
self.rideLivSkeletonGraphic.AnimationState.Complete = self.rideLivSkeletonGraphic.AnimationState.Complete + idleFunc
|
|
end
|
|
else
|
|
self.playerLiveSkeletonGraphic.AnimationState.Complete = self.playerLiveSkeletonGraphic.AnimationState.Complete + idleFunc
|
|
end
|
|
end
|
|
end
|
|
--设置位置
|
|
function PlayerLiveView:SelectRenPos(ChapterRolePosition,localScaleVer,_parent)
|
|
if self.liveParent then
|
|
self.liveParent:SetActive(true)
|
|
if _parent then
|
|
self.liveParent.transform:SetParent(_parent.transform)
|
|
end
|
|
self.liveParent.transform.localScale = Vector3.New(localScaleVer[1],localScaleVer[2],1)
|
|
self.liveParent:GetComponent("RectTransform").anchoredPosition3D = Vector3.New(ChapterRolePosition[1], ChapterRolePosition[2], 10)
|
|
end
|
|
end
|
|
|
|
-- 走动 传 起始位置 和 目标位置
|
|
function PlayerLiveView:SetRoleWalk(_pos,_tagerPos,_fun)
|
|
local pos = _pos
|
|
local targetPos = _tagerPos
|
|
local speed = 5 -- 越大越慢 到时候 会读表
|
|
self.liveParent.transform:DOLocalMove(targetPos, speed / 5, false):OnStart(function ()
|
|
PlayerLiveView:SetRoleDirAction(targetPos.x, targetPos.y, pos.x, pos.y)
|
|
end):OnUpdate(function() --TODO:测试速度
|
|
|
|
end):OnComplete(function ()
|
|
Log("行走完毕")
|
|
if self.rideLive then
|
|
self.rideLivSkeletonGraphic.AnimationState:SetAnimation(0, "idle", true)
|
|
else
|
|
self.playerLiveSkeletonGraphic.AnimationState:SetAnimation(0, "idle", true)
|
|
end
|
|
if _fun then
|
|
_fun()
|
|
_fun = nil
|
|
end
|
|
end):SetEase(Ease.Linear)
|
|
end
|
|
|
|
function PlayerLiveView:SetRoleDirAction(targetU, targetV, u0, v0)
|
|
local dU = targetU - u0
|
|
local dV = targetV - v0
|
|
if dU > 0 then
|
|
PlayerLiveView:SetWalkDir(WALK_DIR.RUN_RIGHT)
|
|
elseif dU < 0 then
|
|
PlayerLiveView:SetWalkDir(WALK_DIR.RUN_LEFT)
|
|
elseif dV < 0 then
|
|
PlayerLiveView:SetWalkDir(WALK_DIR.RUN_UP)
|
|
elseif dV > 0 then
|
|
PlayerLiveView:SetWalkDir(WALK_DIR.RUN_DOWN)
|
|
end
|
|
end
|
|
|
|
function PlayerLiveView:SetSelfTag()
|
|
if self.SelfTagGo then
|
|
-- poolManager:UnLoadAsset("fx_qufenzhiji",self.SelfTagGo, PoolManager.AssetType.GameObject)
|
|
destroy(self.SelfTagGo)
|
|
self.SelfTagGo = nil
|
|
end
|
|
self.SelfTagGo = poolManager:LoadAsset("fx_qufenzhiji", PoolManager.AssetType.GameObject)
|
|
self.SelfTagGo.transform:SetParent(self.selfTagParent.transform)
|
|
if self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0 then
|
|
self.SelfTagGo.transform.localPosition = Vector3.New(0,-0.95,0)
|
|
else
|
|
self.SelfTagGo.transform.localPosition = Vector3.zero
|
|
end
|
|
self.selfTagParent:SetActive(true)
|
|
if self.SelfTagGo then
|
|
Util.SetParticleSortLayer(self.SelfTagGo, self:GetSelfTagLayer())
|
|
end
|
|
Util.GetGameObject(self.selfTagParent,"direction"):SetActive(false)
|
|
end
|
|
|
|
--设置角色脚底箭头
|
|
function PlayerLiveView:SetSelfDirectingTag(_isShow,_curPos,_targetPos)
|
|
self.selfTagParent:SetActive(true)
|
|
-- if not self.directImg then
|
|
self.directImg = Util.GetGameObject(self.selfTagParent,"direction")
|
|
-- end
|
|
self.directImg:SetActive(_isShow)
|
|
if _isShow then
|
|
local angle = math.atan2((_targetPos.y - _curPos.y),(_targetPos.x - _curPos.x))/math.pi*180
|
|
self.directImg:GetComponent("RectTransform").rotation = Quaternion.Euler(Vector3.New(0,0,angle))
|
|
end
|
|
|
|
if self.SelfTagGo then
|
|
destroy(self.SelfTagGo)
|
|
self.SelfTagGo = nil
|
|
end
|
|
self.SelfTagGo = poolManager:LoadAsset("fx_xunbaomizong_daoda", PoolManager.AssetType.GameObject)
|
|
self.SelfTagGo.transform:SetParent(self.selfTagParent.transform)
|
|
if self.PlayerLiveViewData.ride and self.PlayerLiveViewData.ride > 0 then
|
|
self.SelfTagGo.transform.localPosition = Vector3.New(0,-0.95,0)
|
|
else
|
|
self.SelfTagGo.transform.localPosition = Vector3.New(0,0,10)
|
|
end
|
|
if self.SelfTagGo then
|
|
Util.SetParticleSortLayer(self.SelfTagGo, self:GetSelfTagLayer())
|
|
end
|
|
self.SelfTagGo:SetActive(not _isShow)
|
|
end
|
|
|
|
function PlayerLiveView:SetEffectScale(effectScale)
|
|
if self.SelfTagGo then
|
|
Util.SetParticleScale(self.SelfTagGo, effectScale)
|
|
local isScaleActive = true
|
|
-- 处理喜扑老包称号显示异常的问题,喜扑第一个版本的包在底层删除了缩放节点,这里要处理下针对此包不再进行缩放还原
|
|
if AppConst.isSDK then
|
|
local vc = AndroidDeviceInfo.Instance:GetVersionCode()
|
|
if settingValue and vc == tonumber(settingValue) then
|
|
isScaleActive = false
|
|
end
|
|
end
|
|
|
|
-- 称号显示优化,设置粒子缩放会导致节点缩放,导致粒子显示异常,这里要将缩放还原
|
|
if isScaleActive then
|
|
local particles = self.SelfTagGo:GetComponentsInChildren(typeof(UnityEngine.ParticleSystem))
|
|
local isScale = false
|
|
for key, value in pairs(particles:ToTable()) do
|
|
value.transform.localScale = value.transform.localScale / effectScale
|
|
isScale = true
|
|
end
|
|
if isScale then
|
|
self.SelfTagGo.transform.localScale = Vector3.one * (self.scale or 1)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
function PlayerLiveView:GetSelfTagLayer()
|
|
local cursortingorder = sortingorder - 1
|
|
if UIManager.IsOpen(UIName.FightPointPassMainPanel) or UIManager.IsOpen(UIName.ExplorePanel) then--挂机界面特殊处理
|
|
cursortingorder = 0
|
|
end
|
|
return cursortingorder
|
|
end
|
|
return PlayerLiveView |