mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交
This commit is contained in:
30
JNFrame2/Assets/Scripts/Game/Logic/Entity/EDEntityBasis.cs
Normal file
30
JNFrame2/Assets/Scripts/Game/Logic/Entity/EDEntityBasis.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using JNGame.Math;
|
||||
using JNGame.Sync.Frame.Service;
|
||||
using JNGame.Sync.State.Tile;
|
||||
using JNGame.Sync.State.Tile.Entity;
|
||||
|
||||
namespace Game.Logic.Entity
|
||||
{
|
||||
public abstract class EDEntityBasis : JNTileEntity
|
||||
{
|
||||
|
||||
public JNRandomSystem Random => Context.GetSync().GetSystem<JNRandomSystem>();
|
||||
|
||||
//获取当前权限瓦块随机点
|
||||
public LVector3 GetTileRandom()
|
||||
{
|
||||
|
||||
if (Context.GetSync() is JNSSTileServerService tileServer)
|
||||
{
|
||||
return new LVector3(
|
||||
Random.Float(tileServer.MinContains.x,tileServer.MaxContains.x),
|
||||
LFloat.Zero,
|
||||
Random.Float(tileServer.MinContains.y,tileServer.MaxContains.y)
|
||||
);
|
||||
}
|
||||
return LVector3.Down;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0f4f8b42fdc465b9ad60b8e574aa996
|
||||
timeCreated: 1725096772
|
@@ -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()
|
||||
|
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c880d909098c44d59b5ec8d009dc1fe4
|
||||
timeCreated: 1725097481
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 835547007d6f4d88a441f5c4e782b103
|
||||
timeCreated: 1725097492
|
@@ -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
|
||||
{
|
@@ -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
|
||||
{
|
@@ -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
|
||||
{
|
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using Game.Input;
|
||||
using Game.JNGFrame.Logic.Entity;
|
||||
using Game.JNGFrame.Logic.Entity.Contexts;
|
||||
using Game.Logic.Entity.Nodes;
|
||||
using JNGame.Math;
|
||||
|
||||
namespace Game.Logic.System.Logic
|
||||
@@ -18,9 +19,9 @@ namespace Game.Logic.System.Logic
|
||||
|
||||
public DInputSystem Input => GetSystem<DInputSystem>();
|
||||
|
||||
public override void OnSyncUpdate()
|
||||
public override void OnSyncUpdate(int dt)
|
||||
{
|
||||
base.OnSyncUpdate();
|
||||
base.OnSyncUpdate(dt);
|
||||
|
||||
//创建Boss
|
||||
GetSystem<DInputSystem>().SInput<IDWorld>().ForEach(child =>
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using Game.Input;
|
||||
using Game.JNGFrame.Logic.Entity;
|
||||
using Game.JNGFrame.Logic.Entity.Contexts;
|
||||
using Game.Logic.Entity.Nodes;
|
||||
using JNGame.Math;
|
||||
|
||||
namespace Game.Logic.System.Logic
|
||||
@@ -18,9 +19,9 @@ namespace Game.Logic.System.Logic
|
||||
|
||||
public DInputSystem Input => GetSystem<DInputSystem>();
|
||||
|
||||
public override void OnSyncUpdate()
|
||||
public override void OnSyncUpdate(int dt)
|
||||
{
|
||||
base.OnSyncUpdate();
|
||||
base.OnSyncUpdate(dt);
|
||||
|
||||
//创建角色
|
||||
GetSystem<DInputSystem>().SInput<IDWorld>().ForEach(child =>
|
||||
|
@@ -2,6 +2,7 @@
|
||||
using Game.Input;
|
||||
using Game.JNGFrame.Logic.Entity;
|
||||
using Game.JNGFrame.Logic.Entity.Contexts;
|
||||
using Game.Logic.Entity.Nodes;
|
||||
using JNGame.Math;
|
||||
|
||||
namespace Game.Logic.System.Logic
|
||||
@@ -16,10 +17,10 @@ namespace Game.Logic.System.Logic
|
||||
//Node 第一个节点
|
||||
public Queue<EDNode> NodeQueue = new();
|
||||
|
||||
public override void OnSyncUpdate()
|
||||
public override void OnSyncUpdate(int dt)
|
||||
{
|
||||
|
||||
base.OnSyncUpdate();
|
||||
base.OnSyncUpdate(dt);
|
||||
if (GetSystem<DInputSystem>().SInputOne<IDWorld>() is not IDWorld { IsAdd: true }) return;
|
||||
|
||||
//超过500 则 销毁第一个实体
|
||||
|
@@ -23,9 +23,9 @@ namespace Game.Logic.System.Usual
|
||||
Debug.Log($"DemoMapService - 加载完成地图");
|
||||
}
|
||||
|
||||
public override void OnSyncUpdate()
|
||||
public override void OnSyncUpdate(int dt)
|
||||
{
|
||||
base.OnSyncUpdate();
|
||||
base.OnSyncUpdate(dt);
|
||||
Root.Update(new LFloat(null,Sync.DeltaTime));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user