This commit is contained in:
PC-20230316NUNE\Administrator
2024-08-31 21:05:29 +08:00
parent d67032e1de
commit 77b305be7a
53 changed files with 316 additions and 118 deletions

View File

@@ -1,15 +1,14 @@
using DotRecast.Detour.Crowd;
using System;
using DotRecast.Detour.Crowd;
using Game.Logic.System.Usual;
using JNGame.Math;
using JNGame.Sync.Entity.Component;
using JNGame.Sync.State.Tile.Entity.Component;
namespace Game.JNGFrame.Logic.Entity.Components
namespace Game.Logic.Entity.Nodes.Component.Components
{
/// <summary>
/// 移动组件
/// </summary>
public class EDMoveComponent : JNTileComponent
public class EDMoveComponent : EDEntityComponent
{
public DMapSystem Map => GetSystem<DMapSystem>();
@@ -34,6 +33,16 @@ namespace Game.JNGFrame.Logic.Entity.Components
_info.maxAcceleration = _info.maxSpeed * 4;
}
}
public LVector3 MoveTarget
{
get
{
DtCrowdAgent agent = Map.GetAgent(Entity.Id);
if (agent is null) return LVector3.Zero;
return new LVector3(agent.targetPos.X,agent.targetPos.Y,agent.targetPos.Z);
}
}
public override void OnSyncStart()
{
@@ -98,11 +107,19 @@ namespace Game.JNGFrame.Logic.Entity.Components
Map.VectorMoveAgent(Entity.Id, vector * Speed);
}
public override void OnSyncUpdate()
public bool IsNearTarget()
{
base.OnSyncUpdate();
if (MoveTarget == LVector3.Zero) return true;
DtCrowdAgent agent = Map.GetAgent(Entity.Id);
return EntityBasis.Transform.IsRange(MoveTarget, LFloat.L1 + agent.option.radius);
}
public override void OnSyncUpdate(int dt)
{
base.OnSyncUpdate(dt);
var npos = Map.GetAgent(Entity.Id).npos;
Entity.Transform.Position = new LVector3((LFloat)npos.X, (LFloat)npos.Y, (LFloat)npos.Z);
}
public override void OnSyncDestroy()

View File

@@ -1,5 +1,6 @@
using Game.Input;
using Game.JNGFrame.Logic.Entity.Components;
using Game.Logic.Entity;
using Game.Logic.Entity.Nodes.Component;
using Game.Logic.Entity.Nodes.Component.Components;
using JNGame.Math;
using JNGame.Sync.State.Tile.Entity.Component;
@@ -8,14 +9,35 @@ namespace Game.JNGFrame.Logic.Entity.Controller
/// <summary>
/// Boss控制器
/// </summary>
public class EDBossController : JNTileComponent
public class EDBossController : EDEntityComponent
{
public EDMoveComponent Move => Entity.GetComponent<EDMoveComponent>();
public override void OnSyncStart()
{
base.OnSyncStart();
//Boss 同步到从服务器
TileEntity.IsSyncSlave = true;
Move.Speed = LFloat.L10;
}
public override void OnSyncUpdate(int dt)
{
base.OnSyncUpdate(dt);
// 到达目标则移动
if (Move.IsNearTarget())
{
Move.Go(EntityBasis.GetTileRandom());
}
}
}
}

View File

