本文整理汇总了C#中Microsoft.Xna.Framework.Game.Exit方法的典型用法代码示例。如果您正苦于以下问题:C# Game.Exit方法的具体用法?C# Game.Exit怎么用?C# Game.Exit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Game
的用法示例。
在下文中一共展示了Game.Exit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public override void Update(GameTime gameTime, Game game)
{
if (jouer.isCliked)
{
SceneManager.Instance.AddScene(new PhysicsScene());
}
else if (option.isCliked)
{
Console.WriteLine("option");
}
else if (quitter.isCliked)
{
game.Exit();
}
jouer.Update(gameTime);
option.Update(gameTime);
quitter.Update(gameTime);
base.Update(gameTime,game);
}
示例2: InGameMenu
public InGameMenu(Vector2 position, Vector2 size, Game game)
: base(position, size, ContentInterface.LoadTexture("UITest"), ContentInterface.LoadTexture("UITest"))
{
Button button = new Button(this, new Vector2(60, 210), new Vector2(80, 40), Content.ContentInterface.LoadTexture("UITest"),
delegate { game.Exit(); },
"Exit");
AddChild(button);
button = new Button(this, new Vector2(20, 30), new Vector2(160, 40), Content.ContentInterface.LoadTexture("UITest"),
delegate { Console.WriteLine("Test1"); },
"Testbutton1");
AddChild(button);
button = new Button(this, new Vector2(20, 90), new Vector2(160, 40), Content.ContentInterface.LoadTexture("UITest"),
delegate { Console.WriteLine("Test2"); },
"Testbutton2");
AddChild(button);
button = new Button(this, new Vector2(20, 150), new Vector2(160, 40), Content.ContentInterface.LoadTexture("UITest"),
delegate { Console.WriteLine("Test3"); },
"Testbutton3");
AddChild(button);
}
示例3: MainPageViewModel
public MainPageViewModel(INavigationService n)
{
// XNA stuff for media control
GameTimer gameTimer = new GameTimer();
gameTimer.UpdateInterval = TimeSpan.FromMilliseconds(33);
gameTimer.Update += delegate { try { FrameworkDispatcher.Update(); } catch { } };
gameTimer.Start();
// navigation service
this.navigationService = n;
// event handlers
MediaPlayer.ActiveSongChanged += new EventHandler<EventArgs>(SongChanged);
MediaPlayer.MediaStateChanged += new EventHandler<EventArgs>(StateChanged);
FrameworkDispatcher.Update();
currentAccentColorHex = (System.Windows.Media.Color)Application.Current.Resources["PhoneAccentColor"];
if ((Application.Current as App).IsTrial)
{
if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType ==
Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None)
{
MessageBox.Show(AppResources.NetworkUnavailable);
Game game = new Game();
game.Exit();
}
}
if (MediaPlayer.GameHasControl)
{
MessageBox.Show(AppResources.TurnMusicOnLongWP7);
IsEnabled = false;
}
else
{
IsEnabled = true;
NextSongBackground = currentAccentColorHex.ToString();
UpdateView();
}
}
示例4: HandleInput
public void HandleInput(GameTime gameTime, InputState intouches, Game game)
{
Vector2 releasePt;
Vector2 touchPt = intouches.TouchState.GetTouchPt(out releasePt);
const int itemHeight = 40;
var itemRect = new Rectangle(0, 260, 800, itemHeight);
int touchedEntry = -1;
const int numMenuItems = 5;
for (int menuItem = 0; menuItem < numMenuItems; menuItem++) {
if (releasePt.X >= itemRect.Left && releasePt.X <= itemRect.Right &&
releasePt.Y >= (itemRect.Top + menuItem*itemHeight) && releasePt.Y <= (itemRect.Bottom + menuItem*itemHeight))
{
touchedEntry = menuItem;
break;
}
}
if (touchedEntry != -1) {
Invasion.Option = touchedEntry;
switch (Invasion.Option) {
case 0: // Play Game Menu Item
Invasion.currentScreen = GameplayScreen;
Invasion.SetupNewGame();
var menuSoundEffect = this.menuSoundEffect;
SoundManager.Instance.Play(menuSoundEffect);
break;
case 1: // Options Menu Item
Invasion.currentScreen = OptionsScreen;
Invasion.DelayStart = Environment.TickCount;
break;
case 2: // Credits Menu Item
Invasion.currentScreen = CreditsScreen;
Invasion.DelayStart = Environment.TickCount;
break;
case 3: // Help Menu Item
Invasion.currentScreen = HelpScreen;
ExtrasManager.Instance.Reset();
for (int iExtra = 0; iExtra < Extra.NumExtraTypes; iExtra++) {
Debug.WriteLine("Setting up iExtra = " + iExtra + ", Extra = " + (Extra.ExtraType)(iExtra));
Vector2 extraPos = new Vector2(240, HelpScreen.HelpScreenExtrasFirstRowY+HelpScreen.HelpScreenExtrasLineSpacing*iExtra);
Extra extra = new Extra(game, extraPos, (Extra.ExtraType)(iExtra));
ExtrasManager.Instance.Add(extra);
}
Invasion.DelayStart = Environment.TickCount;
//Debug.WriteLine("delayOffset = " + delayOffset + ", delayStart = " + delayStart);
break;
case 4: // Quit Menu Item Exits the Game
game.Exit();
break;
}
}
else {
for (int menuItem = 0; menuItem < numMenuItems; menuItem++) {
if (touchPt.X >= itemRect.Left && touchPt.X <= itemRect.Right &&
touchPt.Y >= (itemRect.Top + menuItem*itemHeight) && touchPt.Y <= (itemRect.Bottom + menuItem*itemHeight))
{
touchedEntry = menuItem;
break;
}
}
if (touchedEntry != -1) {
Invasion.Option = touchedEntry;
}
}
}
示例5: HandleBackButton
public override void HandleBackButton(Game game)
{
game.Exit();
}
示例6: updateKeyboard
public byte updateKeyboard(Game leJeu, KeyboardState etatClavier)
{
KeyboardState etatActuel = etatClavier;
if (statutKeyboard.enter(etatActuel))
{
switch (position)
{
case 0:
// code du newgame
return 1;
case 1:
// code du loadgame
return 2;
case 2:
// code du settings
return 3;
case 3:
// code du quit
leJeu.Exit();
break;
}
}
if (statutKeyboard.moveDown(etatClavier))
{
if (!delais.IsRunning)
{
delais.Start();
if (position < 3)
{
position++;
}
else
{
position = 0;
}
}
else if (delais.Elapsed.Milliseconds >= 175)
{
delais.Stop();
delais.Reset();
if (position < 3)
{
position++;
}
else
{
position = 0;
}
delais.Start();
}
}
if (statutKeyboard.moveUp(etatClavier))
{
if (!delais.IsRunning)
{
delais.Start();
if (position == 0)
{
position = 3;
}
else
{
position--;
}
}
else if (delais.Elapsed.Milliseconds >= 175)
{
delais.Stop();
delais.Reset();
if (position == 0)
{
position = 3;
}
else
{
position --;
}
delais.Start();
}
}
return 0;
}
示例7: HandleKeyboard
/// <summary>
/// Handle Keyboard - temporary unit WSAD movement and Animation swap
/// </summary>
public static void HandleKeyboard(Player player, Game game, GraphicsDevice device)
{
foreach (Unit unit in player.UnitList)
{
unit.lastPosition = unit.Position;
if (unit.selected)
{
if (currentKeyboardState.IsKeyDown(Keys.W))
{
unit.Position.Z -= 0.1f;
unit.Rotation.Y = MathHelper.ToRadians(180);
}
if (currentKeyboardState.IsKeyDown(Keys.S))
{
unit.Position.Z += 0.1f;
unit.Rotation.Y = MathHelper.ToRadians(360);
}
if (currentKeyboardState.IsKeyDown(Keys.A))
{
unit.Position.X -= 0.1f;
unit.Rotation.Y = MathHelper.ToRadians(270);
}
if (currentKeyboardState.IsKeyDown(Keys.D))
{
unit.Position.X += 0.1f;
unit.Rotation.Y = MathHelper.ToRadians(90);
}
if (currentKeyboardState.IsKeyDown(Keys.Z))
{
player.Souls += 100;
}
}
// Allows the game to exit
if (currentKeyboardState.IsKeyDown(Keys.Escape) && oldKeyboardState.IsKeyUp(Keys.Escape))
game.Exit();
if (currentKeyboardState.IsKeyDown(Keys.F1))
{
DefferedRenderer.lightIntensity += 0.01f;
}
if (currentKeyboardState.IsKeyDown(Keys.F2))
{
DefferedRenderer.lightIntensity -= 0.01f;
}
}
}
示例8: RunLoop
//.........这里部分代码省略.........
}
}
// Window Move
else if (evt.window.windowEvent == SDL.SDL_WindowEventID.SDL_WINDOWEVENT_MOVED)
{
/* Apparently if you move the window to a new
* display, a GraphicsDevice Reset occurs.
* -flibit
*/
int newIndex = SDL.SDL_GetWindowDisplayIndex(
game.Window.Handle
);
if (newIndex != displayIndex)
{
displayIndex = newIndex;
game.GraphicsDevice.Reset(
game.GraphicsDevice.PresentationParameters,
GraphicsAdapter.Adapters[displayIndex]
);
}
}
// Mouse Focus
else if (evt.window.windowEvent == SDL.SDL_WindowEventID.SDL_WINDOWEVENT_ENTER)
{
SDL.SDL_DisableScreenSaver();
}
else if (evt.window.windowEvent == SDL.SDL_WindowEventID.SDL_WINDOWEVENT_LEAVE)
{
SDL.SDL_EnableScreenSaver();
}
}
// Controller device management
else if (evt.type == SDL.SDL_EventType.SDL_CONTROLLERDEVICEADDED)
{
INTERNAL_AddInstance(evt.cdevice.which);
}
else if (evt.type == SDL.SDL_EventType.SDL_CONTROLLERDEVICEREMOVED)
{
INTERNAL_RemoveInstance(evt.cdevice.which);
}
// Text Input
else if (evt.type == SDL.SDL_EventType.SDL_TEXTINPUT && !INTERNAL_TextInputSuppress)
{
string text;
// Based on the SDL2# LPUtf8StrMarshaler
unsafe
{
byte* endPtr = evt.text.text;
while (*endPtr != 0)
{
endPtr++;
}
byte[] bytes = new byte[endPtr - evt.text.text];
Marshal.Copy((IntPtr) evt.text.text, bytes, 0, bytes.Length);
text = System.Text.Encoding.UTF8.GetString(bytes);
}
if (text.Length > 0)
{
TextInputEXT.OnTextInput(text[0]);
}
}
// Quit
else if (evt.type == SDL.SDL_EventType.SDL_QUIT)
{
game.RunApplication = false;
break;
}
}
// Text Input Controls Key Handling
if (INTERNAL_TextInputControlDown[0] && INTERNAL_TextInputControlRepeat[0] <= Environment.TickCount)
{
TextInputEXT.OnTextInput((char) 8);
}
if (INTERNAL_TextInputControlDown[1] && INTERNAL_TextInputControlRepeat[1] <= Environment.TickCount)
{
TextInputEXT.OnTextInput((char) 9);
}
if (INTERNAL_TextInputControlDown[2] && INTERNAL_TextInputControlRepeat[2] <= Environment.TickCount)
{
TextInputEXT.OnTextInput((char) 13);
}
if (INTERNAL_TextInputControlDown[3] && INTERNAL_TextInputControlRepeat[3] <= Environment.TickCount)
{
TextInputEXT.OnTextInput((char) 22);
}
Keyboard.SetKeys(keys);
game.Tick();
}
// We out.
game.Exit();
}
示例9: Update
public void Update(GameTime gameTime, Game game)
{
MouseState mouse = Mouse.GetState();
KeyboardState keyboard = Keyboard.GetState();
GamePadState gamepad = GamePad.GetState(PlayerIndex.One, GamePadDeadZone.None);
switch (CurrentGameState)
{
case GameState.SplashScreen:
if (keyboard.IsKeyDown(Keys.Space) || m_ButtonSpace.isClicked == true || gamepad.IsButtonDown(Buttons.Start))
{
currentGameState = GameState.MainMenu;
}
m_ButtonSpace.Update(mouse);
break;
case GameState.MainMenu:
if (m_ButtonPlay.isClicked == true || gamepad.IsButtonDown(Buttons.A) && m_ButtonDown == false)
{
m_ButtonDown = true;
// Level.loadLevel(0);
currentGameState = GameState.Game;
}
else if (gamepad.IsButtonUp(Buttons.A))
{
m_ButtonDown = false;
}
m_ButtonPlay.Update(mouse);
if (m_ButtonCredits.isClicked == true || gamepad.IsButtonDown(Buttons.X) && m_ButtonDown == false)
{
m_ButtonDown = true;
currentGameState = GameState.Credits;
}
else if (gamepad.IsButtonUp(Buttons.X))
{
m_ButtonDown = false;
}
m_ButtonCredits.Update(mouse);
if (m_ButtonLevelSelect.isClicked == true || gamepad.IsButtonDown(Buttons.Y) && m_ButtonDown == false)
{
m_ButtonDown = true;
currentGameState = GameState.LevelSelect;
}
else if (gamepad.IsButtonUp(Buttons.Y))
{
m_ButtonDown = false;
}
m_ButtonLevelSelect.Update(mouse);
if (m_ButtonExit.isClicked == true || gamepad.IsButtonDown(Buttons.Back) && m_ButtonDown == false)
{
m_ButtonDown = true;
game.Exit();
}
else if (gamepad.IsButtonUp(Buttons.Back))
{
m_ButtonDown = false;
}
m_ButtonExit.Update(mouse);
break;
case GameState.Credits:
if (m_ButtonBack.isClicked == true || gamepad.IsButtonDown(Buttons.B) && m_ButtonDown == false)
{
m_ButtonDown = true;
CurrentGameState = GameState.MainMenu;
}
else if (gamepad.IsButtonDown(Buttons.B))
{
m_ButtonDown = false;
}
m_ButtonBack.Update(mouse);
break;
case GameState.LevelSelect:
if (m_LevelOne.isClicked == true || gamepad.IsButtonDown(Buttons.A) && m_ButtonDown == false)
{
m_ButtonDown = true;
Level.loadLevel(0);
CurrentGameState = GameState.Game;
}
else if (gamepad.IsButtonDown(Buttons.A))
{
m_ButtonDown = false;
}
m_LevelOne.Update(mouse);
if (m_LevelTwo.isClicked == true || gamepad.IsButtonDown(Buttons.X) && m_ButtonDown == false)
{
m_ButtonDown = true;
Level.loadLevel(1);
CurrentGameState = GameState.Game;
}
m_LevelTwo.Update(mouse);
if (m_LevelThree.isClicked == true || gamepad.IsButtonDown(Buttons.Y) && m_ButtonDown == false)
{
m_ButtonDown = true;
Level.loadLevel(2);
CurrentGameState = GameState.Game;
}
m_LevelThree.Update(mouse);
//.........这里部分代码省略.........
示例10: Update
public int Update(Game g)
{
keystate = Keyboard.GetState();
if (keystate.IsKeyDown(Keys.R) && prevKeystate.IsKeyUp(Keys.R))
{
return 2;
}
else if (keystate.IsKeyDown(Keys.M) && prevKeystate.IsKeyUp(Keys.M))
{
return 0;
}
else if (keystate.IsKeyDown(Keys.E))
{
g.Exit();
}
prevKeystate = keystate;
return 4;
}
示例11: backroungWorker_DoWork
void backroungWorker_DoWork(object sender, DoWorkEventArgs e)
{
try
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
//On regarde si c'est le premier lancement
var store = IsolatedStorageFile.GetUserStoreForApplication();
if (!store.FileExists("firstRunVictor.txt"))
{
//Création du fichier
if (MessageBox.Show("Before to use the game, you must accept the terms of the agreement", "License Agreement", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
{
//On met à jour l'acceptation des licenses
using (var stream = store.OpenFile("firstRunVictor.txt", FileMode.Create))
{
StreamWriter writer = new StreamWriter(stream);
writer.Write(true);
writer.Close();
}
Init.InitBDD();
}
//On quitte l'application
else
{
Game game = new Game();
game.Exit();
}
}
});
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Erreur", MessageBoxButton.OK);
}
}
示例12: OnBackKeyPress
protected override void OnBackKeyPress(CancelEventArgs e)
{
base.OnBackKeyPress(e);
Game game = new Game();
game.Exit();
}
示例13: CreateEscKey
//simple method to allow the Escape key to act as an exit method;
//The reason for making all of these "utility" methods in classes is to allow for easy code distribution
//once the game really gets going
//****Pre: Must be added in Update() method as it is currently written-> make event later
public void CreateEscKey(Game GameArg)
{
if (Keyboard.GetState().IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape))
GameArg.Exit();
}
示例14: Execute
public override void Execute(Game game, ISceneRouter router)
{
game.Exit();
}
示例15: AudioEngine
private bool throwExceptions = false; // Should this class throw exceptions?
#endregion Fields
#region Constructors
/// <summary>
/// Initialize audio engine
/// </summary>
/// <param name="instance">The instance of the game</param>
public AudioEngine(Game instance)
{
// Initialize Bass.Net
// Returning false means Bass did not start
if (StartBassNet() == false)
{
// Display a warning to the user that Bass did not start and there is no sound
DialogResult result = MessageBox.Show("Warning, pressing OK may result in no sound and/or unforeseen events. Press cancel to close the program",
"Bass failed to start", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
// If the user does not wish to continue, exit the game
if (result == DialogResult.Cancel)
{
instance.Exit();
}
}
}