protected override void LoadContent()
        {
            // Create scene
            scene = new Scene(core);
            scene.Camera.Position = new Vector3(22, 27, -20);
            scene.Camera.Update();
            core.ActiveScene = scene;

            // Create level entity
            DynamicEntity level = new DynamicEntity(core.ActiveScene);

            // Disable core input handling
            core.Input.ActiveDevices = Input.DeviceFlags.None;

            // Create player controller
            playerInput = new CharacterControllerInput(core.ActiveScene.Space, core.ActiveScene.Camera);
            playerInput.UseCameraSmoothing            = true;
            playerInput.CharacterController.JumpSpeed = 9;
            playerInput.CharacterController.HorizontalMotionConstraint.Speed = 8;
            playerInput.StandingCameraOffset = 1.4f;
            playerInput.Activate();

            // Initialise mouse state
            Game.IsMouseVisible = false;
            Mouse.SetPosition(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2);
            startMouseState = mouseState = Mouse.GetState();
        }
        //Testing
        public override void SimulationStart()
        {
            vxEngine.InputManager.ShowCursor = false;

            if (SandboxGameState == vxEnumSandboxGameState.EditMode)
            {
                SandboxGameState = vxEnumSandboxGameState.Running;

                // Set the Camera type to chase Camera
                character.Activate();
                Camera.CameraType = CameraType.CharacterFPS;
            }
            base.SimulationStart();
        }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        public override void LoadContent()
        {
            InitialiseLevel();

//			xEnvrio g = new xEnvrio(vxEngine, vxEngine.LoadModel("Models/tech demo/vrtc_techDemo"), Vector3.Zero);
//            g.World *= Matrix.CreateRotationZ(-MathHelper.PiOver2);
//			g.name = "tech demo";
//			g.NormalMap = vxEngine.Game.Content.Load<Texture2D>("Models/tech demo/grass_nm");


            int size    = 100;
            Box baseBox = new Box(new Vector3(0, -5, 0), size, 10, size);

            BEPUPhyicsSpace.Add(baseBox);

            ///////////////////////////////////////////////////////////////////////
            //Initialise Camera Code
            ///////////////////////////////////////////////////////////////////////
            #region Set Up Camera

            base.LoadContent();
            Camera.CameraType = CameraType.CharacterFPS;

            Camera.Position = new Vector3(0, 20, 0);

            character = new CharacterControllerInput(BEPUPhyicsSpace, Camera, vxEngine);

            //Since this is the character playground, turn on the character by default.
            character.Activate();

            //Having the character body visible would be a bit distracting.
            character.CharacterController.Body.Tag = "noDisplayObject";


            //
            //Grabbers
            //
            grabber = new MotorizedGrabSpring();
            BEPUPhyicsSpace.Add(grabber);
            rayCastFilter = RayCastFilter;

            new IndexedPrimTest(vxEngine, new Vector3(0, 0, 0));


            #endregion
        }
예제 #4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here

            // Load a sprite font
            font = Content.Load <SpriteFont>("SpriteFont1");

            long startTime = stopwatch.ElapsedMilliseconds;

            // Load a test scene
            //LoadExteriorMapScene();
            LoadBlockScene();
            //LoadModelScene();
            //LoadPhysicsScene();

            // Load and play initial sound
            LoadSound();
            PlaySound();

            // Show or hide debug buffers
            core.Renderer.ShowDebugBuffers = false;

            lastLoadTime = stopwatch.ElapsedMilliseconds - startTime;

            playerInput = new CharacterControllerInput(core.ActiveScene.Space, core.ActiveScene.Camera);

            playerInput.UseCameraSmoothing = true;

            //playerInput.CharacterController.Body.Radius = 0.5f;
            playerInput.CharacterController.JumpSpeed = 10;
            playerInput.CharacterController.HorizontalMotionConstraint.Speed = 8;
            playerInput.StandingCameraOffset = 1.4f;

            playerInput.Activate();
        }
