This commit is contained in:
2024-10-16 00:03:41 +08:00
commit 897058435c
5033 changed files with 1009728 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
using UnityEngine;
using XFFSM;
namespace Game.Component.EnemyFSM_AI
{
public abstract class EnemyFSMState : FSMState
{
protected EnemyEntity Entity;
public override void OnCreate ()
{
this.Entity = (EnemyEntity)this.userData;
}
public void SetAiTarget (Vector2 targetPos)
{
this.Entity.AiLerp.destination = targetPos;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b1f10345745046a6b4ca1ccc5951d343
timeCreated: 1728987048

View File

@@ -0,0 +1,14 @@
namespace Game.Component.EnemyFSM_AI
{
public class Follow : EnemyFSMState
{
public override void OnEnter ()
{
}
public override void OnUpdate ()
{
this.SetAiTarget (MapContent.Instance.PlayerPosition);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cbe864c917a64ccab3b6b115595248b7
timeCreated: 1728987822

View File

@@ -0,0 +1,17 @@
using XFFSM;
namespace Game.Component.EnemyFSM_AI
{
public class Idea : EnemyFSMState
{
public override void OnEnter ()
{
if (!this.Entity.HasSafeArea)
{
this.Entity.EndAttack ();
}
//角色进入idea状态时 重置状态
this.SetAiTarget (this.Entity.CreatePos);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 3e32e90cfcf94a799c192bd48694869c
timeCreated: 1728986882

View File

@@ -0,0 +1,34 @@
using Unity.VisualScripting;
using UnityEngine;
namespace Game.Component.EnemyFSM_AI
{
public class RandomWalk : EnemyFSMState
{
private Vector2 target;
public override void OnEnter ()
{
this.target = this.CreateRandomPos ();
this.SetAiTarget (this.target);
}
public override void OnUpdate ()
{
if (Vector2.Distance (this.Entity.transform.position, this.target) < 0.5f)
{
this.target = this.CreateRandomPos ();
this.SetAiTarget (this.target);
}
}
private Vector2 CreateRandomPos ()
{
var point = this.Entity.CreatePos;
var area = this.Entity.WalkArea.Abs ();
//随机生成一个位置
var x = Random.Range(point.x - area.x / 2, point.x + area.x / 2);
var y = Random.Range(point.y - area.y / 2, point.y + area.y / 2);
return new Vector2(x, y);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: f30cf9a1f060477888024e0f40a3bc3e
timeCreated: 1728987901

View File

@@ -0,0 +1,9 @@
using XFFSM;
namespace Game.Component.EnemyFSM_AI
{
public class Sleep : EnemyFSMState
{
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4468144f266a4902a696efa225b1ee3b
timeCreated: 1728986951