public AiStateMachine(Enemy owner, AIState constState, AIState startState)
        {
            this.owner = owner;
            this.constState = constState;
            this.dynamicState = startState;

            constState.Enter(owner);
            dynamicState.Enter(owner);
        }
 public void UpdateState(Enemy owner, float deltaTime)
 {
     switch (currDir)
     {
         case Direction.NEGATIVE_X:
             UpdateLeft(deltaTime, owner);
             break;
         case Direction.POSITIVE_X:
             UpdateRight(deltaTime, owner);
             break;
     }
 }
 public void UpdateState(Enemy owner, float deltaTime)
 {
     actionCooldownTimer += deltaTime;
     if (actionCooldownTimer >= actionCooldown)
     {
         if (Vector3.Distance(Game.player.Cam.Position, owner.Position) <= playerDistToPerformAction)
         {
             actionCooldownTimer = 0.0f;
              owner.PerformBaseAction();
         }
     }
 }
 public void UpdateState(Enemy owner, float deltaTime)
 {
     switch (currDir)
     {
         case Direction.NEGATIVE_Z:
             UpdateNegative(deltaTime, owner);
             break;
         case Direction.POSITIVE_Z:
             UpdatePositive(deltaTime, owner);
             break;
     }
 }
        public void Enter(Enemy owner)
        {
            owner.Velocity = endPos - startPos;
            Vector3 vel = owner.Velocity;
            vel.Normalize();
            owner.Velocity = vel;
            originalVelocity = owner.Velocity;
            owner.Position = startPos;

            if (originalVelocity.X < 0)
            {
                currDir = Direction.NEGATIVE_X;
                owner.Rotation = new Vector3(0, NegativeHeading, 0);
            }
            else
            {
                currDir = Direction.POSITIVE_X;
                owner.Rotation = new Vector3(0, PositiveHeading, 0);
            }
        }
 void UpdateLeft(float deltaTime, Enemy owner)
 {
     float distance = Vector3.Distance(owner.Position, startPos);
     if (distance <= 400)
     {
         if (distance <= 200)
         {
             if (owner.Rotation.Y < 270)
             {
                 owner.Velocity = new Vector3(owner.Velocity.X + (acceleration * deltaTime), owner.Velocity.Y, owner.Velocity.Z);
                 owner.Rotation = new Vector3(owner.Rotation.X, owner.Rotation.Y + (90 * deltaTime), 0);
             }
             else
             {
                 currDir = Direction.POSITIVE_X;
                 owner.Rotation = new Vector3(0, PositiveHeading, 0);
                 owner.Velocity = endPos - startPos;
                 Vector3 vel = owner.Velocity;
                 vel.Normalize();
                 owner.Velocity = vel;
                 originalVelocity = owner.Velocity;
             }
         }
         else
             owner.Velocity = new Vector3(originalVelocity.X * (distance / 400), originalVelocity.Y, originalVelocity.Z);
     }
     else if (owner.Velocity.X > -maxVelocity)
     {
         owner.Velocity = new Vector3(owner.Velocity.X - (acceleration * deltaTime), owner.Velocity.Y, owner.Velocity.Z);
         originalVelocity = owner.Velocity;
     }
 }
 public void Exit(Enemy owner)
 {
     owner.Velocity = Vector3.Zero;
 }
 void UpdateRight(float deltaTime, Enemy owner)
 {
     float distance = Vector3.Distance(owner.Position, endPos);
     if (distance <= 400)
     {
         if (distance <= 200)
         {
             if (owner.Rotation.Y > 90)
             {
                 owner.Velocity = new Vector3(owner.Velocity.X - (acceleration * deltaTime), 0, 0);
                 owner.Rotation = new Vector3(owner.Rotation.X, owner.Rotation.Y - (90 * deltaTime), 0);
             }
             else
             {
                 currDir = Direction.NEGATIVE_X;
                 owner.Rotation = new Vector3(0, 90, 0);
                 owner.Velocity = startPos - endPos;
                 Vector3 vel = owner.Velocity;
                 vel.Normalize();
                 owner.Velocity = vel;
                 originalVelocity = owner.Velocity;
             }
         }
         else
             owner.Velocity = new Vector3(originalVelocity.X * (distance / 400), originalVelocity.Z, originalVelocity.Y);
     }
      else if (owner.Velocity.X < maxVelocity)
     {
         owner.Velocity = new Vector3(owner.Velocity.X + (acceleration * deltaTime), owner.Velocity.Y, owner.Velocity.Z);
         originalVelocity = owner.Velocity;
     }
 }
 public void Exit(Enemy owner)
 {
 }
 public void Enter(Enemy owner)
 {
     actionCooldownTimer = 0.0f;
 }
        void UpdateNegative(float deltaTime, Enemy owner)
        {
            float distance = Vector3.Distance(owner.Position, currentTarget);
            if (distance <= 400)
            {
                if (distance <= 200)
                {
                    if (owner.Rotation.Y < positiveHeading)
                    {
                        owner.Velocity = new Vector3(owner.Velocity.X, owner.Velocity.Y, owner.Velocity.Z + (acceleration * deltaTime));
                        owner.Rotation = new Vector3(owner.Rotation.X, owner.Rotation.Y + (90 * deltaTime), 0);
                    }
                    else
                    {
                        currDir = Direction.POSITIVE_Z;
                        ChangeTarget();
                        owner.Velocity = currentTarget - otherTarget;
                        Vector3 vel = owner.Velocity;
                        vel.Normalize();
                        owner.Velocity = vel;
                        originalVelocity = owner.Velocity;
                        owner.Rotation = new Vector3(0, positiveHeading, 0);

                    }
                }
                else
                    owner.Velocity = new Vector3(originalVelocity.X, originalVelocity.Y, originalVelocity.Z * (distance / 400));
            }
            else if (owner.Velocity.Z > -maxVelocity)
            {
                owner.Velocity = new Vector3(owner.Velocity.X, owner.Velocity.Y, owner.Velocity.Z - (acceleration * deltaTime));
                originalVelocity = owner.Velocity;
            }
        }