@@ -1,14 +1,14 @@
using Game.Input;
using Game.JNGFrame.Logic.Entity.Components;
using Game.Logic.Entity.Nodes.Component;
using Game.Logic.Entity.Nodes.Component.Components;
using JNGame.Math;
using JNGame.Sync.State.Tile.Entity.Component;
namespace Game.JNGFrame.Logic.Entity.Controller
{
/// <summary>
/// 角色控制器
/// </summary>
public class EDPlayerController : JNTileComponent
public class EDPlayerController : EDEntityComponent
{
/// <summary>
@@ -37,9 +37,9 @@ namespace Game.JNGFrame.Logic.Entity.Controller
Move.Speed = LFloat.L10;
}
public override void OnSyncUpdate()
public override void OnSyncUpdate(int dt)
{
base.OnSyncUpdate();
base.OnSyncUpdate(dt);
OnMoveUpdate();
}

View File

@@ -0,0 +1,11 @@
using JNGame.Sync.State.Tile.Entity.Component;
namespace Game.Logic.Entity.Nodes.Component
{
public class EDEntityComponent : JNTileComponent
{
public EDEntityBasis EntityBasis => Entity as EDEntityBasis;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c880d909098c44d59b5ec8d009dc1fe4
timeCreated: 1725097481

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 835547007d6f4d88a441f5c4e782b103
timeCreated: 1725097492

View File

@@ -1,9 +1,10 @@
using System;
using Game.JNGFrame.Logic.Entity.Controller;
using Game.Logic.Entity.Nodes.Component.Components;
using JNGame.Sync.Frame.Entity.Components;
using JNGame.Util.Types;
namespace Game.JNGFrame.Logic.Entity.Components
namespace Game.Logic.Entity.Nodes.Component.Lookup
{
public class EDBoosLookup : JNEntityLookup
{

View File

@@ -1,8 +1,9 @@
using System;
using Game.Logic.Entity.Nodes.Component.Components;
using JNGame.Sync.Frame.Entity.Components;
using JNGame.Util.Types;
namespace Game.JNGFrame.Logic.Entity.Components
namespace Game.Logic.Entity.Nodes.Component.Lookup
{
public class EDNodeLookup : JNEntityLookup
{

View File

@@ -1,10 +1,10 @@
using System;
using Game.JNGFrame.Logic.Entity.Controller;
using Game.Logic.Entity.Nodes.Component.Components;
using JNGame.Sync.Frame.Entity.Components;
using JNGame.Util.Types;
using UnityEngine;
namespace Game.JNGFrame.Logic.Entity.Components
namespace Game.Logic.Entity.Nodes.Component.Lookup
{
public class EDPlayerLookup : JNEntityLookup
{

View File

@@ -1,5 +1,6 @@
using Game.JNGFrame.Logic.Entity.Components;
using Game.JNGFrame.Logic.Entity.Controller;
using Game.JNGFrame.Logic.Entity.Controller;
using Game.Logic.Entity.Nodes;
using Game.Logic.Entity.Nodes.Component.Components;
using JNGame.Sync.Frame.Entity;
using JNGame.Sync.State.Tile.Entity;

View File

@@ -1,4 +1,5 @@
using Game.JNGFrame.Logic.Entity.Components;
using Game.Logic.Entity.Nodes;
using Game.Logic.Entity.Nodes.Component.Components;
using JNGame.Sync.Frame.Entity;
using JNGame.Sync.State.Tile.Entity;

View File

@@ -1,5 +1,6 @@
using Game.JNGFrame.Logic.Entity.Components;
using Game.JNGFrame.Logic.Entity.Controller;
using Game.JNGFrame.Logic.Entity.Controller;
using Game.Logic.Entity.Nodes;
using Game.Logic.Entity.Nodes.Component.Components;
using JNGame.Sync.State.Tile.Entity;
namespace Game.JNGFrame.Logic.Entity.Contexts

View File

@@ -1,14 +1,13 @@
using Game.JNGFrame.Logic.Entity.Components;
using Game.JNGFrame.Logic.Entity.Controller;
using Game.JNGFrame.Logic.Entity.Controller;
using Game.JNGState.Logic.Data;
using Game.Logic.Entity.Nodes.Component.Components;
using Game.Logic.Entity.Nodes.Component.Lookup;
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
namespace Game.Logic.Entity.Nodes
{
public class EDBoss : JNTileEntity
public class EDBoss : EDEntityBasis
{
public EDMoveComponent Move => CLookup.Query<EDMoveComponent>(this);

View File

@@ -1,13 +1,13 @@
using Game.JNGFrame.Logic.Entity.Components;
using Game.JNGState.Logic.Data;
using Game.JNGState.Logic.Data;
using Game.Logic.Entity.Nodes.Component.Components;
using Game.Logic.Entity.Nodes.Component.Lookup;
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
namespace Game.Logic.Entity.Nodes
{
public class EDNode : JNTileEntity
public class EDNode : EDEntityBasis
{
public EDMoveComponent Move => CLookup.Query<EDMoveComponent>(this);

View File

@@ -1,15 +1,14 @@
using Game.JNGFrame.Logic.Entity.Components;
using Game.JNGFrame.Logic.Entity.Controller;
using Game.JNGFrame.Logic.Entity.Controller;
using Game.JNGState.Logic.Data;
using JNGame.Math;
using Game.Logic.Entity.Nodes.Component.Components;
using Game.Logic.Entity.Nodes.Component.Lookup;
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
namespace Game.Logic.Entity.Nodes
{
public class EDPlayer : JNTileEntity
public class EDPlayer : EDEntityBasis
{
public EDMoveComponent Move => CLookup.Query<EDMoveComponent>(this);