mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 10:46:17 +00:00
提交
This commit is contained in:
52
JNFrame2/Assets/Scripts/Samples/Game/View/Entity/VDBoss.cs
Normal file
52
JNFrame2/Assets/Scripts/Samples/Game/View/Entity/VDBoss.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using AppGame;
|
||||
using AppGame.Sync;
|
||||
using Cinemachine;
|
||||
using DG.Tweening;
|
||||
using Game.JNGFrame.Logic.Entity;
|
||||
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 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);
|
||||
}
|
||||
|
||||
private void OnUpdatePosition((GameObject View, EDBossData Data) tuple)
|
||||
{
|
||||
var (view, data) = tuple;
|
||||
if (data.Value.Position != null)
|
||||
{
|
||||
view.transform.DOMove(data.Value.Position.ToVector3(), 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
public override GameObject NewView(EDBossData data)
|
||||
{
|
||||
var view = Object.Instantiate(Boss, VWorld.transform);
|
||||
view.name = $"Boss_{data.Id}";
|
||||
return view;
|
||||
}
|
||||
|
||||
public override EDBossData[] GetData()
|
||||
{
|
||||
return GetService<EDBossDataSystem>().Datas;
|
||||
}
|
||||
|
||||
public override void ViewRemove(GameObject view)
|
||||
{
|
||||
view.transform.DOKill();
|
||||
Object.Destroy(view);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 211b4062ef0644d583693f4b36358c40
|
||||
timeCreated: 1724724729
|
52
JNFrame2/Assets/Scripts/Samples/Game/View/Entity/VDNodes.cs
Normal file
52
JNFrame2/Assets/Scripts/Samples/Game/View/Entity/VDNodes.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using AppGame;
|
||||
using DG.Tweening;
|
||||
using Game.JNGFrame.Logic.Entity;
|
||||
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 : 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新位置
|
||||
/// </summary>
|
||||
private void OnUpdatePosition((GameObject View, EDNodeData Data) tuple)
|
||||
{
|
||||
var (view, data) = tuple;
|
||||
if (data.Value.Position != null)
|
||||
{
|
||||
view.transform.DOMove(data.Value.Position.ToVector3(), 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
public override GameObject NewView(EDNodeData data)
|
||||
{
|
||||
var view = Object.Instantiate(Player, VWorld.transform);
|
||||
view.name = $"Node_{data.Id}";
|
||||
return view;
|
||||
}
|
||||
|
||||
public override EDNodeData[] GetData()
|
||||
{
|
||||
return GetService<EDNodeDataSystem>().Datas;
|
||||
}
|
||||
|
||||
public override void ViewRemove(GameObject view)
|
||||
{
|
||||
view.transform.DOKill();
|
||||
Object.Destroy(view);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 658e1c8925f546749725181702b989e9
|
||||
timeCreated: 1715169861
|
103
JNFrame2/Assets/Scripts/Samples/Game/View/Entity/VDPlayers.cs
Normal file
103
JNFrame2/Assets/Scripts/Samples/Game/View/Entity/VDPlayers.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using AppGame;
|
||||
using AppGame.Sync;
|
||||
using Cinemachine;
|
||||
using DG.Tweening;
|
||||
using Game.JNGState.Logic.Data;
|
||||
using JNGame.Sync.System;
|
||||
using JNGame.Sync.View;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.JNGFrame.View.Entity
|
||||
{
|
||||
public class VDPlayers : VDEntityBasis<EDPlayerData>
|
||||
{
|
||||
public GameObject VWorld => App.Resource.VWorld;
|
||||
public GameObject Player => App.Resource.Player;
|
||||
public CinemachineFreeLook FreeLook => App.Resource.FreeLook;
|
||||
|
||||
//本地玩家 视图
|
||||
private GameObject LocalView;
|
||||
|
||||
public VDPlayers(SViewSystem root) : base(root)
|
||||
{
|
||||
|
||||
Register((int)GDataValueCode.Position, OnUpdatePosition);
|
||||
Register((int)EDPlayerValueCode.Auth, OnUpdateAuth);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新坐标
|
||||
/// </summary>
|
||||
/// <param name="tuple"></param>
|
||||
private void OnUpdatePosition((GameObject View, EDPlayerData Data) tuple)
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
//绑定相机
|
||||
FreeLook.LookAt = view.transform;
|
||||
FreeLook.Follow = view.transform;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override GameObject NewView(EDPlayerData data)
|
||||
{
|
||||
GameObject view;
|
||||
//如果这个角色是自己 则 直接拿自己的 View
|
||||
if (App.IsClient() && data.Value.Auth == App.ClientID)
|
||||
{
|
||||
if (LocalView is null) LocalView = Object.Instantiate(Player, VWorld.transform);
|
||||
view = LocalView;
|
||||
}
|
||||
else
|
||||
{
|
||||
view = Object.Instantiate(Player, VWorld.transform);
|
||||
}
|
||||
|
||||
view.name = $"Player_{data.Id}";
|
||||
return view;
|
||||
}
|
||||
|
||||
public override EDPlayerData[] GetData()
|
||||
{
|
||||
return GetService<EDPlayerDataSystem>().Datas;
|
||||
}
|
||||
|
||||
public override void ViewRemove(GameObject view)
|
||||
{
|
||||
view.transform.DOKill();
|
||||
if (LocalView != view)
|
||||
{
|
||||
Object.Destroy(view);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c45ed812046443709890cdd79dfdcb19
|
||||
timeCreated: 1722252921
|
Reference in New Issue
Block a user