mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交新概念 Tile从服务器
This commit is contained in:
28
JNFrame2/Assets/Scripts/Game/Data/EDBossDataSystem.cs
Normal file
28
JNFrame2/Assets/Scripts/Game/Data/EDBossDataSystem.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
using DotRecast.Core.Collections;
|
||||
using Game.JNGFrame.Logic.Entity;
|
||||
using Game.JNGFrame.Logic.Entity.Contexts;
|
||||
using JNGame.Sync.State.Tile.Entity;
|
||||
using JNGame.Sync.System.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.JNGState.Logic.Data
|
||||
{
|
||||
|
||||
public class EDBossData : GDataBase<EDBossData,EDNodeValue,EDBoss>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class EDBossDataSystem : GDataBaseSystem<EDBossData,EDNodeValue,EDBoss>
|
||||
{
|
||||
public EDBossDataSystem(SStateDataEnum type) : base(type)
|
||||
{
|
||||
}
|
||||
|
||||
public override int NetID => (int)NetDataEnum.EDBossData;
|
||||
public override JNTileContext<EDBoss> NodeContext => Contexts.GetContext<EDBossContext>();
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 800b600f0af8416c9f450a329385cfcb
|
||||
timeCreated: 1724675405
|
@@ -25,16 +25,8 @@ namespace Game.JNGState.Logic.Data
|
||||
public class EDNodeData : GDataBase<EDNodeData,EDNodeValue,EDNode>
|
||||
{
|
||||
|
||||
public EDNodeData()
|
||||
{
|
||||
}
|
||||
|
||||
public EDNodeData(EDNode node) : base(node)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
public class EDNodeDataSystem : GDataBaseSystem<EDNodeData,EDNode>
|
||||
public class EDNodeDataSystem : GDataBaseSystem<EDNodeData,EDNodeValue,EDNode>
|
||||
{
|
||||
|
||||
public EDNodeDataSystem(SStateDataEnum type) : base(type)
|
||||
@@ -44,21 +36,6 @@ namespace Game.JNGState.Logic.Data
|
||||
public override JNTileContext<EDNode> NodeContext => Contexts.GetContext<EDNodeContext>();
|
||||
|
||||
public override int NetID => (int)NetDataEnum.EDNodeData;
|
||||
|
||||
public override Dictionary<ulong, EDNodeData> GetLatest()
|
||||
{
|
||||
var nodes = new Dictionary<ulong, EDNodeData>();
|
||||
NodeContext.GetEntities().ForEach(child =>
|
||||
{
|
||||
if (nodes.ContainsKey(child.Id))
|
||||
{
|
||||
Debug.Log($"[EDNodeDataSystem] 出错 发现重复Key");
|
||||
return;
|
||||
}
|
||||
nodes.Add(child.Id,new EDNodeData(child));
|
||||
});
|
||||
return nodes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,16 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DotRecast.Core.Collections;
|
||||
using Entitas;
|
||||
using Game.JNGFrame.Logic.Entity;
|
||||
using Game.JNGFrame.Logic.Entity.Contexts;
|
||||
using JNGame.Math;
|
||||
using JNGame.Sync.State.Tile.Entity;
|
||||
using JNGame.Sync.System;
|
||||
using JNGame.Sync.System.Data;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.JNGState.Logic.Data
|
||||
{
|
||||
@@ -23,13 +18,10 @@ namespace Game.JNGState.Logic.Data
|
||||
|
||||
public class EDPlayerData : GDataBase<EDPlayerData,EDPlayerValue,EDPlayer>
|
||||
{
|
||||
public EDPlayerData()
|
||||
public override void BindEntity(JNTileEntity entity)
|
||||
{
|
||||
}
|
||||
|
||||
public EDPlayerData(EDPlayer node) : base(node)
|
||||
{
|
||||
Value.Auth = node.Controller.Auth;
|
||||
base.BindEntity(entity);
|
||||
Value.Auth = Node.Controller.Auth;
|
||||
}
|
||||
|
||||
public override bool IsEquals(ISData data)
|
||||
@@ -58,7 +50,7 @@ namespace Game.JNGState.Logic.Data
|
||||
}
|
||||
|
||||
|
||||
public class EDPlayerDataSystem : GDataBaseSystem<EDPlayerData,EDPlayer>
|
||||
public class EDPlayerDataSystem : GDataBaseSystem<EDPlayerData,EDPlayerValue,EDPlayer>
|
||||
{
|
||||
|
||||
public EDPlayerDataSystem(SStateDataEnum type) : base(type)
|
||||
@@ -69,17 +61,6 @@ namespace Game.JNGState.Logic.Data
|
||||
|
||||
public override JNTileContext<EDPlayer> NodeContext => Contexts.GetContext<EDPlayerContext>();
|
||||
|
||||
|
||||
public override Dictionary<ulong, EDPlayerData> GetLatest()
|
||||
{
|
||||
var nodes = new Dictionary<ulong, EDPlayerData>();
|
||||
NodeContext.GetEntities().ForEach(child =>
|
||||
{
|
||||
nodes.Add(child.Id,new EDPlayerData(child));
|
||||
});
|
||||
return nodes;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,7 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Text;
|
||||
using AppGame;
|
||||
using AppGame.Systems.CServer;
|
||||
using DotRecast.Core.Collections;
|
||||
using Google.Protobuf;
|
||||
using JNGame.Math;
|
||||
using JNGame.Sync.Entity;
|
||||
@@ -10,6 +14,7 @@ using JNGame.Sync.System;
|
||||
using JNGame.Sync.System.Data;
|
||||
using Newtonsoft.Json;
|
||||
using Plugins.JNGame.Network.Action;
|
||||
using Plugins.JNGame.Util;
|
||||
|
||||
namespace Game.JNGState.Logic.Data
|
||||
{
|
||||
@@ -27,22 +32,19 @@ namespace Game.JNGState.Logic.Data
|
||||
|
||||
public N Node => Entity as N;
|
||||
|
||||
public override bool IsHost => Node is not null && Node.IsHost;
|
||||
|
||||
public GDataBase()
|
||||
{
|
||||
}
|
||||
|
||||
public GDataBase(N node)
|
||||
public override void BindEntity(JNTileEntity entity)
|
||||
{
|
||||
Id = node.Id;
|
||||
base.BindEntity(entity);
|
||||
Value.Position = new DValuePosition()
|
||||
{
|
||||
x = node.Position.x.rawValue,
|
||||
y = node.Position.y.rawValue,
|
||||
z = node.Position.z.rawValue,
|
||||
x = Node.Position.x.rawValue,
|
||||
y = Node.Position.y.rawValue,
|
||||
z = Node.Position.z.rawValue,
|
||||
};
|
||||
BindEntity(node);
|
||||
}
|
||||
|
||||
public override bool IsEquals(ISData data)
|
||||
@@ -54,7 +56,8 @@ namespace Game.JNGState.Logic.Data
|
||||
|
||||
public sealed override byte[] GetByte()
|
||||
{
|
||||
return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(Value));
|
||||
// return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(Value));
|
||||
return ToUtil.ObjectToBytes(Value);
|
||||
}
|
||||
|
||||
public sealed override byte[] GetByteDifference(ISData diffValue = null)
|
||||
@@ -62,7 +65,8 @@ namespace Game.JNGState.Logic.Data
|
||||
var diff = GetDifference(diffValue);
|
||||
if (diff is not null)
|
||||
{
|
||||
return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(diff));
|
||||
// return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(diff));
|
||||
return ToUtil.ObjectToBytes(diff);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -85,7 +89,8 @@ namespace Game.JNGState.Logic.Data
|
||||
public sealed override void UByte(byte[] bytes)
|
||||
{
|
||||
if (bytes.Length == 0) return;
|
||||
var value = JsonConvert.DeserializeObject<T>(Encoding.UTF8.GetString(bytes));
|
||||
// var value = JsonConvert.DeserializeObject<T>(Encoding.UTF8.GetString(bytes));
|
||||
var value = ToUtil.BytesToObject<T>(bytes);
|
||||
UData(value);
|
||||
}
|
||||
|
||||
@@ -104,28 +109,54 @@ namespace Game.JNGState.Logic.Data
|
||||
|
||||
}
|
||||
|
||||
public abstract class GDataBaseSystem<T,E> : STileDataSystem<T,E> where T : ISTileData,new() where E : JNTileEntity, new()
|
||||
public abstract class GDataBaseSystem<T,V,E> : STileDataSystem<T,E> where T : GDataBase<T,V,E>,new() where E : JNTileEntity, new() where V : GDataValue,new()
|
||||
{
|
||||
protected GDataBaseSystem(SStateDataEnum type) : base(type)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnSendUBytes(Dictionary<ulong, byte[]> bytes)
|
||||
public override Dictionary<ulong, T> GetLatest()
|
||||
{
|
||||
var nodes = new Dictionary<ulong, T>();
|
||||
NodeContext.GetHostEntities().ForEach(child =>
|
||||
{
|
||||
var entity = new T();
|
||||
entity.BindEntity(child);
|
||||
nodes.Add(child.Id,entity);
|
||||
});
|
||||
return nodes;
|
||||
}
|
||||
|
||||
JNStateItemData data = new JNStateItemData();
|
||||
data.NetID = NetID;
|
||||
|
||||
public override void OnSendAllData(Dictionary<ulong, byte[]> bytes)
|
||||
{
|
||||
JNStateItemData player = new JNStateItemData(); //玩家状态数据
|
||||
player.NetID = NetID;
|
||||
foreach (var byteItem in bytes)
|
||||
{
|
||||
data.Messages.Add(byteItem.Key,new JNStateData()
|
||||
var data = new JNStateData()
|
||||
{
|
||||
Data = ByteString.CopyFrom(byteItem.Value)
|
||||
});
|
||||
};
|
||||
player.Messages.Add(byteItem.Key,data);
|
||||
}
|
||||
|
||||
App.Server.AllSend((int)NActionEnum.NSyncStateDataUpdate,data);
|
||||
|
||||
//给玩家发送状态信息
|
||||
App.Server.AllSend((int)NActionEnum.NSyncStateDataUpdate,player,client => App.Server.Roles.TryGetValue(client.Id,out var role) && role == JNGClientRole.Player);
|
||||
}
|
||||
|
||||
public override void OnSendSlaveData(Dictionary<ulong, byte[]> bytes)
|
||||
{
|
||||
JNStateItemData slave = new JNStateItemData(); //玩家状态数据
|
||||
slave.NetID = NetID;
|
||||
foreach (var byteItem in bytes)
|
||||
{
|
||||
var data = new JNStateData()
|
||||
{
|
||||
Data = ByteString.CopyFrom(byteItem.Value)
|
||||
};
|
||||
slave.Messages.Add(byteItem.Key,data);
|
||||
}
|
||||
//给从服务器发送状态信息
|
||||
App.Server.AllSend((int)NActionEnum.NSyncStateDataUpdate,slave,client => App.Server.Roles.TryGetValue(client.Id,out var role) && role == JNGClientRole.SlaveServer);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -4,5 +4,6 @@
|
||||
{
|
||||
EDNodeData = 0,
|
||||
EDPlayerData = 1,
|
||||
EDBossData = 2,
|
||||
}
|
||||
}
|
@@ -20,5 +20,10 @@ namespace Game.Input
|
||||
/// </summary>
|
||||
public bool IsPlayerCreate;
|
||||
|
||||
/// <summary>
|
||||
/// Boss创建
|
||||
/// </summary>
|
||||
public bool IsBossCreate;
|
||||
|
||||
}
|
||||
}
|
@@ -1,7 +1,5 @@
|
||||
using Entitas;
|
||||
using Game.JNGFrame.Logic.Entity.Contexts;
|
||||
using JNGame.Sync.Entity;
|
||||
using JNGame.Sync.Frame.Entity;
|
||||
using JNGame.Sync.State.Tile.Entity;
|
||||
|
||||
namespace Game.JNGFrame.Logic.Entity
|
||||
@@ -9,7 +7,7 @@ namespace Game.JNGFrame.Logic.Entity
|
||||
public class EDContexts : JNTileContexts
|
||||
{
|
||||
|
||||
public override IContext[] allContexts { get; } = { new EDNodeContext(),new EDPlayerContext() };
|
||||
public override IContext[] allContexts { get; } = { new EDNodeContext(),new EDPlayerContext(),new EDBossContext(), };
|
||||
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
using DotRecast.Detour.Crowd;
|
||||
using Game.JNGFrame.Logic.System;
|
||||
using Game.Logic.System.Usual;
|
||||
using JNGame.Math;
|
||||
using JNGame.Sync.Entity.Component;
|
||||
using JNGame.Sync.State.Tile.Entity.Component;
|
||||
|
@@ -0,0 +1,21 @@
|
||||
using Game.Input;
|
||||
using Game.JNGFrame.Logic.Entity.Components;
|
||||
using JNGame.Math;
|
||||
using JNGame.Sync.State.Tile.Entity.Component;
|
||||
|
||||
namespace Game.JNGFrame.Logic.Entity.Controller
|
||||
{
|
||||
/// <summary>
|
||||
/// Boss控制器
|
||||
/// </summary>
|
||||
public class EDBossController : JNTileComponent
|
||||
{
|
||||
public override void OnSyncStart()
|
||||
{
|
||||
base.OnSyncStart();
|
||||
|
||||
//Boss 同步到从服务器
|
||||
TileEntity.IsSyncSlave = true;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3e21eba1a90402cbcf1c142b7c6b103
|
||||
timeCreated: 1724723406
|
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using Game.JNGFrame.Logic.Entity.Controller;
|
||||
using JNGame.Sync.Frame.Entity.Components;
|
||||
using JNGame.Util.Types;
|
||||
|
||||
namespace Game.JNGFrame.Logic.Entity.Components
|
||||
{
|
||||
public class EDBoosLookup : JNEntityLookup
|
||||
{
|
||||
|
||||
//移动组件
|
||||
public int Movement { get; set; }
|
||||
public int Controller { get; set; }
|
||||
|
||||
protected override void BindIndex()
|
||||
{
|
||||
base.BindIndex();
|
||||
Movement = Next();
|
||||
Controller = Next();
|
||||
}
|
||||
|
||||
protected override void BindType(KeyValue<int, Type> types)
|
||||
{
|
||||
base.BindType(types);
|
||||
types.Add(Movement,typeof(EDMoveComponent));
|
||||
types.Add(Controller,typeof(EDBossController));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3000f079bc5f4d72aa5d6b4145ac5e0e
|
||||
timeCreated: 1724723017
|
@@ -0,0 +1,18 @@
|
||||
using Game.JNGFrame.Logic.Entity.Components;
|
||||
using Game.JNGFrame.Logic.Entity.Controller;
|
||||
using JNGame.Sync.Frame.Entity;
|
||||
using JNGame.Sync.State.Tile.Entity;
|
||||
|
||||
namespace Game.JNGFrame.Logic.Entity.Contexts
|
||||
{
|
||||
public sealed partial class EDBossContext : JNTileContext<EDBoss>
|
||||
{
|
||||
protected override EDBoss BindComponent(EDBoss entity)
|
||||
{
|
||||
base.BindComponent(entity);
|
||||
entity.AddComponent<EDMoveComponent>();
|
||||
entity.AddComponent<EDBossController>();
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dae9cf4b44914450b1624b40d7646190
|
||||
timeCreated: 1724723007
|
29
JNFrame2/Assets/Scripts/Game/Logic/Entity/Nodes/EDBoss.cs
Normal file
29
JNFrame2/Assets/Scripts/Game/Logic/Entity/Nodes/EDBoss.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Game.JNGFrame.Logic.Entity.Components;
|
||||
using Game.JNGFrame.Logic.Entity.Controller;
|
||||
using Game.JNGState.Logic.Data;
|
||||
using JNGame.Sync.Frame.Entity.Components;
|
||||
using JNGame.Sync.State.Tile.Entity;
|
||||
using JNGame.Sync.System.Data;
|
||||
using NotImplementedException = System.NotImplementedException;
|
||||
|
||||
namespace Game.JNGFrame.Logic.Entity
|
||||
{
|
||||
public class EDBoss : JNTileEntity
|
||||
{
|
||||
|
||||
public EDMoveComponent Move => CLookup.Query<EDMoveComponent>(this);
|
||||
public EDBossController Controller => CLookup.Query<EDBossController>(this);
|
||||
|
||||
public override void TileSyncData(ISTileData data)
|
||||
{
|
||||
var nodeData = data as EDBossData;
|
||||
Transform.Position = nodeData.Value.Position.ToLVector3();
|
||||
}
|
||||
|
||||
public override JNEntityLookup NewCLookup()
|
||||
{
|
||||
return new EDBoosLookup();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 473e297b1bcf4ff1ad73d3fd1de8c597
|
||||
timeCreated: 1724675433
|
@@ -23,5 +23,6 @@ namespace Game.JNGFrame.Logic.Entity
|
||||
{
|
||||
return new EDNodeLookup();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
3
JNFrame2/Assets/Scripts/Game/Logic/System/Logic.meta
Normal file
3
JNFrame2/Assets/Scripts/Game/Logic/System/Logic.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: babf7d8ac075441b803a0078da31ce8a
|
||||
timeCreated: 1724724193
|
@@ -0,0 +1,40 @@
|
||||
using DotRecast.Core.Collections;
|
||||
using Game.Input;
|
||||
using Game.JNGFrame.Logic.Entity;
|
||||
using Game.JNGFrame.Logic.Entity.Contexts;
|
||||
using JNGame.Math;
|
||||
|
||||
namespace Game.Logic.System.Logic
|
||||
{
|
||||
/// <summary>
|
||||
/// Boss逻辑
|
||||
/// </summary>
|
||||
public class DBossSystem : DGBasisSystem
|
||||
{
|
||||
|
||||
//Node 节点
|
||||
public EDBoss[] Nodes => NodeContext.GetHostEntities();
|
||||
public EDBossContext NodeContext => Contexts.GetContext<EDBossContext>();
|
||||
|
||||
public DInputSystem Input => GetSystem<DInputSystem>();
|
||||
|
||||
public override void OnSyncUpdate()
|
||||
{
|
||||
base.OnSyncUpdate();
|
||||
|
||||
//创建Boss
|
||||
GetSystem<DInputSystem>().SInput<IDWorld>().ForEach(child =>
|
||||
{
|
||||
|
||||
var idWorld = (IDWorld)child.Value;
|
||||
if (idWorld is { IsBossCreate: true })
|
||||
{
|
||||
var entity = NodeContext.CreateEntity();
|
||||
entity.Move.SetPosition(GetTileRandom());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b48944cb153b4e67809d2cddde1acc6b
|
||||
timeCreated: 1724724224
|
@@ -3,11 +3,8 @@ using Game.Input;
|
||||
using Game.JNGFrame.Logic.Entity;
|
||||
using Game.JNGFrame.Logic.Entity.Contexts;
|
||||
using JNGame.Math;
|
||||
using JNGame.Sync.Frame.Service;
|
||||
using JNGame.Sync.System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Logic.System
|
||||
namespace Game.Logic.System.Logic
|
||||
{
|
||||
/// <summary>
|
||||
/// 玩家逻辑
|
||||
@@ -31,7 +28,7 @@ namespace Game.Logic.System
|
||||
var key = child.Key;
|
||||
var idWorld = (IDWorld)child.Value;
|
||||
|
||||
if (idWorld != null && idWorld.IsPlayerCreate)
|
||||
if (idWorld is { IsPlayerCreate: true })
|
||||
{
|
||||
var entity = NodeContext.CreateEntity();
|
||||
entity.Controller.AuthBind(key);
|
@@ -1,13 +1,10 @@
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using Game.Input;
|
||||
using Game.JNGFrame.Logic.Entity;
|
||||
using Game.JNGFrame.Logic.Entity.Contexts;
|
||||
using Game.Logic.System;
|
||||
using JNGame.Math;
|
||||
using JNGame.Sync.Frame.Service;
|
||||
using JNGame.Sync.System;
|
||||
|
||||
namespace Game.JNGFrame.Logic.System
|
||||
namespace Game.Logic.System.Logic
|
||||
{
|
||||
public class DWorldSystem : DGBasisSystem
|
||||
{
|
||||
@@ -15,7 +12,10 @@ namespace Game.JNGFrame.Logic.System
|
||||
//Node 节点
|
||||
public EDNode[] Nodes => NodeContext.GetHostEntities();
|
||||
public EDNodeContext NodeContext => Contexts.GetContext<EDNodeContext>();
|
||||
|
||||
|
||||
//Node 第一个节点
|
||||
public Queue<EDNode> NodeQueue = new();
|
||||
|
||||
public override void OnSyncUpdate()
|
||||
{
|
||||
|
||||
@@ -25,28 +25,29 @@ namespace Game.JNGFrame.Logic.System
|
||||
//超过500 则 销毁第一个实体
|
||||
if (Nodes.Length >= 100)
|
||||
{
|
||||
var node = Nodes[0];
|
||||
node.Destroy();
|
||||
NodeQueue.Dequeue().Destroy();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var max = 100;
|
||||
EDNode entity;
|
||||
if (IsTile())
|
||||
{
|
||||
var entity = Contexts.GetContext<EDNodeContext>().CreateEntity();
|
||||
entity = Contexts.GetContext<EDNodeContext>().CreateEntity();
|
||||
entity.Move.SetPosition(GetTileRandom());
|
||||
entity.Move.Go(GetTileRandom());
|
||||
}
|
||||
else
|
||||
{
|
||||
var entity = Contexts.GetContext<EDNodeContext>().CreateEntity();
|
||||
entity = Contexts.GetContext<EDNodeContext>().CreateEntity();
|
||||
var spawn = new LVector3(Random.Float(0, max),Random.Float(0, 100),Random.Float(0, max));
|
||||
entity.Move.SetPosition(spawn);
|
||||
spawn = new LVector3(Random.Float(0, max),Random.Float(0, 100),Random.Float(0, max));
|
||||
entity.Move.Go(spawn);
|
||||
}
|
||||
|
||||
|
||||
NodeQueue.Enqueue(entity);
|
||||
|
||||
}
|
||||
|
3
JNFrame2/Assets/Scripts/Game/Logic/System/Usual.meta
Normal file
3
JNFrame2/Assets/Scripts/Game/Logic/System/Usual.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c7f6594b809471b929e958068a70d32
|
||||
timeCreated: 1724724127
|
@@ -1,11 +1,8 @@
|
||||
using AppGame;
|
||||
using Game.Logic.System;
|
||||
using JNGame.Map;
|
||||
using JNGame.Map.DotRecast.Util;
|
||||
using JNGame.Sync.System;
|
||||
using Service;
|
||||
|
||||
namespace Game.JNGFrame.Logic
|
||||
namespace Game.Logic.System.Usual
|
||||
{
|
||||
/// <summary>
|
||||
/// 游戏数据
|
@@ -2,13 +2,11 @@
|
||||
using DotRecast.Core.Numerics;
|
||||
using DotRecast.Detour;
|
||||
using DotRecast.Detour.Crowd;
|
||||
using Game.Logic.System;
|
||||
using JNGame.Map.DotRecast;
|
||||
using JNGame.Math;
|
||||
using JNGame.Sync.System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.JNGFrame.Logic.System
|
||||
namespace Game.Logic.System.Usual
|
||||
{
|
||||
/// <summary>
|
||||
/// 地图
|
@@ -14,6 +14,7 @@ namespace Game.JNGFrame.View
|
||||
views = new IViewData[] {
|
||||
new VDNodes(this), //显示Demo实体
|
||||
new VDPlayers(this), //显示玩家实体
|
||||
new VDBoss(this), //显示Boss实体
|
||||
};
|
||||
}
|
||||
|
||||
|
50
JNFrame2/Assets/Scripts/Game/View/Entity/VDBoss.cs
Normal file
50
JNFrame2/Assets/Scripts/Game/View/Entity/VDBoss.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
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 : ViewData<EDBossData>
|
||||
{
|
||||
public GameObject VWorld => App.Resource.VWorld;
|
||||
public GameObject Boss => App.Resource.Boss;
|
||||
|
||||
public VDBoss(SViewSystem root) : base(root)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ViewUpdate(EDBossData data, GameObject view)
|
||||
{
|
||||
|
||||
view.name = $"Boss_{data.Id}";
|
||||
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);
|
||||
}
|
||||
|
||||
public override EDBossData[] GetData()
|
||||
{
|
||||
return GetService<EDBossDataSystem>().Datas;
|
||||
}
|
||||
|
||||
public override void ViewRemove(GameObject view)
|
||||
{
|
||||
Object.Destroy(view);
|
||||
}
|
||||
}
|
||||
}
|
3
JNFrame2/Assets/Scripts/Game/View/Entity/VDBoss.cs.meta
Normal file
3
JNFrame2/Assets/Scripts/Game/View/Entity/VDBoss.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 211b4062ef0644d583693f4b36358c40
|
||||
timeCreated: 1724724729
|
@@ -1,7 +1,6 @@
|
||||
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;
|
||||
@@ -14,7 +13,7 @@ namespace Game.JNGFrame.View.Entity
|
||||
public class VDNodes : ViewData<EDNodeData>
|
||||
{
|
||||
public GameObject VWorld => App.Resource.VWorld;
|
||||
public GameObject Player1 => App.Resource.Player1;
|
||||
public GameObject Player => App.Resource.Player;
|
||||
public VDNodes(SViewSystem root) : base(root)
|
||||
{
|
||||
}
|
||||
@@ -32,7 +31,7 @@ namespace Game.JNGFrame.View.Entity
|
||||
|
||||
public override GameObject NewView(EDNodeData data)
|
||||
{
|
||||
return Object.Instantiate(Player1, VWorld.transform);
|
||||
return Object.Instantiate(Player, VWorld.transform);
|
||||
}
|
||||
|
||||
public override EDNodeData[] GetData()
|
||||
|
@@ -2,13 +2,9 @@
|
||||
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
|
||||
@@ -16,13 +12,9 @@ namespace Game.JNGFrame.View.Entity
|
||||
public class VDPlayers : ViewData<EDPlayerData>
|
||||
{
|
||||
public GameObject VWorld => App.Resource.VWorld;
|
||||
public GameObject Player1 => App.Resource.Player1;
|
||||
public GameObject Player => App.Resource.Player;
|
||||
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)
|
||||
{
|
||||
}
|
||||
@@ -36,13 +28,7 @@ namespace Game.JNGFrame.View.Entity
|
||||
{
|
||||
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)
|
||||
@@ -61,7 +47,7 @@ namespace Game.JNGFrame.View.Entity
|
||||
|
||||
public override GameObject NewView(EDPlayerData data)
|
||||
{
|
||||
var gameObject = Object.Instantiate(Player1, VWorld.transform);
|
||||
var gameObject = Object.Instantiate(Player, VWorld.transform);
|
||||
// gameObject.transform.DOMove(gameObject.transform.position + new Vector3(0,0,1000), 100);
|
||||
return gameObject;
|
||||
}
|
||||
|
Reference in New Issue
Block a user