#region Using directives using System; using System.Collections.Generic; using System.Text; using XnaGraphicEngine.GameScreens; using Microsoft.Xna.Framework; using XnaGraphicEngine.Helpers; using Microsoft.Xna.Framework.Input; using XnaGraphicEngine.Properties; using XnaGraphicEngine.Graphics; #endregion namespace XnaGraphicEngine.Game { /// /// Player helper class, holds all the current game properties: /// Health, Weapon and Score. /// Note: This is a static class and holds always all player entries /// for the current game. If we would have more than 1 player (e.g. /// in multiplayer mode) this should not be a static class! /// static class Player { #region Variables /// /// Current game time in ms. Used for time display in game. Also used to /// update the level position. /// public static float gameTimeMs = 0; /// /// Won or lost? /// public static bool victory = false; /// /// Game over? /// private static bool gameOver = false; /// /// Is game over? /// /// Bool public static bool GameOver { get { return gameOver; } // get } // GameOver /// /// Remember if we already uploaded our highscore for this game. /// Don't do this twice (e.g. when pressing esc). /// static bool alreadyUploadedHighscore = false; /// /// Set game over and upload highscore /// public static void SetGameOverAndUploadHighscore() { // Set lifes to 0 and set gameOver to true to mark this game as ended. gameOver = true; // Upload highscore if (alreadyUploadedHighscore == false) { alreadyUploadedHighscore = true; Highscores.SubmitHighscore(score, Highscores.DefaultLevelName); } // if (alreadyUploadedHighscore) } // SetGameOverAndUploadHighscore() #endregion #region Current player values (health, weapon, etc.) /// /// Health, 1 means we have 100% health, everything below means we /// are damaged. If we reach 0, we die! /// public static float health = 1.0f; /// /// Weapon types we can carry with our ship /// public enum WeaponTypes { MG, Plasma, Gattling, Rockets, } // enum WeaponTypes /// /// Weapon we currently have, each weapon is replaced by the /// last collected one. No ammunition is used. /// public static WeaponTypes currentWeapon = WeaponTypes.MG; /// /// Do we have the EMP bomb? Press space to fire them. /// public static int empBombs = 0; /// /// Current score. Used as highscore if game is over. /// public static int score = 0; #endregion #region Reset everything for starting a new game /// /// Keys for moving around. Assigned from settings! /// static Keys moveLeftKey, moveRightKey, moveUpKey, moveDownKey; /// /// Default to normal mouse sensibility, can be changed /// from 0.5 to 2.0. /// static float mouseSensibility = 1.0f; /// /// Reset all player entries for restarting a game. /// public static void Reset() { gameOver = false; alreadyUploadedHighscore = false; gameTimeMs = 0; health = 1.0f; score = 0; // Assign keys. Warning: This is VERY slow, never use it // inside any render loop (getting Settings, etc.)! moveLeftKey = GameSettings.Default.MoveLeftKey; moveRightKey = GameSettings.Default.MoveRightKey; moveUpKey = GameSettings.Default.MoveForwardKey; moveDownKey = GameSettings.Default.MoveBackwardKey; // Also assign mouse sensibility mouseSensibility = 2.5f - 2.0f * GameSettings.Default.ControllerSensibility; if (mouseSensibility < 0.5f) mouseSensibility = 0.5f; } // Reset(setLevelName) #endregion #region Handle game logic /// /// Handle game logic /// public static void HandleGameLogic(Mission mission) { //TODO } // HandleGameLogic(asteroidManager) #endregion } // class Player } // namespace XnaGraphicEngine