/// <summary> /// Gets into position and then shoots at target. /// </summary> /// <param name="target"></param> internal void Shoot(GameTime gameTime, Room room) { Direction targetDir; // Find nearest target: targetedPlayer = FindNearestPlayer(room); targetDir = IsOrthogonalDiagonal(targetedPlayer, room); if (targetDir != Direction.None) { if (fireTimer > 0.0) return; // Fire Projectile Here room.AddAfterUpdate(new BoomStick(this, Position, GetXYComponents(targetDir, BoomStick.INITIAL_VELOCITY_X, BoomStick.INITIAL_VELOCITY_Y), TextureManager.GetTexture(TextureNames.BOOMSTICK_BULLET))); fireTimer = rand.GetRandomDouble(timeBetweenFire.distribution, timeBetweenFire.alpha, timeBetweenFire.beta); currentState = AIState.None; return; } MoveToNearestFirePoint(targetedPlayer, gameTime, room); }
/// <summary> /// Avoid the nearest player. /// </summary> /// <param name="target"></param> internal void Avoid(GameTime gameTime, Room room) { Direction avoidDir; Vector2 avoidVector; targetedPlayer = FindNearestPlayer(room); avoidVector = DirectionOperations.ToVector(NearestDirToTarget(targetedPlayer)); avoidDir=DirectionOperations.FromVector(Vector2.Negate(avoidVector)); if (DistanceToObject(targetedPlayer) < AVOID_DISTANCE) Move(avoidDir, gameTime, room); }
/// <summary> /// Mob will attempt to chase down target object. /// </summary> /// <param name="target"></param> internal void Chase(GameTime gameTime, Room room) { Direction targetDir; targetedPlayer = FindNearestPlayer(room); targetDir = NearestDirToTarget(targetedPlayer); Move(NearestDirToTarget(targetedPlayer), gameTime, room); }