提交新概念 Tile从服务器

This commit is contained in:
PC-20230316NUNE\Administrator
2024-08-31 15:35:12 +08:00
parent 77db4d7d71
commit d67032e1de
1039 changed files with 57738 additions and 412 deletions

View File

@@ -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(), };
}
}

View File

@@ -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;

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b3e21eba1a90402cbcf1c142b7c6b103
timeCreated: 1724723406

View File

@@ -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));
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3000f079bc5f4d72aa5d6b4145ac5e0e
timeCreated: 1724723017

View File

@@ -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;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: dae9cf4b44914450b1624b40d7646190
timeCreated: 1724723007

View 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();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 473e297b1bcf4ff1ad73d3fd1de8c597
timeCreated: 1724675433

View File

@@ -23,5 +23,6 @@ namespace Game.JNGFrame.Logic.Entity
{
return new EDNodeLookup();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: babf7d8ac075441b803a0078da31ce8a
timeCreated: 1724724193

View File

@@ -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());
}
});
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b48944cb153b4e67809d2cddde1acc6b
timeCreated: 1724724224

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9c7f6594b809471b929e958068a70d32
timeCreated: 1724724127

View File

@@ -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>
/// 游戏数据

View File

@@ -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>
/// 地图