当前位置: 首页>>代码示例>>C#>>正文


C# InputHelper.Update方法代码示例

本文整理汇总了C#中InputHelper.Update方法的典型用法代码示例。如果您正苦于以下问题:C# InputHelper.Update方法的具体用法?C# InputHelper.Update怎么用?C# InputHelper.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InputHelper的用法示例。


在下文中一共展示了InputHelper.Update方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleInput

 /// <summary>
 /// Checks the difference between the old and new mouse position
 /// </summary>
 /// <param name="inputHelper">The inputhelper to react to input</param>
 public override void HandleInput(InputHelper inputHelper)
 {
     inputHelper.Update();
     mouseDiff.X = inputHelper.MousePosition.X - prevMousePos.X;
     mouseDiff.Y = inputHelper.MousePosition.Y - prevMousePos.Y;
     prevMousePos = new Vector2(GameEnvironment.Screen.X / 2, GameEnvironment.Screen.Y / 2);
     Mouse.SetPosition((int)prevMousePos.X, (int)prevMousePos.Y);
 }
开发者ID:FancyPandaSoftworks,项目名称:IntroProject,代码行数:12,代码来源:Camera.cs

示例2: HandleInput

    /// <summary>
    /// Handle the input
    /// </summary>
    /// <param name="inputHelper">The inputhelper to react to input</param>
    public override void HandleInput(InputHelper inputHelper)
    {
        base.HandleInput(inputHelper);
        inputHelper.Update();

        //Check if the playbutton is being pressed to go to the game
        if (continueButton.ButtonIsPressed)
        {
            foreach (Sound sound in MusicPlayer.Music)
                sound.StopSound();

            game.IsMouseVisible = false;
            Mouse.SetPosition(GameEnvironment.Screen.X / 2, GameEnvironment.Screen.Y / 2);
            if (File.Exists("Content\\SaveFile.txt"))
            {
                using (StreamReader stream = new StreamReader("Content\\SaveFile.txt"))
                {
                    string line = stream.ReadLine();
                    if (line != null)
                    {
                        PlayingState playingState = GameEnvironment.GameStateManager.GetGameState("playingState") as PlayingState;
                        playingState.RoomCounter = int.Parse(line);
                    }
                }
                GameEnvironment.GameStateManager.SwitchTo("playingState");
            }
        }

        if (newGameButton.ButtonIsPressed)
        {
            foreach (Sound sound in MusicPlayer.Music)
                sound.StopSound();
            game.IsMouseVisible = false;
            Mouse.SetPosition(GameEnvironment.Screen.X / 2, GameEnvironment.Screen.Y / 2);
            File.WriteAllText("Content\\SaveFile.txt", String.Empty);
            PlayingState playingState = GameEnvironment.GameStateManager.GetGameState("playingState") as PlayingState;
            playingState.RoomCounter = 1;
            GameEnvironment.GameStateManager.SwitchTo("controlsGameState");
        }

        if (exitButton.ButtonIsPressed)
        {
            game.Exit();
        }

        //Change visibility of mouseoverbutton
        if (continueButton.IsMouseOver)
            continueButtonMouseOver.Visible = true;
        else
            continueButtonMouseOver.Visible = false;

        if (newGameButtonMouseOver.IsMouseOver)
            newGameButtonMouseOver.Visible = true;
        else
            newGameButtonMouseOver.Visible = false;

        if (exitButtonMouseOver.IsMouseOver)
            exitButtonMouseOver.Visible = true;
        else
            exitButtonMouseOver.Visible = false;
    }
开发者ID:FancyPandaSoftworks,项目名称:IntroProject,代码行数:65,代码来源:TitleScreenState.cs

示例3: HandleInput

    /// <summary>
    /// React to the input
    /// </summary>
    /// <param name="inputHelper">The inputhelper to react to input</param>
    public override void HandleInput(InputHelper inputHelper)
    {
        base.HandleInput(inputHelper);
        inputHelper.Update();

        //Check if the exitButton is being pressed to go back to the title screen
        if (exitButton.ButtonIsPressed)
        {
            foreach (Sound sound in MusicPlayer.Music)
            {
                sound.PlaySound();
            }
            GameEnvironment.GameStateManager.SwitchTo("titleScreenState");
        }

        //Check if the resumeButton is being pressed to go back to the game
        if (continueButton.ButtonIsPressed || inputHelper.KeyPressed(Keys.Escape))
        {
            foreach (Sound sound in MusicPlayer.SoundEffect)
                if (sound.Name == "paperrustle2")
                    sound.PlaySound();
            game.IsMouseVisible = false;
            Mouse.SetPosition(GameEnvironment.Screen.X / 2, GameEnvironment.Screen.Y / 2);
            GameEnvironment.GameStateManager.SwitchTo("playingState");
        }

        //Change visibility of mouseoverbutton
        if (continueButton.IsMouseOver)
            continueButtonMouseOver.Visible = true;
        else
            continueButtonMouseOver.Visible = false;

        if (exitButtonMouseOver.IsMouseOver)
            exitButtonMouseOver.Visible = true;
        else
            exitButtonMouseOver.Visible = false;
    }
开发者ID:FancyPandaSoftworks,项目名称:IntroProject,代码行数:41,代码来源:PauseScreenState.cs

示例4: HandleInput

    /// <summary>
    /// React to the input
    /// </summary>
    /// <param name="inputHelper">The inputhelper to react to input</param>
    public override void HandleInput(InputHelper inputHelper)
    {
        base.HandleInput(inputHelper);
        inputHelper.Update();

        //Check if the continueButton is being pressed to go back to the game, starting from the last checkpoint
        if (continueButton.ButtonIsPressed)
        {
            game.IsMouseVisible = false;
            Mouse.SetPosition(GameEnvironment.Screen.X / 2, GameEnvironment.Screen.Y / 2);
            if (File.Exists("Content\\SaveFile.txt"))
            {
                using (StreamReader stream = new StreamReader("Content\\SaveFile.txt"))
                {
                    string line = stream.ReadLine();
                    PlayingState playingState = GameEnvironment.GameStateManager.GetGameState("playingState") as PlayingState;
                    if (line != null)
                    {
                        playingState.RoomCounter = int.Parse(line);
                    }
                    else
                    {
                        playingState.RoomCounter = 0;
                    }
                }
            }
            GameEnvironment.GameStateManager.SwitchTo("playingState");
            bgPosY = 0;
        }

        //Check if the exitbutton is being pressed, to switch back to the main menu
        if (exitButton.ButtonIsPressed)
        {
            foreach (Sound sound in MusicPlayer.Music)
            {
                sound.PlaySound();
            }
            bgPosY = 0;
            GameEnvironment.GameStateManager.SwitchTo("titleScreenState");
        }

        //Change visibility of mouseoverbutton
        if (continueButton.IsMouseOver)
            continueButtonMouseOver.Visible = true;
        else
            continueButtonMouseOver.Visible = false;

        if (exitButtonMouseOver.IsMouseOver)
            exitButtonMouseOver.Visible = true;
        else
            exitButtonMouseOver.Visible = false;
    }
开发者ID:FancyPandaSoftworks,项目名称:IntroProject,代码行数:56,代码来源:GameOverState.cs


注:本文中的InputHelper.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。