mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
优化属性更新逻辑
This commit is contained in:
@@ -12,29 +12,30 @@ using UnityEngine;
|
||||
|
||||
namespace Game.JNGFrame.View.Entity
|
||||
{
|
||||
public class VDBoss : ViewData<EDBossData>
|
||||
public class VDBoss : VDEntityBasis<EDBossData>
|
||||
{
|
||||
public GameObject VWorld => App.Resource.VWorld;
|
||||
public GameObject Boss => App.Resource.Boss;
|
||||
|
||||
public VDBoss(SViewSystem root) : base(root)
|
||||
{
|
||||
Register((int)GDataValueCode.Position, OnUpdatePosition);
|
||||
}
|
||||
|
||||
public override void ViewUpdate(EDBossData data, GameObject view)
|
||||
private void OnUpdatePosition((GameObject View, EDBossData Data) tuple)
|
||||
{
|
||||
|
||||
view.name = $"Boss_{data.Id}";
|
||||
var (view, data) = tuple;
|
||||
if (data.Value.Position != null)
|
||||
{
|
||||
view.transform.DOMove(data.Value.Position.ToVector3(), 0.5f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override GameObject NewView(EDBossData data)
|
||||
{
|
||||
return Object.Instantiate(Boss, VWorld.transform);
|
||||
var view = Object.Instantiate(Boss, VWorld.transform);
|
||||
view.name = $"Boss_{data.Id}";
|
||||
return view;
|
||||
}
|
||||
|
||||
public override EDBossData[] GetData()
|
||||
|
@@ -10,28 +10,32 @@ using UnityEngine;
|
||||
|
||||
namespace Game.JNGFrame.View.Entity
|
||||
{
|
||||
public class VDNodes : ViewData<EDNodeData>
|
||||
public class VDNodes : VDEntityBasis<EDNodeData>
|
||||
{
|
||||
public GameObject VWorld => App.Resource.VWorld;
|
||||
public GameObject Player => App.Resource.Player;
|
||||
public VDNodes(SViewSystem root) : base(root)
|
||||
{
|
||||
Register((int)GDataValueCode.Position, OnUpdatePosition);
|
||||
}
|
||||
|
||||
public override void ViewUpdate(EDNodeData data, GameObject view)
|
||||
/// <summary>
|
||||
/// 更新位置
|
||||
/// </summary>
|
||||
private void OnUpdatePosition((GameObject View, EDNodeData Data) tuple)
|
||||
{
|
||||
|
||||
view.name = $"Node_{data.Id}";
|
||||
var (view, data) = tuple;
|
||||
if (data.Value.Position != null)
|
||||
{
|
||||
view.transform.DOMove(data.Value.Position.ToVector3(), 0.5f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override GameObject NewView(EDNodeData data)
|
||||
{
|
||||
return Object.Instantiate(Player, VWorld.transform);
|
||||
var view = Object.Instantiate(Player, VWorld.transform);
|
||||
view.name = $"Node_{data.Id}";
|
||||
return view;
|
||||
}
|
||||
|
||||
public override EDNodeData[] GetData()
|
||||
|
@@ -9,7 +9,7 @@ using UnityEngine;
|
||||
|
||||
namespace Game.JNGFrame.View.Entity
|
||||
{
|
||||
public class VDPlayers : ViewData<EDPlayerData>
|
||||
public class VDPlayers : VDEntityBasis<EDPlayerData>
|
||||
{
|
||||
public GameObject VWorld => App.Resource.VWorld;
|
||||
public GameObject Player => App.Resource.Player;
|
||||
@@ -17,17 +17,41 @@ namespace Game.JNGFrame.View.Entity
|
||||
|
||||
public VDPlayers(SViewSystem root) : base(root)
|
||||
{
|
||||
|
||||
Register((int)GDataValueCode.Position, OnUpdatePosition);
|
||||
Register((int)EDPlayerValueCode.Auth, OnUpdateAuth);
|
||||
|
||||
}
|
||||
|
||||
public override void ViewUpdate(EDPlayerData data, GameObject view)
|
||||
/// <summary>
|
||||
/// 更新坐标
|
||||
/// </summary>
|
||||
/// <param name="tuple"></param>
|
||||
private void OnUpdatePosition((GameObject View, EDPlayerData Data) tuple)
|
||||
{
|
||||
view.name = $"Player_{data.Id}";
|
||||
var (view, data) = tuple;
|
||||
|
||||
//更新位置
|
||||
if (data.Value.Position != null)
|
||||
{
|
||||
view.transform.DOMove(data.Value.Position.ToVector3(), 0.5f);
|
||||
}
|
||||
|
||||
if (data.Value.Auth == App.ClientID)
|
||||
{
|
||||
//更新本地玩家位置
|
||||
if (data.Value.Position != null) App.Game.GetClient<JNGTileClientSystem>()?.SetPlayerPosition(data.Value.Position.ToLVector3());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新权限
|
||||
/// </summary>
|
||||
private void OnUpdateAuth((GameObject View, EDPlayerData Data) tuple)
|
||||
{
|
||||
|
||||
var (view, data) = tuple;
|
||||
|
||||
//权限操作
|
||||
if (App.IsClient() && data.Value.Auth == App.ClientID)
|
||||
@@ -37,17 +61,14 @@ namespace Game.JNGFrame.View.Entity
|
||||
FreeLook.LookAt = view.transform;
|
||||
FreeLook.Follow = view.transform;
|
||||
|
||||
//更新玩家位置
|
||||
if (data.Value.Position != null) App.Game.GetClient<JNGTileClientSystem>()?.SetPlayerPosition(data.Value.Position.ToLVector3());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override GameObject NewView(EDPlayerData data)
|
||||
{
|
||||
var gameObject = Object.Instantiate(Player, VWorld.transform);
|
||||
// gameObject.transform.DOMove(gameObject.transform.position + new Vector3(0,0,1000), 100);
|
||||
gameObject.name = $"Player_{data.Id}";
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user