Traveller/scripts/behaviorTree/ai/AiWalkNode.cs

33 lines
858 B
C#
Raw Normal View History

2024-04-28 13:55:19 +00:00
using ColdMint.scripts.character;
namespace ColdMint.scripts.behaviorTree.ai;
/// <summary>
/// <para>一个节点用于实现角色的移动</para>
/// <para>A node is used to implement the movement of the character</para>
/// </summary>
public class AiWalkNode : BehaviorTreeNodeTemplate
2024-04-28 13:55:19 +00:00
{
public AiCharacter? Character { get; set; }
2024-04-28 13:55:19 +00:00
public override int Execute(bool isPhysicsProcess, double delta)
{
if (Character == null)
{
return Config.BehaviorTreeResult.Failure;
}
if (Character.FacingLeft)
{
//If the character is facing left, move left
//如果角色面向左边,那么向左移动
Character.MoveLeft();
}
else
{
Character.MoveRight();
}
return Config.BehaviorTreeResult.Success;
}
}