Ejemplo n.º 1
0
    public override void _Input(InputEvent @event)
    {
        if (@event.IsActionPressed("ui_cancel"))
        {
            OpenMicrobeStageMenuPressed();

            if (helpScreen.Visible)
            {
                helpScreen.Hide();
            }
        }
    }
Ejemplo n.º 2
0
    public override void _Input(InputEvent @event)
    {
        if (@event.IsActionPressed("ui_cancel"))
        {
            MenuButtonPressed();

            if (helpScreen.Visible)
            {
                helpScreen.Hide();
            }
        }
    }
Ejemplo n.º 3
0
    private void SetActiveMenu(string menu)
    {
        helpScreen.Hide();
        primaryMenu.Hide();
        loadMenu.Hide();
        optionsMenu.Hide();
        saveMenu.Hide();

        switch (menu)
        {
        case "primary":
            primaryMenu.Show();
            break;

        case "help":
            helpScreen.Show();
            break;

        case "load":
            loadMenu.Show();
            break;

        case "options":
            optionsMenu.OpenFromInGame(GameProperties);
            break;

        case "save":
            saveMenu.Show();
            break;

        default:
            throw new ArgumentException("unknown menu", nameof(menu));
        }
    }
Ejemplo n.º 4
0
 protected override void LoadContent()
 {
     spriteBatch = new SpriteBatch(GraphicsDevice);
     Services.AddService(typeof(SpriteBatch), spriteBatch);
     normalFont = Content.Load<SpriteFont>("normal");
     background = Content.Load<Texture2D>("gryphon");
     startScreen = new StartScreen(this, normalFont, background);
     Components.Add(startScreen);
     background = Content.Load<Texture2D>("fire-dragon");
     helpScreen = new HelpScreen(this, background);
     Components.Add(helpScreen);
     startScreen.Show();
     helpScreen.Hide();
     activeScreen = startScreen;
 }
