Ejemplo n.º 1
0
        /// <summary>
        /// This function is called to update this component of our game
        /// to the current game time.
        /// </summary>
        /// <param name="gameTime"></param>
        public void Update(GameTime gameTime)
        {
            azimuth += turnRate * rotationSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
               Matrix transform = Matrix.CreateRotationY(azimuth);
               Vector3 direction = Vector3.TransformNormal(new Vector3(0, 0, 1), transform);

               delta += (float)gameTime.ElapsedGameTime.TotalSeconds;
               switch (pollenStates)
               {
               case PollenatingStates.Up:
                   position += new Vector3(0, 1, 0) * (YSpeed+20) * (float)gameTime.ElapsedGameTime.TotalSeconds;
                   if (delta > 1.0f)
                   {
                       pollenStates = PollenatingStates.Down;
                       delta = 0;
                       return;
                   }
                   break;
               case PollenatingStates.Down:
                   position -= new Vector3(0, 1, 0) * YSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                   if (delta > 1.0f)
                   {
                       pollenStates = PollenatingStates.FlyAway;
                       delta = 0;
                       return;
                   }
                   break;
               case PollenatingStates.FlyAway:
                   position += 1 * direction * movementSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                   if (delta > 1.0f)
                   {
                       delta = 0;
                       pollenStates = PollenatingStates.Nothing;
                       isPolenating = false;
                       return;
                   }
                   break;
               }
               if(!isPolenating)
               {
             if (increaseAltitude)
            {
                 //states = WingStates.Up;
                position += new Vector3(0, 1, 0) * YSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
                if (position.Y > 2000)
                    position.Y = 2000;

              }
             else
             {
                  position -= new Vector3(0, 1, 0) * gravity * (float)gameTime.ElapsedGameTime.TotalSeconds;
                  if (position.Y < 0)
                   {
                      position.Y = 0;
                      // states = WingStates.NotMoving;
                       //wingAngle = 0;
                  }
             }

            position += move * direction * movementSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;
               }
               float wingMoveTime = .50f;
               switch (states)
               {

               case WingStates.Up:
                   {
                       wingAngle += .3f * (float)gameTime.ElapsedGameTime.TotalSeconds / wingMoveTime;
                       if (wingAngle > .3f)
                           states = WingStates.Down;

                       break;
                   }
               case WingStates.Down:
                  {
                      wingAngle -= .3f * (float)gameTime.ElapsedGameTime.TotalSeconds / wingMoveTime;
                      if (wingAngle < 0)
                          states = WingStates.Up;
                      break;
                  }
               }
        }
Ejemplo n.º 2
0
 public void SetPollenatingStateToPollenate()
 {
     pollenStates = PollenatingStates.Up;
 }