예제 #5
0
        public override void Update(Fix64 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);
            }
        }
예제 #6
0
파일: Player.cs 프로젝트: snoozbuster/ld28
 public void Activate()
 {
     character.Activate();
 }
        protected override void LoadContent()
        {
            // Load fonts
            consoleFont = Game.Content.Load <SpriteFont>("Fonts/MenuFont");

            core.Renderer.ShowDebugBuffers = true;

            // Load fonts
            SpriteFont menuFont2 = Game.Content.Load <SpriteFont>("Fonts/MenuFont2");

            // Create gui manager
            gui = new InterfaceManager(core);
            gui.SetMargins(Margins.All, 20);

            // Create status text
            physicsTextItem = new TextItemScreenComponent(core, menuFont2, string.Empty);
            physicsTextItem.EnableOutline       = true;
            physicsTextItem.OutlineColor        = Color.Gray;
            physicsTextItem.ShadowColor         = Color.Black;
            physicsTextItem.ShadowVector        = new Vector2(2, 2);
            physicsTextItem.HorizontalAlignment = HorizontalAlignment.Left;
            physicsTextItem.VerticalAlignment   = VerticalAlignment.Top;

            // Add to gui
            gui.Components.Add(physicsTextItem);

            // Create scene
            scene = new Scene(core);
            scene.Camera.Position = new Vector3(22, 27, -20);
            scene.Camera.Update();
            core.ActiveScene = scene;

            // Set day/night mode for window textures
            core.MaterialManager.Daytime = false;

            // Create level entity
            DynamicEntity level = new DynamicEntity(core.ActiveScene);

            // Create block component
            DaggerfallBlockComponent block = new DaggerfallBlockComponent(core);

            block.LoadBlock("S0000181.RDB", MapsFile.DefaultClimateSettings, core.ActiveScene, true);

            // Increase bounding sphere radius as block component does not current calculate properly
            block.BoundingSphere = new BoundingSphere(block.BoundingSphere.Center, block.BoundingSphere.Radius * 2);

            // Add block to level
            level.Components.Add(block);

            // Attach block flats
            AddBlockFlats(level, block);

            // Attach block lights
            AddBlockLights(level, block);

            // Add player point light
            playerLight = new LightComponent(core, Vector3.Zero, 7f, Color.White, 1f);
            level.Components.Add(playerLight);

            // Disable core input handling
            core.Input.ActiveDevices = Input.DeviceFlags.None;

            // Create player controller
            playerInput = new CharacterControllerInput(core.ActiveScene.Space, core.ActiveScene.Camera);
            playerInput.UseCameraSmoothing            = true;
            playerInput.CharacterController.JumpSpeed = 9;
            playerInput.CharacterController.HorizontalMotionConstraint.Speed = 8;
            playerInput.StandingCameraOffset = 1.4f;
            playerInput.Activate();

            // Initialise mouse state
            Game.IsMouseVisible = false;
            Mouse.SetPosition(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2);
            startMouseState = mouseState = Mouse.GetState();

            // Load songs
            MediaPlayer.Stop();
            song = Game.Content.Load <Song>("Songs/DanGoodale_DF-D2");
            MediaPlayer.Play(song);

            UpdatePhysicsObjectText();
        }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        public override void LoadContent()
        {
            InitialiseLevel();


            ///////////////////////////////////////////////////////////////////////
            //Initialise Camera Code
            ///////////////////////////////////////////////////////////////////////
            #region Set Up Camera

            base.LoadContent();
            Camera.CameraType = CameraType.CharacterFPS;

            character = new CharacterControllerInput(BEPUPhyicsSpace, Camera, vxEngine);

            //Since this is the character playground, turn on the character by default.
            character.Activate();

            //Having the character body visible would be a bit distracting.
            character.CharacterController.Body.Tag = "noDisplayObject";

            SimulationStart();
            SimulationStop();

            //
            //Grabbers
            //
            grabber = new MotorizedGrabSpring();
            BEPUPhyicsSpace.Add(grabber);
            rayCastFilter = RayCastFilter;


            #endregion

            DoFog   = true;
            FogNear = 20;
            FogFar  = Camera.FarPlane / 4;

            Envrio envr = new Envrio(vxEngine, vxEngine.vxContentManager.LoadModel("Models/courtyard/td_courtyard"), Vector3.Zero);

            //Envrio envr = new Envrio(vxEngine, vxEngine.vxContentManager.LoadModel("Models/castle/mdl_castle"), new Vector3(0, 1, 0));

            //waterItems.Add(new vxWaterEntity(vxEngine, Vector3.Up, new Vector3(50, 0.25f, 50)));


            envr.SpecularIntensity = 1;
            //envr.SpecularIntensity = 100;
            //envr.SpecularPower = 5f;
            //envr.DoFog = false;

            light = new vxLightEntity(vxEngine, new Vector3(0, 2, 0), LightType.Point, Color.Orange, 10, 1);

            //This is a little convenience method used to extract vertices and indices from a model.
            //It doesn't do anything special; any approach that gets valid vertices and indices will work.

                        #if !TECHDEMO_PLTFRM_GL
            ModelDataExtractor.GetVerticesAndIndicesFromModel(envr.vxModel.ModelMain, out staticTriangleVertices, out staticTriangleIndices);

            //var staticMesh = new StaticMesh(staticTriangleVertices, staticTriangleIndices, new AffineTransform(Matrix3X3.CreateFromAxisAngle(Vector3.Up, MathHelper.Pi), new Vector3(0, -10, 0)));
            var staticMesh = new StaticMesh(staticTriangleVertices, staticTriangleIndices,
                                            new AffineTransform(new Vector3(1),
                                                                Quaternion.CreateFromRotationMatrix(Matrix.CreateRotationX(-MathHelper.PiOver2) * Matrix.CreateRotationY(0)),
                                                                new Vector3(0)));
            staticMesh.Sidedness = TriangleSidedness.Counterclockwise;

            BEPUPhyicsSpace.Add(staticMesh);
            BEPUDebugDrawer.Add(staticMesh);
                        #endif

            int size = 100;
            BEPUPhyicsSpace.Add(new Box(new Vector3(0, -5, 0), size, 10, size));

            vxTabPage Straights = new vxTabPage(vxEngine, tabControl, "Items");
            tabControl.AddItem(Straights);

            vxScrollPanel ScrollPanel_GeneralItemsPage = new vxScrollPanel(new Vector2(0, 0),
                                                                           vxEngine.GraphicsDevice.Viewport.Width - 150, vxEngine.GraphicsDevice.Viewport.Height - 75);

            //Cubes
            ScrollPanel_GeneralItemsPage.AddItem(new vxScrollPanelSpliter(vxEngine, "Items"));
            ScrollPanel_GeneralItemsPage.AddItem(RegisterNewSandboxItem(WoodenCrate.EntityDescription));

            //Add the scrollpanel to the slider tab page.
            Straights.AddItem(ScrollPanel_GeneralItemsPage);

            //IndexedCubeTest cube = new IndexedCubeTest(vxEngine, new Vector3(4, 4, 0));


            Teapot t = new Teapot((GameEngine)vxEngine, new Vector3(4, 4, 0));
            t.SetMesh(Matrix.CreateTranslation(new Vector3(4, 2, 0)), true, true);

            ConcreteCube cc = new ConcreteCube((GameEngine)vxEngine, new Vector3(0, 5, 0));
            cc.SetMesh(Matrix.CreateTranslation(new Vector3(0, 2, 0)), true, true);


            ModelObjs mo = new ModelObjs((GameEngine)vxEngine, new Vector3(-4, 4, 0));
            mo.SetMesh(Matrix.CreateTranslation(new Vector3(0, 2, 8)), true, true);

            vxEngine.InputManager.ShowCursor = true;
        }