修改提交
This commit is contained in:
89
Assets/Scripts/Fishing/New/View/PlayerViewComponent.cs
Normal file
89
Assets/Scripts/Fishing/New/View/PlayerViewComponent.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using Fantasy.Entitas;
|
||||
using Fantasy.Entitas.Interface;
|
||||
using NBF.Fishing2;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF
|
||||
{
|
||||
public class PlayerViewComponent : Entity
|
||||
{
|
||||
public Player Player { get; private set; }
|
||||
|
||||
public PlayerUnityComponent Unity { get; private set; }
|
||||
|
||||
#region 生命周期
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
Player = GetParent<Player>();
|
||||
var gameObject = PrefabsHelper.CreatePlayer(SceneSettings.Instance.Node);
|
||||
Unity = gameObject.GetComponent<PlayerUnityComponent>();
|
||||
Unity.Player = Player;
|
||||
CreatePlayerModel();
|
||||
if (Player.IsSelf)
|
||||
{
|
||||
CameraManager.Instance.SetFppLook(Unity);
|
||||
}
|
||||
Unity.transform.localPosition = new Vector3(484, 1, 422);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
}
|
||||
|
||||
public void LateUpdate()
|
||||
{
|
||||
Player.EyeAngle = GameUtils.GetVerticalAngle(Unity.transform, Unity.FppLook);
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 模型创建
|
||||
|
||||
private void CreatePlayerModel()
|
||||
{
|
||||
var modelObject = PrefabsHelper.CreatePlayer(Unity.Root, "Human_Male");
|
||||
modelObject.transform.localPosition = Vector3.zero;
|
||||
Unity.ModelAsset = modelObject.GetComponent<PlayerModelAsset>();
|
||||
Unity.ModelAsset.SetPlayer(Unity.FppLook);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class PlayerViewAwakeSystem : AwakeSystem<PlayerViewComponent>
|
||||
{
|
||||
protected override void Awake(PlayerViewComponent self)
|
||||
{
|
||||
self.Awake();
|
||||
}
|
||||
}
|
||||
|
||||
public class PlayerViewDestroySystem : DestroySystem<PlayerViewComponent>
|
||||
{
|
||||
protected override void Destroy(PlayerViewComponent self)
|
||||
{
|
||||
self.Destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public class PlayerViewUpdateSystem : UpdateSystem<PlayerViewComponent>
|
||||
{
|
||||
protected override void Update(PlayerViewComponent self)
|
||||
{
|
||||
self.Update();
|
||||
}
|
||||
}
|
||||
|
||||
public class PlayerViewLateUpdateSystem : LateUpdateSystem<PlayerViewComponent>
|
||||
{
|
||||
protected override void LateUpdate(PlayerViewComponent self)
|
||||
{
|
||||
self.LateUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user