Пример #1
0
        private void CreateCamera()
        {
            Vector3[] cameraPositions = {
                new Vector3(0, 10, 30),
                new Vector3(30, 0, 0),
                new Vector3(0, 30, 0.01f),
                new Vector3(0, 100, 100),
            };

            this.staticCameras = new BaseCamera[cameraPositions.Length];
            for (int i = 0; i < staticCameras.Length; i++)
            {
                staticCameras[i] = new BaseCamera(this);
                staticCameras[i].Position = cameraPositions[i];
            }

            this.thirdPersonCamera = new ThirdPersonCamera(this);

            camera = thirdPersonCamera;
        }
Пример #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            inputState.Update();

            // Allows the game to exit
            if (InputState.IsDown(Keys.Escape) ||
                GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            // TODO: Add your update logic here
            #if DEBUG && DEBUG_WINDOW
            {
                if (this.IsActive &&
                    inputState.NewMouseState.LeftButton == ButtonState.Pressed)
                {

                    float x = inputState.NewMouseState.X - 320;
                    float y = inputState.NewMouseState.Y - 240;
                    debugWindow.SetPositionText(x, y);
                }
            }
            #endif
            BaseCamera oldCamera = camera;
            if (inputState.IsDown(Keys.D1)) camera = thirdPersonCamera;
            if (inputState.IsDown(Keys.D2)) camera = staticCameras[0];
            if (inputState.IsDown(Keys.D3)) camera = staticCameras[1];
            if (inputState.IsDown(Keys.D4)) camera = staticCameras[2];
            if (inputState.IsDown(Keys.D5)) camera = staticCameras[3];

            if (oldCamera != camera) {
                Components.Remove(oldCamera);
                Components.Add(camera);
            }

            debugDrawer.Enabled = InputState.IsDown(Keys.C);

            switch (state)
            {
                case State.Pause:
                    //if (inputState.IsTrigger(Keys.Enter)) {
                    //    state = State.Play;
                    //}
                    state = State.Play;
                    break;
                case State.Play:
                    if (inputState.IsTrigger(Keys.Back))
                    {
                        Reset();
                    }
                    physicSystem.Integrate((float)gameTime.ElapsedGameTime.TotalSeconds);
                    break;
                default:
                    break;
            }

            base.Update(gameTime);
        }