/// <summary> /// Helps switch the process. /// </summary> /// <param name="animal"></param> private void NextProcess(Animal animal) { // if the current process is climbing. if (this.process == ClimbProcess.Climbing) { // Switch to gliding. this.process = ClimbProcess.Gliding; } // if the current process is falling, switch to scurrying else if (this.process == ClimbProcess.Gliding) { this.process = ClimbProcess.Scurrying; } // if the current process is scurrying else if (this.process == ClimbProcess.Scurrying) { int lowerMax = Convert.ToInt32(Math.Floor(Convert.ToDouble(animal.YPositionMax) * 0.15)); int higherMax = Convert.ToInt32(Math.Floor(Convert.ToDouble(animal.YPositionMax) * 0.85)); // set max height to a random value between the lowest max and the highest max // Set random max height this.maxHeight = random.Next(lowerMax, higherMax); // switch to climbing this.process = ClimbProcess.Climbing; } }
/// <summary> /// Toggles between the two processes of the hovering behavior. /// </summary> /// <param name="animal">The animal to move.</param> private void NextProcess(Animal animal) { switch (this.process) { case ClimbProcess.Climbing: this.process = ClimbProcess.Falling; break; case ClimbProcess.Falling: this.process = ClimbProcess.Scurrying; break; case ClimbProcess.Scurrying: // Set the maximum height to a random value between 15 and 85 percent of the height of the animal's maximum y position int lowerMax = Convert.ToInt32(Math.Floor(Convert.ToDouble(animal.YPositionMax) * 0.15)); int higherMax = Convert.ToInt32(Math.Floor(Convert.ToDouble(animal.YPositionMax) * 0.85)); this.maxHeight = ClimbBehavior.random.Next(lowerMax, higherMax + 1); this.process = ClimbProcess.Climbing; break; } }