You've already forked taptap2024_GJ_chidouren
init
This commit is contained in:
20
Assets/Scripts/Game/Component/EnemyFSM_AI/EnemyFSMState.cs
Normal file
20
Assets/Scripts/Game/Component/EnemyFSM_AI/EnemyFSMState.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b1f10345745046a6b4ca1ccc5951d343
|
||||
timeCreated: 1728987048
|
||||
14
Assets/Scripts/Game/Component/EnemyFSM_AI/Follow.cs
Normal file
14
Assets/Scripts/Game/Component/EnemyFSM_AI/Follow.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Game/Component/EnemyFSM_AI/Follow.cs.meta
Normal file
3
Assets/Scripts/Game/Component/EnemyFSM_AI/Follow.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cbe864c917a64ccab3b6b115595248b7
|
||||
timeCreated: 1728987822
|
||||
17
Assets/Scripts/Game/Component/EnemyFSM_AI/Idea.cs
Normal file
17
Assets/Scripts/Game/Component/EnemyFSM_AI/Idea.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Game/Component/EnemyFSM_AI/Idea.cs.meta
Normal file
3
Assets/Scripts/Game/Component/EnemyFSM_AI/Idea.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e32e90cfcf94a799c192bd48694869c
|
||||
timeCreated: 1728986882
|
||||
34
Assets/Scripts/Game/Component/EnemyFSM_AI/RandomWalk.cs
Normal file
34
Assets/Scripts/Game/Component/EnemyFSM_AI/RandomWalk.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f30cf9a1f060477888024e0f40a3bc3e
|
||||
timeCreated: 1728987901
|
||||
9
Assets/Scripts/Game/Component/EnemyFSM_AI/Sleep.cs
Normal file
9
Assets/Scripts/Game/Component/EnemyFSM_AI/Sleep.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using XFFSM;
|
||||
|
||||
namespace Game.Component.EnemyFSM_AI
|
||||
{
|
||||
public class Sleep : EnemyFSMState
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Game/Component/EnemyFSM_AI/Sleep.cs.meta
Normal file
3
Assets/Scripts/Game/Component/EnemyFSM_AI/Sleep.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4468144f266a4902a696efa225b1ee3b
|
||||
timeCreated: 1728986951
|
||||
Reference in New Issue
Block a user