mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交Unity 联机Pro
This commit is contained in:
48
JNFrame2/Assets/Scripts/Game/View/Entity/VDNodes.cs
Normal file
48
JNFrame2/Assets/Scripts/Game/View/Entity/VDNodes.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using AppGame;
|
||||
using DG.Tweening;
|
||||
using Game.JNGFrame.Logic.Entity;
|
||||
using Game.JNGFrame.Logic.System;
|
||||
using Game.JNGState.Logic.Data;
|
||||
using JNGame.Math;
|
||||
using JNGame.Sync.System;
|
||||
using JNGame.Sync.View;
|
||||
using Service;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.JNGFrame.View.Entity
|
||||
{
|
||||
public class VDNodes : ViewData<EDNodeData>
|
||||
{
|
||||
public GameObject VWorld => App.Resource.VWorld;
|
||||
public GameObject Player1 => App.Resource.Player1;
|
||||
public VDNodes(SViewSystem root) : base(root)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ViewUpdate(EDNodeData data, GameObject view)
|
||||
{
|
||||
|
||||
view.name = $"Node_{data.Id}";
|
||||
if (data.Value.Position != null)
|
||||
{
|
||||
view.transform.DOMove(data.Value.Position.ToVector3(), 0.5f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override GameObject NewView(EDNodeData data)
|
||||
{
|
||||
return Object.Instantiate(Player1, VWorld.transform);
|
||||
}
|
||||
|
||||
public override EDNodeData[] GetData()
|
||||
{
|
||||
return GetService<EDNodeDataSystem>().Datas;
|
||||
}
|
||||
|
||||
public override void ViewRemove(GameObject view)
|
||||
{
|
||||
Object.Destroy(view);
|
||||
}
|
||||
}
|
||||
}
|
3
JNFrame2/Assets/Scripts/Game/View/Entity/VDNodes.cs.meta
Normal file
3
JNFrame2/Assets/Scripts/Game/View/Entity/VDNodes.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 658e1c8925f546749725181702b989e9
|
||||
timeCreated: 1715169861
|
78
JNFrame2/Assets/Scripts/Game/View/Entity/VDPlayers.cs
Normal file
78
JNFrame2/Assets/Scripts/Game/View/Entity/VDPlayers.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using AppGame;
|
||||
using AppGame.Sync;
|
||||
using Cinemachine;
|
||||
using DG.Tweening;
|
||||
using Game.JNGFrame.Logic.Entity;
|
||||
using Game.JNGFrame.Logic.System;
|
||||
using Game.JNGState.Logic.Data;
|
||||
using JNGame.Math;
|
||||
using JNGame.Sync.System;
|
||||
using JNGame.Sync.View;
|
||||
using Service;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.JNGFrame.View.Entity
|
||||
{
|
||||
public class VDPlayers : ViewData<EDPlayerData>
|
||||
{
|
||||
public GameObject VWorld => App.Resource.VWorld;
|
||||
public GameObject Player1 => App.Resource.Player1;
|
||||
public CinemachineFreeLook FreeLook => App.Resource.FreeLook;
|
||||
|
||||
public Vector3 pos = new Vector3(0, 0, 0);
|
||||
|
||||
public Vector3 target = new Vector3(0, 0, 0);
|
||||
|
||||
public VDPlayers(SViewSystem root) : base(root)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ViewUpdate(EDPlayerData data, GameObject view)
|
||||
{
|
||||
view.name = $"Player_{data.Id}";
|
||||
|
||||
//更新位置
|
||||
if (data.Value.Position != null)
|
||||
{
|
||||
view.transform.DOKill();
|
||||
view.transform.DOMove(data.Value.Position.ToVector3(), 0.5f);
|
||||
// view.transform.DOKill();
|
||||
// view.transform.DOMove(pos = pos + new Vector3(0,0,10f / 15), 0.07f);
|
||||
}
|
||||
// view.transform.position += new Vector3(0, 0,3f * Time.deltaTime);
|
||||
// view.transform.position += new Vector3(0, 0,30f * Time.deltaTime);
|
||||
// view.transform.position = new Vector3(0, 10, view.transform.position.z);
|
||||
|
||||
//权限操作
|
||||
if (App.IsClient() && data.Value.Auth == App.ClientID)
|
||||
{
|
||||
|
||||
//绑定相机
|
||||
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(Player1, VWorld.transform);
|
||||
// gameObject.transform.DOMove(gameObject.transform.position + new Vector3(0,0,1000), 100);
|
||||
return gameObject;
|
||||
}
|
||||
|
||||
public override EDPlayerData[] GetData()
|
||||
{
|
||||
return GetService<EDPlayerDataSystem>().Datas;
|
||||
}
|
||||
|
||||
public override void ViewRemove(GameObject view)
|
||||
{
|
||||
Object.Destroy(view);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c45ed812046443709890cdd79dfdcb19
|
||||
timeCreated: 1722252921
|
Reference in New Issue
Block a user