(client) feat:实体的手动控制
This commit is contained in:
@ -33,8 +33,12 @@ namespace AI
|
||||
{
|
||||
|
||||
}
|
||||
public class WanderNode : AIBase
|
||||
public class RandomWander : AIBase
|
||||
{
|
||||
public override JobBase GetJob(Entity.Entity target)
|
||||
{
|
||||
return new WanderJob();
|
||||
}
|
||||
}
|
||||
public class ConditionalAI : AIBase
|
||||
{
|
||||
|
@ -1,12 +1,13 @@
|
||||
using Base;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AI
|
||||
{
|
||||
public abstract class JobBase
|
||||
{
|
||||
public Entity.Entity entity;
|
||||
private int timeoutTicks = 1000;
|
||||
private int timeoutTicks = 100;
|
||||
public bool Running=>timeoutTicks > 0;
|
||||
|
||||
public virtual void StartJob(Entity.Entity target)
|
||||
@ -33,6 +34,28 @@ namespace AI
|
||||
timeoutTicks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public class WanderJob : JobBase
|
||||
{
|
||||
public override void StartJob(Entity.Entity target)
|
||||
{
|
||||
base.StartJob(target);
|
||||
Vector3 move=new(Random.Range(-10,10), Random.Range(-10,10));
|
||||
var targetPosition=entity.transform.position+move;
|
||||
entity.SetTarget(targetPosition);
|
||||
entity.IsChase = false;
|
||||
}
|
||||
|
||||
protected override void UpdateJob()
|
||||
{
|
||||
entity.TryMove();
|
||||
}
|
||||
|
||||
override public void StopJob()
|
||||
{
|
||||
base.StopJob();
|
||||
entity.IsChase = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
2
Client/Assets/Scripts/AI/JobBase.cs.meta
Normal file
2
Client/Assets/Scripts/AI/JobBase.cs.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d2497fdaa11d3554287c58d696dab7e9
|
Reference in New Issue
Block a user