You've already forked taptap2024_GJ_chidouren
完成4种基础ai
This commit is contained in:
33
Assets/Scripts/Game/Component/FsmMonoData/AttackTimer.cs
Normal file
33
Assets/Scripts/Game/Component/FsmMonoData/AttackTimer.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using Framework.Timer;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
public class AttackTimer : MonoBehaviour
|
||||
{
|
||||
[SerializeField, Header ("追逐时长")] private float AttackRealTime;
|
||||
private TimeHandler _timeHandler;
|
||||
|
||||
[ProgressBar(0 , "Curprogress")]
|
||||
public float Curprogress => this._timeHandler?.CurProgress ?? 0;
|
||||
|
||||
public bool IsRunning => this._timeHandler?.IsPlaying ?? false;
|
||||
|
||||
|
||||
public void StartAttack (Action callback)
|
||||
{
|
||||
this._timeHandler?.Kill ();
|
||||
this._timeHandler = GameUpdateMgr.Instance.CreateTimer (this.AttackRealTime , callback);
|
||||
}
|
||||
|
||||
public void StopAttack ()
|
||||
{
|
||||
this._timeHandler?.Kill ();
|
||||
this._timeHandler = null;
|
||||
}
|
||||
|
||||
private void OnDisable ()
|
||||
{
|
||||
StopAttack ();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eaef8af63e5b481a835fd19a9ea60e15
|
||||
timeCreated: 1729082604
|
||||
49
Assets/Scripts/Game/Component/FsmMonoData/WalkPathGroup.cs
Normal file
49
Assets/Scripts/Game/Component/FsmMonoData/WalkPathGroup.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Game.Component.Map;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Game.Component.FsmMonoData
|
||||
{
|
||||
public class WalkPathGroup : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private MovePathGroup PathGroup;
|
||||
|
||||
private int _curIndex;
|
||||
|
||||
public Vector2 CurTarget { get; private set; }
|
||||
|
||||
public void InitTarget (Vector2 actorPos)
|
||||
{
|
||||
//根据角色当前位置,寻找最近的节点
|
||||
_curIndex = 0;
|
||||
CurTarget = this.PathGroup.PathList[0].position;
|
||||
for (int i = 1; i < this.PathGroup.PathList.Count; i++)
|
||||
{
|
||||
if (Vector2.Distance (actorPos , this.PathGroup.PathList[i].position) < Vector2.Distance (actorPos , CurTarget))
|
||||
{
|
||||
_curIndex = i;
|
||||
CurTarget = this.PathGroup.PathList[i].position;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool CheckNextNode (Vector2 actorPos)
|
||||
{
|
||||
if (Vector2.Distance (actorPos , CurTarget) < 0.1f)
|
||||
{
|
||||
NextNode ();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void NextNode ()
|
||||
{
|
||||
_curIndex++;
|
||||
if (this._curIndex >= this.PathGroup.PathList.Count)
|
||||
{
|
||||
_curIndex = 0;
|
||||
}
|
||||
CurTarget = this.PathGroup.PathList[_curIndex].position;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 954117e49b324df0a8e9fbe6556f9578
|
||||
timeCreated: 1729095580
|
||||
Reference in New Issue
Block a user