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


C# Game1.Exit方法代码示例

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


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

示例1: WireUpEvents

 // Clicked event
 protected void WireUpEvents(Game1 game)
 {
     // if this button is for change menu state
     if (change != null) {
         Clicked += delegate(object sender, EventArgs e) {
             ((Button)sender).state = ButtonStatus.Up;
             game.Menu.ChangeState(change.Value, ((Button)sender).Text);
         };
     } else {
         Clicked += delegate(object sender, EventArgs e) {
             ((Button)sender).state = ButtonStatus.Up;
             if (Text.Contains("Exit")) {
                 game.Exit();
             }
             if (Text.Contains("Resume")) {
                 game.State = GameState.InGame;
             }
         };
     }
 }
开发者ID:Konjo,项目名称:PracProj,代码行数:21,代码来源:Button.cs

示例2: MouseClicked

        //method for mouse on main menu
        public Rectangle MouseClicked(int x, int y, Game1 game, ref int currentLevel, ref List<Enemy> enemies, ref List<PickUpItem> Items, ref List<Projectile> projectiles, ref int timer, ContentManager Content, ref Character player, ref string wepUnl, ref bool songPlaying, ref SoundEffectInstance song) {
            Rectangle mouseClickRect = new Rectangle(x, y, 1, 1);
            Rectangle startbuttonRect = new Rectangle((int)startButtonPosition.X, (int)startButtonPosition.Y, 300, 108);
            Rectangle exitbuttonRect = new Rectangle((int)exitButtonPosition.X, (int)exitButtonPosition.Y, 600, 192);

            if (gameState == "StartMenu") {
                //player clicks start
                if (mouseClickRect.Intersects(startbuttonRect)) {
                    try {
                        gameState = "Case";
                        CheckGameState();
                    } catch (GameStateNotFoundException) {
                        
                        gameState = "Case";
                    }

                }
                //player exits game
                else if (mouseClickRect.Intersects(exitbuttonRect)) {
                    game.Exit();
                }
                // player clicked on options
                else if (mouseClickRect.Intersects(optionsButtonPosition)) {
                    try {
                        gameState = "OptionsMenu";
                        lastState = "StartMenu";
                        CheckGameState();
                    } catch (GameStateNotFoundException e) {
                        Console.WriteLine(e.ToString());
                        gameState = "";
                    }
                } else if (mouseClickRect.Intersects(levelSelectButtonPosition)) {
                    try {
                        gameState = "LevelSelect";
                        lastState = "StartMenu";
                        CheckGameState();
                    } catch (GameStateNotFoundException e) {
                        Console.WriteLine(e.ToString());
                        gameState = "";
                    }
                }
            }
            //level select menu
            else if (gameState == "LevelSelect") {
                // back button clicked
                if (mouseClickRect.Intersects(backButtonPosition)) {
                    try {
                        gameState = lastState;
                        CheckGameState();
                    } catch (GameStateNotFoundException e) {
                        Console.WriteLine(e.ToString());
                        gameState = "";
                        lastState = "";
                    }
                } else if (mouseClickRect.Intersects(levelRect[0]) || mouseClickRect.Intersects(levelRect[1]) || mouseClickRect.Intersects(levelRect[2]) || mouseClickRect.Intersects(levelRect[3]) || mouseClickRect.Intersects(levelRect[4]) || mouseClickRect.Intersects(levelRect[5]) || mouseClickRect.Intersects(levelRect[6]) || mouseClickRect.Intersects(levelRect[7])) {
                    Shooting.CreateWeapons(Content);
                    if (mouseClickRect.Intersects(levelRect[0]) && levelClears[0] != 0) {
                        currentLevel = 1;
                        SkillSystem.CreateSkills(Content, player);
                        player.Health = player.MaxHealth;
                        player.Stamina = 100;
                        wepUnl = "";
                        player.Weapon = Shooting.weapons[1];
                        player.FrameLevel = 1;
                        enemies.Clear();
                        Items.Clear();
                        projectiles.Clear();
                        timer = 0;
                        gameState = "LevelSwitch";
                        CheckGameState();
                    } else if (mouseClickRect.Intersects(levelRect[1]) && levelClears[1] != 0) {
                        currentLevel = 2;
                        Shooting.weapons[2].IsAcquired = true;
                        SkillSystem.CreateSkills(Content, player);
                        player.Health = player.MaxHealth;
                        player.Stamina = 100;
                        wepUnl = "";
                        player.Weapon = Shooting.weapons[1];
                        player.FrameLevel = 1;
                        enemies.Clear();
                        Items.Clear();
                        projectiles.Clear();
                        timer = 0;
                        gameState = "LevelSwitch";
                        CheckGameState();
                    } else if (mouseClickRect.Intersects(levelRect[2]) && levelClears[2] != 0) {
                        currentLevel = 3;
                        Shooting.weapons[2].IsAcquired = true;
                        SkillSystem.CreateSkills(Content, player);
                        player.Health = player.MaxHealth;
                        player.Stamina = 100;
                        wepUnl = "";
                        player.Weapon = Shooting.weapons[1];
                        player.FrameLevel = 1;
                        enemies.Clear();
                        Items.Clear();
                        projectiles.Clear();
                        timer = 0;
                        gameState = "LevelSwitch";
//.........这里部分代码省略.........
开发者ID:JoeyTheAsian,项目名称:Just-Force,代码行数:101,代码来源:GameStateManager.cs

示例3: Update

 public void Update(Game1 game)
 {
     oldState = currentState;
     currentState = Keyboard.GetState();
     if ((currentState.IsKeyDown(Keys.Up) && oldState.IsKeyUp(Keys.Up)) || (currentState.IsKeyDown(Keys.Down) && oldState.IsKeyUp(Keys.Down)))
     {
         play = !play;
     }
     if (currentState.IsKeyDown(Keys.Enter))
     {
         if (play)
         {
             game.transition = true;
         }
         else
         {
             game.Exit();
         }
     }
 }
开发者ID:Oscillation,项目名称:School_Project_GameBuild,代码行数:20,代码来源:StartMenu.cs

示例4: Update

 public void Update(Game1 game)
 {
     if (game.keyState.IsKeyDown(Keys.Up) && game.oldState.IsKeyUp(Keys.Up))
     {
         if (!exitSelected && !resumeSelected)
         {
             resumeSelected = true;
             exitSelected = false;
         }
         else if (resumeSelected)
         {
             exitSelected = true;
             resumeSelected = false;
         }
         else if (exitSelected)
         {
             resumeSelected = true;
             exitSelected = false;
         }
     }
     if (game.keyState.IsKeyDown(Keys.Down) && game.oldState.IsKeyUp(Keys.Down))
     {
         if (!exitSelected && !resumeSelected)
         {
             exitSelected = true;
             resumeSelected = false;
         }
         else if (resumeSelected)
         {
             exitSelected = true;
             resumeSelected = false;
         }
         else if (exitSelected)
         {
             resumeSelected = true;
             exitSelected = false;
         }
     }
     if (exitSelected)
     {
         exit = game.Content.Load<Texture2D>(@"Game\Menu\exitSelected");
         resume = game.Content.Load<Texture2D>(@"Game\Menu\resume");
     }
     if (resumeSelected)
     {
         exit = game.Content.Load<Texture2D>(@"Game\Menu\exit");
         resume = game.Content.Load<Texture2D>(@"Game\Menu\resumeSelected");
     }
     if (game.keyState.IsKeyDown(Keys.Enter))
     {
         if (exitSelected)
         {
             game.Exit();
         }
         if (resumeSelected)
         {
             Game1.currentGameState = Game1.GameState.PLAY;
             paused = false;
         }
     }
 }
开发者ID:Oscillation,项目名称:School_Project_GameBuild,代码行数:61,代码来源:Menu.cs


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