Example #1
0
        /// <summary>
        /// The hopper moves.
        /// </summary>
        /// <param name="animal">The animal to be moved.</param>
        public void Move(Animal animal)
        {
            MoveHelper.MoveHorizontally(animal, animal.MoveDistance);

            if (this.process == HopProcess.Rising)
            {
                animal.YDirection = VerticalDirection.Up;
                MoveHelper.MoveVertically(animal, animal.MoveDistance);

                if (animal.YPosition <= jumpHeight)
                {
                    this.NextProcess(animal);
                }
            }
            else
            {
                animal.YDirection = VerticalDirection.Down;
                MoveHelper.MoveVertically(animal, animal.MoveDistance);

                if (animal.YPosition >= 400)
                {
                    this.NextProcess(animal);
                }
            }
        }
Example #2
0
        /// <summary>
        /// The animal hovers.
        /// </summary>
        /// <param name="animal">The animal which is to hover.</param>
        public void Move(Animal animal)
        {
            if (this.stepCount <= 0)
            {
                this.NextProcess(animal);
            }

            this.stepCount--;

            int moveDistance;

            if (this.process == HoverProcess.Hovering)
            {
                moveDistance = animal.MoveDistance;

                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
            {
                moveDistance = animal.MoveDistance * 4;
            }

            MoveHelper.MoveHorizontally(animal, moveDistance);
            MoveHelper.MoveVertically(animal, moveDistance);
        }
Example #3
0
        /// <summary>
        /// Moves the animal.
        /// </summary>
        /// <param name="animal"> The animal being moved.</param>
        public void Move(Animal animal)
        {
            // Moves the animal horizontally.
            MoveHelper.MoveHorizontally(animal, animal.MoveDistance);

            // Moves the animal vertically.
            MoveHelper.MoveVertically(animal, animal.MoveDistance / 2);
        }
Example #4
0
        /// <summary>
        /// The hoverer moves.
        /// </summary>
        /// <param name="animal">The animal moving.</param>
        public void Move(Animal animal)
        {
            // if there are no more steps to take (step count is at 0), switch to the next process
            if (stepCount == 0)
            {
                this.NextProcess(animal);
            }

            // decrement the step count
            stepCount--;

            // define a move distance variable
            int moveDistance;

            // if the current process is hovering
            if (this.process == HoverProcess.Hovering)
            {
                // 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
                // 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
            {
                // the animal moves at a quadruple pace, so set the move distance variable to 4 times
                // the animal's move distance
                moveDistance = animal.MoveDistance * 4;
            }

            // move horizontally and vertically using the move distance variable
            MoveHelper.MoveHorizontally(animal, moveDistance);
            MoveHelper.MoveVertically(animal, moveDistance);
        }
Example #5
0
        public void Move(Animal animal)
        {
            MoveHelper.MoveHorizontally(animal, animal.MoveDistance);

            // Simulates wing flapping. Every time the bird is drawn,
            // the bird goes up or down 10 units.
            if (evenOrOdd % 2 == 0)
            {
                MoveHelper.MoveVertically(animal, 10);
                evenOrOdd++;
            }
            else if (evenOrOdd % 2 != 0)
            {
                MoveHelper.MoveVertically(animal, -10);
                evenOrOdd++;
            }
        }
Example #6
0
        /// <summary>
        /// Makes an animal fly.
        /// </summary>
        /// <param name="animal">The animal to move.</param>
        public void Move(Animal animal)
        {
            MoveHelper.MoveHorizontally(animal, animal.MoveDistance);

            // If the animal is currently moving down.
            if (animal.YDirection == VerticalDirection.Down)
            {
                // Move down by 10 and switch directions.
                animal.YPosition += 10;
                animal.YDirection = VerticalDirection.Up;
            }
            else
            {
                // Move up by 10 and switch directions.
                animal.YPosition -= 10;
                animal.YDirection = VerticalDirection.Down;
            }
        }
Example #7
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);
        }
