Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new fish.
        /// </summary>
        public Fish(FishDescription description, FishMovement movement, FishBehavior behavior, FishingState fishing)
        {
            _description = description;
            _movement    = movement;
            _behavior    = behavior;
            _fishing     = fishing;

            _position = new Vector2(700f, _movement.Range.Y);
            _velocity = _targetVelocity = new Vector2(_movement.Speed, 0f);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns a random speed.
        /// </summary>
        private float GetRandomSpeed(FishDescription description)
        {
            float speed = _random.Next(25, 100);

            switch (description.Size)
            {
            case FishSize.Small: speed *= 1.1f; break;

            case FishSize.Medium: speed *= 1f; break;

            case FishSize.Large: speed *= 0.9f; break;

            case FishSize.VeryLarge: speed *= 0.8f; break;
            }
            return(speed);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns a random respawn wait time, in seconds.
        /// </summary>
        private float GetRandomRespawnTime(FishDescription description)
        {
            float time = _random.Next(45, 120);

            switch (description.Size)
            {
            case FishSize.Small: time *= 0.75f; break;

            case FishSize.Medium: time *= 0.9f; break;

            case FishSize.Large: time *= 1f; break;

            case FishSize.VeryLarge: time *= 1f; break;
            }
            return(time);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a semi-random fish. The fish's rarity, modifier, and speed are chosen randomly.
        /// </summary>
        /// <param name="size">The size of the fish.</param>
        /// <param name="left">The left side of fish's path.</param>
        /// <param name="right">The right edge of the fish's path.</param>
        /// <param name="depth">The depth at which the fish swims.</param>
        private Fish CreateFish(FishSize size, float left, float right, float depth)
        {
            FishDescription description = new FishDescription(
                size,
                GetRandomRarity(),
                GetRandomModifier());

            FishMovement movement = new FishMovement(
                GetRandomSpeed(description),
                300f,
                new Vector4(left, depth - 5f, right, depth + 5f));

            FishBehavior behavior = new FishBehavior(
                150f,
                (float)(Math.PI / 6),
                2f);

            Fish fish = new Fish(description, movement, behavior, _fishing);

            fish.LoadContent(_content);

            return(fish);
        }