Exemple #1
0
        /// <summary>
        /// The next process in the hover movement.
        /// </summary>
        /// <param name="animal">The animal hovering.</param>
        private void NextProcess(Animal animal)
        {
            random = new Random();

            // if the current process is hovering
            if (this.process == HoverProcess.Hovering)
            {
                // switch to zooming
                this.process = HoverProcess.Zooming;

                // set the step count to a random number between 5 and 8, inclusive
                this.stepCount = random.Next(5, 9);

                // set the animal's horizontal and vertical directions to a random direction
                animal.XDirection = random.Next(0, 2) == 0 ? HorizontalDirection.Right : HorizontalDirection.Left;
                animal.YDirection = random.Next(0, 2) == 0 ? VerticalDirection.Up : VerticalDirection.Down;
            }
            else if (this.process == HoverProcess.Zooming)
            {
                this.process = HoverProcess.Hovering;

                // set the step count to a random number between 7 and 10, inclusive
                this.stepCount = random.Next(7, 11);
            }
        }
Exemple #2
0
        /// <summary>
        /// Changes the animals hover process. To be called upon completion of current process.
        /// </summary>
        /// <param name="animal">The animal whose hover process is to change.</param>
        private void NextProcess(Animal animal)
        {
            if (this.process == HoverProcess.Hovering)
            {
                this.process = HoverProcess.Zooming;

                this.stepCount = HoverBehavior.moveRandom.Next(5, 9);

                animal.XDirection = HoverBehavior.moveRandom.Next(0, 2) == 0 ? HorizontalDirection.Left : HorizontalDirection.Right;
                animal.YDirection = HoverBehavior.moveRandom.Next(0, 2) == 0 ? VerticalDirection.Up : VerticalDirection.Down;
            }
            else
            {
                this.process = HoverProcess.Hovering;

                this.stepCount = HoverBehavior.moveRandom.Next(7, 11);
            }
        }
Exemple #3
0
        /// <summary>
        /// Moves to the next process.
        /// </summary>
        /// <param name="animal">The animal whose process switches.</param>
        private void NextProcess(Animal animal)
        {
            // if the current process is hovering
            if (this.process == HoverProcess.Hovering)
            {
                // switch to zooming
                this.process = HoverProcess.Zooming;

                // set the step count to a random number between 5 and 8, inclusive
                stepCount = random.Next(5, 9);

                // set the animal's horizontal and vertical directions to a random direction
                int randomX = random.Next(0, 2);
                int randomY = random.Next(0, 2);
                if (randomX == 0)
                {
                    animal.XDirection = Utilities.HorizontalDirection.Left;
                }
                else
                {
                    animal.XDirection = Utilities.HorizontalDirection.Right;
                }

                if (randomY == 0)
                {
                    animal.YDirection = Utilities.VerticalDirection.Up;
                }
                else
                {
                    animal.YDirection = Utilities.VerticalDirection.Down;
                }
            }
            else
            {
                // switch to hovering
                this.process = HoverProcess.Hovering;
                // set the step count to a random number between 7 and 10, inclusive
                stepCount = random.Next(7, 11);
            }
        }
Exemple #4
0
        /// <summary>
        /// Moves the animal in a hovering behavior.
        /// </summary>
        /// <param name="animal"> The animal being moved.</param>
        public void Move(Animal animal)
        {
            // define a move distance variable
            int moveDistance;

            if (this.stepCount == 0)
            {
                this.NextProcess(animal);
            }

            this.stepCount--;

            switch (this.process)
            {

                // if the current process is hovering
                case (HoverProcess.Hover):

                        // the animal moves at a normal pace, so set the move distance variable to the animal's move distance
                        moveDistance = animal.MoveDistance;

                    // the animal moves randomly on each step, so give the animal a random horizontal and vertical direction
                    animal.XDirection = random.Next(0, 2) == 0 ? HorizontalDirection.Right : HorizontalDirection.Left;
                    animal.YDirection = random.Next(0, 2) == 0 ? VerticalDirection.Up : VerticalDirection.Down; 

                        this.process = HoverProcess.Zoom;

                    break;

                case (HoverProcess.Zoom):
                    // if there are no more steps to take (step count is at 0), switch to the next process

                        moveDistance = animal.MoveDistance * 4;
                    break;
            }
            MoveHelper.MoveHorizontally(animal, animal.MoveDistance);

            MoveHelper.MoveVertically(animal, animal.MoveDistance);
        }
Exemple #5
0
        /// <summary>
        /// Changes the behavior process.
        /// </summary>
        /// <param name="animal"></param>
        private void NextProcess(Animal animal)
        {
            // if the current process is hovering
            if (this.process == HoverProcess.Hover)
            {
                // switch to zooming
                this.process = HoverProcess.Zoom;

                // set the step count to a random number between 5 and 8, inclusive
                this.stepCount = random.Next(5, 8);

                // Gets a random horizontal and vertical direction.
                animal.XDirection = random.Next(0, 2) == 0 ? HorizontalDirection.Right : HorizontalDirection.Left;
                animal.YDirection = random.Next(0, 2) == 0 ? VerticalDirection.Up : VerticalDirection.Down;
            }
            else
            {
                // Switch hover.
                this.process = HoverProcess.Hover;

                // set the step count to a random number between 7 and 10, inclusive
                this.stepCount = random.Next(7, 10);
            }
        }