Example #8
0
        /// <summary>
        /// Moves an animal.
        /// </summary>
        /// <param name="animal"> The animal being moved.</param>
        public void Move(Animal animal)
        {
            // Moves the animal horizontally.
            MoveHelper.MoveHorizontally(animal, animal.MoveDistance);

            //If the left / right directiopn is right then...
            if (animal.XDirection == HorizontalDirection.Right)
            {
                //If the distance being moved to the right is greater than the limits then...
                if (animal.XPosition + animal.MoveDistance > animal.XPositionMax)
                {
                    //Sets the left / right position to the maximum left / right position.
                    animal.XPosition = animal.XPositionMax;

                    //Sets the direction to left.
                    animal.XDirection = HorizontalDirection.Left;

                    if (animal.YDirection == VerticalDirection.Up)
                    {
                        animal.YPosition -= 10;

                        animal.YDirection = VerticalDirection.Down;
                    }
                    else
                    {
                        animal.YPosition += 10;

                        animal.YDirection = VerticalDirection.Up;
                    }
                }
                else
                {
                    // Sets the left/right direction plus the move distance.
                    animal.XPosition += animal.MoveDistance;

                    if (animal.YDirection == VerticalDirection.Up)
                    {
                        animal.YPosition -= 10;

                        animal.YDirection = VerticalDirection.Down;
                    }
                    else
                    {
                        animal.YPosition += 10;

                        animal.YDirection = VerticalDirection.Up;
                    }
                }
            }
            else
            {
                //If you try and move the left/ right position past 0 then...
                if (animal.XPosition - animal.MoveDistance < 0)
                {
                    animal.XPosition  = 0;
                    animal.XDirection = HorizontalDirection.Right;
                    if (animal.YDirection == VerticalDirection.Up)
                    {
                        animal.YPosition -= 10;

                        animal.YDirection = VerticalDirection.Down;
                    }
                    else
                    {
                        animal.YPosition += 10;

                        animal.YDirection = VerticalDirection.Up;
                    }
                }
                // Makes the animal go further right.
                else
                {
                    animal.XPosition -= animal.MoveDistance;
                }

                if (animal.YDirection == VerticalDirection.Up)
                {
                    animal.YPosition -= 10;

                    animal.YDirection = VerticalDirection.Down;
                }
                else
                {
                    animal.YPosition += 10;

                    animal.YDirection = VerticalDirection.Up;
                }
            }
        }
Example #9
0
        /// <summary>
        /// Moves the animal in a climb behavior
        /// </summary>
        /// <param name="animal"> The animal being moved.</param>
        public void Move(Animal animal)
        {
            // Doesn't climb left edge.
            switch (this.process)
            {
            case ClimbProcess.Scurrying:

                // Move horizontally
                MoveHelper.MoveHorizontally(animal, animal.MoveDistance);

                // if animal hits a vertical edge.
                if ((animal.MoveDistance + animal.XPosition) > animal.XPositionMax)
                {
                    animal.XPosition = animal.XPositionMax;
                    this.NextProcess(animal);
                }
                // if the animal will hit a vertical wall (either right or left), set the animal to the edge and switch to the next process
                if ((animal.XPosition - animal.MoveDistance) < 0)
                {
                    animal.XPosition = 0;
                    this.NextProcess(animal);
                }
                break;

            case ClimbProcess.Climbing:

                // make sure its moving up (set vertical direction)
                animal.YDirection = Utilities.VerticalDirection.Up;

                MoveHelper.MoveVertically(animal, animal.MoveDistance);

                if ((animal.YPosition - animal.MoveDistance) < this.maxHeight)
                {
                    // Change animals direction.
                    animal.YDirection = Utilities.VerticalDirection.Down;

                    // If the animal was going right, make it go left.
                    if (animal.XDirection == Utilities.HorizontalDirection.Left)
                    {
                        animal.XDirection = Utilities.HorizontalDirection.Right;
                    }
                    // If the animal was going left, make it go right.
                    else
                    {
                        animal.XDirection = Utilities.HorizontalDirection.Left;
                    }
                    // switch to gliding. (switch state)
                    this.NextProcess(animal);
                }

                break;

            case ClimbProcess.Gliding:

                // move diagnolly at a steep angle.
                MoveHelper.MoveHorizontally(animal, animal.MoveDistance);

                // Move vertically at twice the distance.
                MoveHelper.MoveVertically(animal, animal.MoveDistance * 2);

                // if at bottom of cage
                if ((animal.YPosition + animal.MoveDistance) > animal.YPositionMax)
                {
                    // switch to scurry.
                    this.NextProcess(animal);
                }

                break;
            }
        }
Example #10
0
 /// <summary>
 /// The animal moves by swimming.
 /// </summary>
 /// <param name="animal">The intended animal.</param>
 public void Move(Animal animal)
 {
     MoveHelper.MoveHorizontally(animal, animal.MoveDistance);
     MoveHelper.MoveVertically(animal, animal.MoveDistance / 2);
 }
