From ced3d03bdb3ce866d832e03fb212865140905a9a Mon Sep 17 00:00:00 2001 From: Thomas Leyh Date: Sun, 24 Jul 2016 08:14:18 +0200 Subject: Add project files. --- V3/AI/Internal/MoveAction.cs | 53 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 V3/AI/Internal/MoveAction.cs (limited to 'V3/AI/Internal/MoveAction.cs') diff --git a/V3/AI/Internal/MoveAction.cs b/V3/AI/Internal/MoveAction.cs new file mode 100644 index 0000000..fcbba54 --- /dev/null +++ b/V3/AI/Internal/MoveAction.cs @@ -0,0 +1,53 @@ +using Microsoft.Xna.Framework; +using V3.Objects; + +namespace V3.AI.Internal +{ + /// + /// Moves a creature to a destination point. + /// + // ReSharper disable once ClassNeverInstantiated.Global + public class MoveAction : AbstractAction + { + private ICreature mCreature; + private Vector2 mDestination; + + /// + /// Creates a new MoveAction to move the given creature to the given + /// destination. + /// + /// the creature to mvoe + /// the destination of the creature + public MoveAction(ICreature creature, Vector2 destination) + { + mCreature = creature; + mDestination = destination; + } + + /// + /// Start the execution of the action. + /// + public override void Start() + { + mCreature.Move(mDestination); + base.Start(); + } + + protected override ActionState GetNextState() + { + switch (mCreature.MovementState) + { + case MovementState.Idle: + return ActionState.Done; + case MovementState.Attacking: + case MovementState.Dying: + return ActionState.Failed; + case MovementState.Moving: + return ActionState.Executing; + default: + return ActionState.Failed; + } + } + + } +} -- cgit v1.2.1