Ejemplo n.º 5
0
    void Update()
    {
        float dt = Time.deltaTime;

        if ((Input.GetKey(KeyCode.RightControl) || Input.GetKey(KeyCode.LeftControl)) && Input.GetKeyDown(KeyCode.Q))
        {
            doQuit();
        }

        if (Input.GetKeyDown(KeyCode.H) || Input.GetKeyDown(KeyCode.F1))
        {
            helpScreen.ToggleVisibility();
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            helpScreen.Hide();
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            ResetMousePos();
            // Space bar toggles mode (walk/draw)
            if (mouseMode == MouseMode.Look)
            {
                mouseMode = MouseMode.Stick;
                sb.makeVisible();
            }
            else if (mouseMode == MouseMode.Stick)
            {
                sb.makeInvisible();
                mouseMode = MouseMode.Look;
            }
        }

        if (Input.GetKeyDown(KeyCode.LeftAlt) || Input.GetKeyDown(KeyCode.RightAlt) || Input.GetMouseButtonDown(1))
        {
            // Alt or RMB means "temporarily activate rotate mode"
            // Save current mode, make sure the stick/laser is hidden, and link
            // mouse position to object orientation.
            ResetMousePos();
            savedMode = mouseMode;
            if (mouseMode == MouseMode.Stick)
            {
                sb.makeInvisible();
            }
            mouseMode    = MouseMode.Rotate;
            surfaceDelta = surface.transform.position - camera.transform.position;
        }
        if (Input.GetKeyUp(KeyCode.LeftAlt) || Input.GetKeyUp(KeyCode.RightAlt) || Input.GetMouseButtonUp(1))
        {
            // Alt or RMB release means restore previous mode
            ResetMousePos();
            mouseMode = savedMode;
            if (mouseMode == MouseMode.Stick)
            {
                sb.makeVisible();
            }
        }

        if (Input.GetKeyDown(KeyCode.Z))
        {
            // Clear all drawing on the PaintableTexture
            pt.Clear();
        }

        if (Input.GetKeyDown(KeyCode.P))
        {
            // Klein-Poincare toggle
            h2c.ToggleModel();
            h2c.ExportMode();
        }

        if (Input.GetKeyDown(KeyCode.O))
        {
            // Reset view position
            h2c.ResetPreTransformation();
            h2c.ExportPreTransformation();
        }
        if (Input.GetKey(KeyCode.I))
        {
            h2c.ComposePreTransformation(HypUtil.BoostY(-h2speed * dt));
            h2c.ExportPreTransformation();
        }

        if (Input.GetKey(KeyCode.K))
        {
            h2c.ComposePreTransformation(HypUtil.BoostY(h2speed * dt));
            h2c.ExportPreTransformation();
        }
        if (Input.GetKey(KeyCode.J))
        {
            h2c.ComposePreTransformation(HypUtil.BoostX(h2speed * dt));
            h2c.ExportPreTransformation();
        }
        if (Input.GetKey(KeyCode.L))
        {
            h2c.ComposePreTransformation(HypUtil.BoostX(-h2speed * dt));
            h2c.ExportPreTransformation();
        }


        // Walk & strafe according to keyboard
        float horiz = Input.GetAxis("Horizontal") * speed;
        float depth = Input.GetAxis("Vertical") * speed;

        camera.transform.Translate(horiz * dt, 0f, depth * dt);
        if (mouseMode == MouseMode.Rotate)
        {
            surface.transform.position = camera.transform.position + surfaceDelta;
        }

        if (mouseMode == MouseMode.Look)
        {
            Vector2 mp = AbsMousePos();
            camera.transform.localRotation = cameraInitQ * Quaternion.Euler(0, turnRange * mp.x, 0);
        }
        if (mouseMode == MouseMode.Stick)
        {
            if (Input.GetKey(KeyCode.LeftShift) || Input.GetMouseButton(0))
            {
                sb.makeActive();
            }
            else
            {
                sb.makeInactive();
            }
            Vector2 mp = AbsMousePos();
            stickHolder.transform.localRotation = stickInitQ * Quaternion.Euler(-0.5f * stickRange * mp.y, 0, -0.5f * stickRange * mp.x);
        }
        if (mouseMode == MouseMode.Rotate)
        {
            Vector2 mp = AbsMousePos();
            // TODO: Make this a more intuitive trackball-style object rotation interface.
            surface.transform.localRotation = Quaternion.AngleAxis(turnRange * mp.y, camera.transform.right) * Quaternion.AngleAxis(-turnRange * mp.x, camera.transform.up) * surfaceInitQ;
        }
    }
        //ќбработка нажатий на клавиши
        void KeyboardHandle()
        {
            KeyboardState kbState = Keyboard.GetState();

            interval++;
            if (interval >= 5)
            {
                interval = 0;
                if (menuScreen.Enabled)
                {
                    if (kbState.IsKeyDown(Keys.Up))
                    {
                        currentMenuItem--;
                        if (currentMenuItem < 1)
                        {
                            currentMenuItem = 3;
                        }
                        menuScreen.GetKey(currentMenuItem);
                    }
                    if (kbState.IsKeyDown(Keys.Down))
                    {
                        currentMenuItem++;
                        if (currentMenuItem > 3)
                        {
                            currentMenuItem = 1;
                        }
                        menuScreen.GetKey(currentMenuItem);
                    }
                    if (kbState.IsKeyDown(Keys.Enter))
                    {
                        switch (currentMenuItem)
                        {
                        case 1:
                            menuScreen.Hide();
                            GameState.StartNewGame();
                            gameScreen.Show();
                            break;

                        case 2:
                            menuScreen.Hide();
                            helpScreen.Show();
                            break;

                        case 3:
                            Exit();
                            break;
                        }
                    }
                }
                if (gamePauseScreen.Enabled)
                {
                    if (kbState.IsKeyDown(Keys.Up))
                    {
                        currentMenuItem--;
                        if (currentMenuItem < 1)
                        {
                            currentMenuItem = 2;
                        }
                        gamePauseScreen.GetKey(currentMenuItem);
                    }
                    if (kbState.IsKeyDown(Keys.Down))
                    {
                        currentMenuItem++;
                        if (currentMenuItem > 2)
                        {
                            currentMenuItem = 1;
                        }
                        gamePauseScreen.GetKey(currentMenuItem);
                    }
                    if (kbState.IsKeyDown(Keys.Enter))
                    {
                        switch (currentMenuItem)
                        {
                        case 1:
                            GameState.IsPaused = false;
                            gamePauseScreen.Hide();
                            break;

                        case 2:
                            GameState.IsPaused = false;
                            gamePauseScreen.Hide();
                            gameScreen.Hide();
                            menuScreen.Show();
                            currentMenuItem = 1;
                            break;
                        }
                    }
                }
                if (gameRestartScreen.Enabled)
                {
                    GameState.ShowMenu = false;
                    if (kbState.IsKeyDown(Keys.Up))
                    {
                        currentMenuItem--;
                        if (currentMenuItem < 1)
                        {
                            currentMenuItem = 2;
                        }
                        gameRestartScreen.GetKey(currentMenuItem);
                    }
                    if (kbState.IsKeyDown(Keys.Down))
                    {
                        currentMenuItem++;
                        if (currentMenuItem > 2)
                        {
                            currentMenuItem = 1;
                        }
                        gameRestartScreen.GetKey(currentMenuItem);
                    }
                    if (kbState.IsKeyDown(Keys.Enter))
                    {
                        switch (currentMenuItem)
                        {
                        case 1:
                            GameState.IsPaused = false;
                            gameRestartScreen.Hide();
                            GameState.StartNewGame();
                            break;

                        case 2:
                            GameState.IsPaused = false;
                            gameRestartScreen.Hide();
                            gameScreen.Hide();
                            menuScreen.Show();
                            currentMenuItem = 1;
                            break;
                        }
                    }
                }
            }
            if (helpScreen.Enabled)
            {
                if (kbState.IsKeyDown(Keys.Escape))
                {
                    helpScreen.Hide();
                    menuScreen.Show();
                }
            }
            if (gameScreen.Enabled)
            {
                if (kbState.IsKeyDown(Keys.Escape))
                {
                    GameState.IsPaused = true;
                    gamePauseScreen.Show();
                    currentMenuItem = 1;
                }
                if (GameState.ShowMenu)
                {
                    GameState.IsPaused = true;
                    gameRestartScreen.Show();
                    currentMenuItem = 1;
                }
            }
        }