Example #11
0
        /// <summary>
        /// Moves the animal.
        /// </summary>
        /// <param name="animal">The animal to move.</param>
        public void Move(Animal animal)
        {
            switch (this.process)
            {
            case ClimbProcess.Climbing:
                // If the animal is climbing, ensure the vertical direction is set to up
                animal.YDirection = VerticalDirection.Up;

                // Move the animal vertically
                MoveHelper.MoveVertically(animal, animal.MoveDistance);

                // If the animal has hit or will hit the top of the cage
                if (animal.YPosition - animal.MoveDistance <= this.maxHeight)
                {
                    // Change the animal's vertical direction to down
                    animal.YDirection = VerticalDirection.Down;

                    // Switch the way the animal is facing
                    animal.XDirection = animal.XDirection == HorizontalDirection.Left ? HorizontalDirection.Right : HorizontalDirection.Left;

                    // And switch the animal to the next process
                    this.NextProcess(animal);
                }

                break;

            case ClimbProcess.Falling:
                // Otherwise if the animal is floating, have it move diagonally
                MoveHelper.MoveHorizontally(animal, animal.MoveDistance);
                MoveHelper.MoveVertically(animal, animal.MoveDistance * 2);

                // If the animal has hit or will hit the bottom of the cage
                if (animal.YPosition + animal.MoveDistance >= animal.YPositionMax)
                {
                    // Switch to the next process
                    this.NextProcess(animal);
                }

                break;

            case ClimbProcess.Scurrying:
                // Move the animal horizontally
                MoveHelper.MoveHorizontally(animal, animal.MoveDistance);

                // If the animal has hit or will hit a vertical wall
                if (animal.XPosition - animal.MoveDistance <= 0 || animal.XPosition + animal.MoveDistance >= animal.XPositionMax)
                {
                    // Move the animal to the appropriate edge of the cage
                    if (animal.XPosition + animal.MoveDistance >= animal.XPositionMax)
                    {
                        animal.XPosition = animal.XPositionMax;
                    }
                    else
                    {
                        animal.XPosition = 0;
                    }

                    // Switch to the next process
                    this.NextProcess(animal);
                }

                break;
            }
        }
Example #12
0
 /// <summary>
 /// Moves an animal.
 /// </summary>
 /// <param name="animal"> The animal being moved.</param>
 public void Move(Animal animal)
 {
     // Moves the animal left or right by the animal's move distance.
     MoveHelper.MoveHorizontally(animal, animal.MoveDistance);
 }
Example #13
0
 /// <summary>
 /// The climber moves.
 /// </summary>
 /// <param name="animal">The animal moving.</param>
 public void Move(Animal animal)
 {
     // if the current process is climbing
     if (process == ClimbProcess.Climbing)
     {
         // ensure animal is moving up
         if (animal.YDirection == VerticalDirection.Up)
         {
             animal.YDirection = VerticalDirection.Down;
         }
         // move vertically
         MoveHelper.MoveVertically(animal, animal.MoveDistance);
         // if the animal's next step will take it above the max height
         if (animal.YPosition - animal.MoveDistance <= maxHeight)
         {
             // make animal move down
             animal.YDirection = VerticalDirection.Up;
             // switch its horizontal direction (if moving right, make it move left and vice versa)
             if (animal.XDirection == HorizontalDirection.Right)
             {
                 animal.XDirection = HorizontalDirection.Left;
             }
             else
             {
                 animal.XDirection = HorizontalDirection.Right;
             }
             // switch to next process
             this.NextProcess(animal);
         }
     }
     // if current process is falling
     if (process == ClimbProcess.Falling)
     {
         // move horizontally
         MoveHelper.MoveHorizontally(animal, animal.MoveDistance);
         // move vertically at twice the distance
         MoveHelper.MoveVertically(animal, animal.MoveDistance * 2);
         // if the animal's next move will take it past the bottom, switch to the next process
         if (animal.YPosition + (animal.MoveDistance * 2) >= animal.YPositionMax)
         {
             this.NextProcess(animal);
         }
     }
     // if the current process is scurrying
     if (process == ClimbProcess.Scurrying)
     {
         // move horizontally
         MoveHelper.MoveHorizontally(animal, animal.MoveDistance);
         // if the animal will hit a vertical wall (either right or left), set the animal to the edge and switch to the next process
         if (animal.XPosition + animal.MoveDistance >= animal.XPositionMax)
         {
             animal.XPosition = animal.XPositionMax;
             this.NextProcess(animal);
         }
         if (animal.XPosition - animal.MoveDistance <= 0)
         {
             animal.XPosition = 0;
             this.NextProcess(animal);
         }
     }
 }