예제 #1
0
    // Change the specified player's type of controller. Either xbox or mouse-and-keyboard
    public void ChangeControllerType(int playerIndex, Controller.Type controllerType)
    {
        switch (controllerType)
        {
        case Controller.Type.Xbox:
            controllers[playerIndex] = new XboxController(playerIndex);
            break;

        case Controller.Type.MouseKeyboard:
            controllers[playerIndex] = new MouseKeyboard(playerIndex);
            break;

        case Controller.Type.TouchScreen:
            controllers[playerIndex] = new TouchScreenController(playerIndex);
            break;
        }
    }
예제 #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            base.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

            mainMenuBackground    = this.Content.Load <Texture2D>("MainMenu");
            settingMenuBackground = this.Content.Load <Texture2D>("SettingsPage");
            lostPage = this.Content.Load <Texture2D>("LossPage");
            wonPage  = this.Content.Load <Texture2D>("WinPage");
            Cursor   = this.Content.Load <Texture2D>("Cursor");
            inputDef = InputDefinitions.CreateInput(this);

            MouseKeyboard keyboard = new MouseKeyboard(this);

            mK = new MouseKeyboard(this);

            canv = new Canvas(this);
            ss   = new StyleSheet();
            canv.Initialize();

            if (!File.Exists("MainMenu.ss"))
            {
                GenerateStyleSheet("MainMenu");
            }
            if (!File.Exists("SettingsPage.ss"))
            {
                GenerateStyleSheet("SettingsPage");
            }
            if (!File.Exists("EndScreen.ss"))
            {
                GenerateStyleSheet("EndScreen");
            }
            LoadCanvas("MainMenu.ss", 0);
            currentPage = "Main Menu";

            PlayedGame = new ActualGame(this, "World");
        }
예제 #3
0
 protected InputDefinitions(Game game) : this()
 {
     input = new MouseKeyboard(game);
     input.Initialize();
     StartedLoad = false;
 }
예제 #4
0
        private void HandleInput()
        {
            // Don't handle input if we don't have focus
            if (!MouseKeyboard.ApplicationIsActivated())
            {
                return;
            }

            //Rotate Camera
            float rotationSpeed = 0.05f;
            float movementSpeed = 1.5f;

            if (MouseKeyboard.IsKeyToggled(Keys.Shift))
            {
                movementSpeed *= 5;
                rotationSpeed *= 5;
            }

            if (MouseKeyboard.IsKeyDown(Keys.J))
            {
                if (currentCameraMode != CameraMode.chase)
                {
                    yaw += rotationSpeed;
                }
                else
                {
                    //This is to make the panning more prominent in the Chase Camera.
                    yaw += rotationSpeed;
                }
            }
            if (MouseKeyboard.IsKeyDown(Keys.L))
            {
                if (currentCameraMode != CameraMode.chase)
                {
                    yaw += -rotationSpeed;
                }
                else
                {
                    yaw += -rotationSpeed;
                }
            }
            if (MouseKeyboard.IsKeyDown(Keys.I))
            {
                if (currentCameraMode != CameraMode.chase)
                {
                    pitch += -rotationSpeed;
                }
                else
                {
                    pitch += rotationSpeed;
                }
            }
            if (MouseKeyboard.IsKeyDown(Keys.K))
            {
                if (currentCameraMode != CameraMode.chase)
                {
                    pitch += rotationSpeed;
                }
                else
                {
                    pitch += -rotationSpeed;
                }
            }
            if (MouseKeyboard.IsKeyDown(Keys.U))
            {
                roll += -rotationSpeed;
            }
            if (MouseKeyboard.IsKeyDown(Keys.O))
            {
                roll += rotationSpeed;
            }

            //Move Camera
            if (currentCameraMode == CameraMode.free)
            {
                if (MouseKeyboard.IsKeyDown(Keys.W))
                {
                    MoveCamera(cameraRotation.Forward * movementSpeed);
                }
                if (MouseKeyboard.IsKeyDown(Keys.S))
                {
                    MoveCamera(-cameraRotation.Forward * movementSpeed);
                }
                if (MouseKeyboard.IsKeyDown(Keys.A))
                {
                    MoveCamera(-cameraRotation.Right * movementSpeed);
                }
                if (MouseKeyboard.IsKeyDown(Keys.D))
                {
                    MoveCamera(cameraRotation.Right * movementSpeed);
                }
                if (MouseKeyboard.IsKeyDown(Keys.E))
                {
                    MoveCamera(cameraRotation.Up * movementSpeed);
                }
                if (MouseKeyboard.IsKeyDown(Keys.Q))
                {
                    MoveCamera(-cameraRotation.Up * movementSpeed);
                }
            }
        }