Beispiel #1
0
 void ISpaceObject.OnAdditionToSpace(Space newSpace)
 {
 }
Beispiel #2
0
 void ISpaceObject.OnRemovalFromSpace(Space oldSpace)
 {
 }
Beispiel #3
0
 /// <summary>
 /// Called before an object is removed from its space.
 /// </summary>
 /// <param name="oldSpace">Space from which the object was removed.</param>
 public virtual void OnRemovalFromSpace(Space oldSpace)
 {
 }
Beispiel #4
0
 /// <summary>
 /// Called after the object is added to a space.
 /// </summary>
 /// <param name="newSpace">Space to which the object was added.</param>
 public virtual void OnAdditionToSpace(Space newSpace)
 {
 }
Beispiel #5
0
        public override void Update(float dt)
        {
            #region Kapow-Shooter Input

            //Update kapow-shooter
            if (!vehicle.IsActive)
#if !WINDOWS
            { if (Game.GamePadInput.IsButtonDown(Buttons.RightTrigger))
#else
            { if (Game.MouseInput.LeftButton == ButtonState.Pressed)
#endif
              {
                  if (character.IsActive)   //Keep the ball out of the character's body if its being used.
                  {
                      kapow.Position = Game.Camera.Position + Game.Camera.WorldMatrix.Forward * 3;
                  }
                  else
                  {
                      kapow.Position = Game.Camera.Position + Game.Camera.WorldMatrix.Forward;
                  }
                  kapow.AngularVelocity = Vector3.Zero;
                  kapow.LinearVelocity  = Game.Camera.WorldMatrix.Forward * 30;
              } }

            #endregion

            #region Grabber Input

            //Update grabber

#if !WINDOWS
            if (Game.GamePadInput.IsButtonDown(Buttons.RightShoulder) && !grabber.IsUpdating)
#else
            if (Game.MouseInput.RightButton == ButtonState.Pressed && !grabber.IsGrabbing)
#endif
            {
                //Find the earliest ray hit
                RayCastResult raycastResult;
                if (Space.RayCast(new Ray(Game.Camera.Position, Game.Camera.WorldMatrix.Forward), 1000, rayCastFilter, out raycastResult))
                {
                    var entityCollision = raycastResult.HitObject as EntityCollidable;
                    //If there's a valid ray hit, then grab the connected object!
                    if (entityCollision != null && entityCollision.Entity.IsDynamic)
                    {
                        grabber.Setup(entityCollision.Entity, raycastResult.HitData.Location);
                        grabberGraphic.IsDrawing = true;
                        grabDistance             = raycastResult.HitData.T;
                    }
                }
            }
#if !WINDOWS
            if (Game.GamePadInput.IsButtonDown(Buttons.RightShoulder) && grabber.IsUpdating)
#else
            else if (Game.MouseInput.RightButton == ButtonState.Pressed && grabber.IsUpdating)
#endif
            {
                grabber.GoalPosition = Game.Camera.Position + Game.Camera.WorldMatrix.Forward * grabDistance;
            }
#if !WINDOWS
            if (!Game.GamePadInput.IsButtonDown(Buttons.RightShoulder) && grabber.IsUpdating)
#else
            else if (Game.MouseInput.RightButton == ButtonState.Released && grabber.IsUpdating)
#endif
            {
                grabber.Release();
                grabberGraphic.IsDrawing = false;
            }

            #endregion

            #region Control State Input

#if !WINDOWS
            if (!vehicle.IsActive && Game.WasButtonPressed(Buttons.LeftTrigger))
            {
                kapowMaker.Position = kapow.Position;
                kapowMaker.Explode();
            }
            if (Game.WasButtonPressed(Buttons.A))
            {//Toggle character perspective.
                if (!character.IsActive)
                {
                    vehicle.Deactivate();
                    character.Activate();
                }
                else
                {
                    character.Deactivate();
                }
            }
            if (Game.WasButtonPressed(Buttons.B))
            {//Toggle vehicle perspective.
                if (!vehicle.IsActive)
                {
                    character.Deactivate();
                    vehicle.Activate();
                }
                else
                {
                    vehicle.Deactivate();
                }
            }
#else
            if (!vehicle.IsActive && Game.WasKeyPressed(Keys.Space))
            {
                //Detonate the bomb
                kapowMaker.Position = kapow.Position;
                kapowMaker.Explode();
            }
            if (Game.WasKeyPressed(Keys.C))
            {
                //Toggle character perspective.
                if (!character.IsActive)
                {
                    vehicle.Deactivate();
                    character.Activate();
                }
                else
                {
                    character.Deactivate();
                }
            }


            if (Game.WasKeyPressed(Keys.V))
            {
                //Toggle vehicle perspective.
                if (!vehicle.IsActive)
                {
                    character.Deactivate();
                    vehicle.Activate(Game.Camera.Position);
                }
                else
                {
                    vehicle.Deactivate();
                }
            }
#endif

            #endregion

            base.Update(dt); //Base.update updates the space, which needs to be done before the camera is updated.

            character.Update(dt, Game.PreviousKeyboardInput, Game.KeyboardInput, Game.PreviousGamePadInput, Game.GamePadInput);
            vehicle.Update(dt, Game.KeyboardInput, Game.GamePadInput);
            //If neither are active, just use the default camera movement style.
            if (!character.IsActive && !vehicle.IsActive)
            {
                freeCameraControlScheme.Update(dt);
            }
        }
Beispiel #6
0
 /// <summary>
 /// Removes the motors from the space.  Called automatically.
 /// </summary>
 public override void OnRemovalFromSpace(Space oldSpace)
 {
     oldSpace.Remove(LinearMotor);
 }
Beispiel #7
0
 /// <summary>
 /// Adds the motors to the space.  Called automatically.
 /// </summary>
 public override void OnAdditionToSpace(Space newSpace)
 {
     newSpace.Add(LinearMotor);
 }