mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 19:34:47 +00:00
79 lines
2.6 KiB
C#
79 lines
2.6 KiB
C#
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.position = data.Value.Position.ToVector3();
|
|
// 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);
|
|
}
|
|
}
|
|
} |