本文整理汇总了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;
}
};
}
}
示例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";
//.........这里部分代码省略.........
示例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();
}
}
}
示例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;
}
}
}