public EngineStateGameOver(Engine engine) { engine_ = engine; duration_ = new TimeSpan(); SoundEngine.getInstance().playCue("goddamnit"); }
/// <summary> /// Creates a main menu state /// </summary> /// <param name="engine">A reference to the engine running the state</param> public EngineStateMenu(Engine engine) { engine_ = engine; logo_ = TextureMap.fetchTexture("TitleScreen"); List<string> menuString = new List<string>(); menuString.Add(STR_MENU_START_GAME); menuString.Add(STR_MENU_CUSTOM_LEVEL); menuString.Add(STR_MENU_CONTROLS); menuString.Add(STR_MENU_LEVEL_EDITOR); menuString.Add(STR_MENU_QUIT); GlobalHelper.getInstance().setCurrentCamera(new Camera()); InputSet inputs = InputSet.getInstance(); /*controlTips_ = "Select: " + inputs.getControlName(InputsEnum.CONFIRM_BUTTON) + " | " + "Cancel: " + inputs.getControlName(InputsEnum.CANCEL_BUTTON);*/ controlTips_ = ""; // currrently refreshed every frame in draw() mainMenuList_ = new MenuList(menuString, MENU_POSITION); mainMenuList_.BaseColor_ = MENU_UNSELECTED_COLOR; mainMenuList_.SelectedColor_ = MENU_SELECTED_COLOR; mainMenuList_.CursorPos_ = MENU_DEFAULT_CURSOR_POSITION; mainMenuList_.Font_ = MENU_FONT; mainMenuList_.Spacing_ = MENU_SPACING; mainMenuList_.LayerDepth_ = MENU_DEPTH; SoundEngine.getInstance().playCue("go_commando"); SoundEngine.getInstance().playMusic("menu"); }
/// <summary> /// Constructor determines whether PC or Xbox 360 and initializes /// variables accordingly. /// /// For PC, this means creating the controller and trying to get a /// storage device. /// /// For the Xbox 360, we don't need to do much as we rely on update() /// logic to determine active controller and storage device. /// </summary> /// <param name="engine"></param> public EngineStateStart(Engine engine) { engine_ = engine; logo_ = TextureMap.fetchTexture("TitleScreen"); #if !XBOX { Settings settings = Settings.getInstance(); if (Settings.getInstance().IsUsingMouse_) { engine_.Controls_ = new PCControllerInput(engine_); settings.CurrentPlayer_ = PlayerIndex.One; TEXT_MESSAGE = "Press " + engine_.Controls_.getControlName(InputsEnum.CONFIRM_BUTTON).ToUpper() + " to Continue"; } else { engine_.Controls_ = new X360ControllerInput(engine_, PlayerIndex.One); settings.CurrentPlayer_ = PlayerIndex.One; TEXT_MESSAGE = "Press " + engine_.Controls_.getControlName(InputsEnum.CONFIRM_BUTTON).ToUpper() + " to Continue"; } prepareStorageDevice(); returnFlag_ = true; } #else { engine_.Controls_ = null; // reset controls if they are coming back to this returnFlag_ = false; } #endif }
/// <summary> /// This is not the recommended ctor, either /// </summary> /// <param name="engine"></param> /// <param name="nextState"></param> /// <param name="durationOfStorySegment"></param> public EngineStateStorySegment(Engine engine, EngineStateInterface nextState, int durationOfStorySegment) { engine_ = engine; nextState_ = nextState; framesSpentInStory_ = 0; DurationOfStory_ = durationOfStorySegment; storyText_ = "You have many questions. The next room could provide the answers you seek."; isUsingImage_ = false; }
/// <summary> /// This is not the recommended ctor /// </summary> /// <param name="engine"></param> /// <param name="nextState"></param> public EngineStateStorySegment(Engine engine, EngineStateInterface nextState) { engine_ = engine; nextState_ = nextState; framesSpentInStory_ = 0; DurationOfStory_ = 1; storyText_ = "You hear the cold, metallic clanks of robot feet pacing\n the room ahead, but you must keep moving forward."; isUsingImage_ = false; }
public EngineStateEditorControls(Engine engine, EngineStateInterface returnState) { InputSet inputs = InputSet.getInstance(); controlTitle_ = "CONTROLS"; engine_ = engine; returnState_ = returnState; List<string> selectedControlsString = new List<string>(); selectedControlsString.Add("WITH OBJECT SELECTED"); selectedControlsString.Add("Deslect: " + inputs.getControlName(InputsEnum.RIGHT_TRIGGER)); selectedControlsString.Add("Place: " + inputs.getControlName(InputsEnum.LEFT_TRIGGER)); selectedControlsString.Add("Rotate L: " + inputs.getControlName(InputsEnum.LEFT_BUMPER)); selectedControlsString.Add("Rotate R: " + inputs.getControlName(InputsEnum.RIGHT_BUMPER)); selectedControlsString.Add("Delete: " + inputs.getControlName(InputsEnum.BUTTON_3)); List<string> unselectedControlsString = new List<string>(); unselectedControlsString.Add("NORMAL EDITOR CONTROLS"); #if XBOX selectedControlsString.Add("(Coming Soon)"); #endif unselectedControlsString.Add("Move Camera/Cursor: " + inputs.getControlName(InputsEnum.LEFT_DIRECTIONAL)); unselectedControlsString.Add("Select Object/Tile: " + inputs.getControlName(InputsEnum.LEFT_TRIGGER)); unselectedControlsString.Add("Next Tile: " + inputs.getControlName(InputsEnum.BUTTON_1)); unselectedControlsString.Add("Prev Tile: " + inputs.getControlName(InputsEnum.BUTTON_2)); unselectedControlsString.Add("Next Palette: " + inputs.getControlName(InputsEnum.LEFT_BUMPER)); unselectedControlsString.Add("Prev Palette: " + inputs.getControlName(InputsEnum.RIGHT_BUMPER)); unselectedControlsString.Add("Place Tile: " + inputs.getControlName(InputsEnum.RIGHT_TRIGGER)); unselectedControlsString.Add("Options: " + inputs.getControlName(InputsEnum.CANCEL_BUTTON)); Vector2 selectedControlsMenuPos = new Vector2(engine_.GraphicsDevice.Viewport.Width / 2.0f - 200.0f, engine_.GraphicsDevice.Viewport.Height / 2.0f - 125.0f); selectedControlsMenuList_ = new MenuList(selectedControlsString, selectedControlsMenuPos); selectedControlsMenuList_.Font_ = CONTROLS_FONT; selectedControlsMenuList_.BaseColor_ = CONTROLS_COLOR; selectedControlsMenuList_.SelectedColor_ = CONTROLS_TITLE_COLOR; selectedControlsMenuList_.Spacing_ = CONTROLS_SPACING; Vector2 unselectedControlsMenuPos = new Vector2(engine_.GraphicsDevice.Viewport.Width / 2.0f + 200.0f, engine_.GraphicsDevice.Viewport.Height / 2.0f - 125.0f); unselectedControlsMenuList_ = new MenuList(unselectedControlsString, unselectedControlsMenuPos); unselectedControlsMenuList_.BaseColor_ = CONTROLS_COLOR; unselectedControlsMenuList_.SelectedColor_ = CONTROLS_TITLE_COLOR; unselectedControlsMenuList_.Font_ = CONTROLS_FONT; unselectedControlsMenuList_.Spacing_ = CONTROLS_SPACING; }
public EngineStateLevelSave(Engine engine, EngineStateLevelEditor state, EngineStateInterface successState, EngineStateInterface cancelState) { engine_ = engine; state_ = state; successState_ = successState; cancelState_ = cancelState; returnState_ = this; mainMessage_ = FontMap.getInstance().getFont(MESSAGE_FONT); StorageDevice sd = Settings.getInstance().StorageDevice_; if (sd == null) { #if !XBOX saveDialog(); #endif } }
/// <summary> /// Creates a pause state which waits for the user to resume play /// </summary> /// <param name="engine">Reference to the engine running the state</param> /// <param name="savedState">The state of play to return to once the user unpauses</param> public EngineStatePause(Engine engine, EngineStateInterface savedState) { engine_ = engine; savedState_ = savedState; List<string> menuString = new List<string>(); menuString.Add(STR_RETURN_TO_GAME); menuString.Add(STR_CONTROLS); menuString.Add(STR_GAME_OPTIONS); menuString.Add(STR_QUIT_GAME); int cursor = (int)Settings.getInstance().getMovementType(); menuList_ = new MenuList(menuString, PAUSE_MENU_POSITION); menuList_.Font_ = PAUSE_FONT; menuList_.BaseColor_ = PAUSE_MENU_UNSELECTED_COLOR; menuList_.SelectedColor_ = PAUSE_MENU_SELECTED_COLOR; menuList_.Spacing_ = PAUSE_MENU_SPACING; menuList_.CursorPos_ = PAUSE_MENU_DEFAULT_SELECTED_ITEM; }
/// <summary> /// Creates an options state which allows the user to adjust game settings /// </summary> /// <param name="engine">Reference to the engine running the state</param> /// <param name="savedState">The state of play to return to once the user finishes</param> public EngineStateOptions(Engine engine, EngineStateInterface savedState) { engine_ = engine; savedState_ = savedState; List<string> menuString = new List<string>(); if (Settings.getInstance().getMovementType() == MovementType.ABSOLUTE) { menuString.Add(STR_MOVEMENT_TYPE_ABSOLUTE); } else { menuString.Add(STR_MOVEMENT_TYPE_RELATIVE); } if (Settings.getInstance().IsSoundAllowed_) { menuString.Add(STR_SOUND_ON); } else { menuString.Add(STR_SOUND_OFF); } menuString.Add(STR_RESOLUTION); if (Settings.getInstance().IsGamerServicesAllowed_) { menuString.Add(STR_CHANGE_STORAGE); } if (Settings.getInstance().IsInDebugMode_) { menuString.Add(STR_DEBUG_MODE_ON); } else { menuString.Add(STR_DEBUG_MODE_OFF); } menuString.Add(STR_RETURN); menuList_ = new MenuList(menuString, OPTIONS_MENU_POSITION); menuList_.Font_ = OPTIONS_FONT; menuList_.BaseColor_ = OPTIONS_MENU_UNSELECTED_COLOR; menuList_.SelectedColor_ = OPTIONS_MENU_SELECTED_COLOR; menuList_.Spacing_ = OPTIONS_MENU_SPACING; menuList_.CursorPos_ = OPTIONS_MENU_DEFAULT_SELECTED_ITEM; }
public EngineStateControls(Engine engine) { InputSet inputs = InputSet.getInstance(); controlTitle_ = "CONTROLS"; engine_ = engine; List<string> gameControlsString = new List<string>(); gameControlsString.Add("GAMEPLAY CONTROLS"); gameControlsString.Add("Move: " + inputs.getControlName(InputsEnum.LEFT_DIRECTIONAL)); gameControlsString.Add("Rotate: " + inputs.getControlName(InputsEnum.RIGHT_DIRECTIONAL)); gameControlsString.Add("Fire: " + inputs.getControlName(InputsEnum.RIGHT_TRIGGER)); gameControlsString.Add("Pause: " + inputs.getControlName(InputsEnum.CANCEL_BUTTON)); List<string> editorControlsString = new List<string>(); editorControlsString.Add("EDITOR CONTROLS"); editorControlsString.Add("Move Cursor: " + inputs.getControlName(InputsEnum.LEFT_DIRECTIONAL)); editorControlsString.Add("Next Tile: " + inputs.getControlName(InputsEnum.BUTTON_1)); editorControlsString.Add("Prev Tile: " + inputs.getControlName(InputsEnum.BUTTON_2)); editorControlsString.Add("Next Palette: " + inputs.getControlName(InputsEnum.LEFT_BUMPER)); editorControlsString.Add("Prev Palette: " + inputs.getControlName(InputsEnum.RIGHT_BUMPER)); editorControlsString.Add("Place Tile: " + inputs.getControlName(InputsEnum.RIGHT_TRIGGER)); editorControlsString.Add("Quit: " + inputs.getControlName(InputsEnum.CANCEL_BUTTON)); Vector2 gameControlsMenuPos = new Vector2(engine_.GraphicsDevice.Viewport.Width / 2.0f - 200.0f, engine_.GraphicsDevice.Viewport.Height / 2.0f - 125.0f); gameControlsMenuList_ = new MenuList(gameControlsString, gameControlsMenuPos); gameControlsMenuList_.Font_ = CONTROLS_FONT; gameControlsMenuList_.BaseColor_ = CONTROLS_COLOR; gameControlsMenuList_.SelectedColor_ = CONTROLS_TITLE_COLOR; gameControlsMenuList_.Spacing_ = CONTROLS_SPACING; Vector2 editorControlsMenuPos = new Vector2(engine_.GraphicsDevice.Viewport.Width / 2.0f + 200.0f, engine_.GraphicsDevice.Viewport.Height / 2.0f - 125.0f); editorControlsMenuList_ = new MenuList(editorControlsString, editorControlsMenuPos); editorControlsMenuList_.BaseColor_ = CONTROLS_COLOR; editorControlsMenuList_.SelectedColor_ = CONTROLS_TITLE_COLOR; editorControlsMenuList_.Font_ = CONTROLS_FONT; editorControlsMenuList_.Spacing_ = CONTROLS_SPACING; }
/// <summary> /// Creates an options state which allows the user to adjust game settings /// </summary> /// <param name="engine">Reference to the engine running the state</param> /// <param name="savedState">The state of play to return to once the user finishes</param> public EngineStateEditorOptions(Engine engine, EngineStateLevelEditor savedState) { engine_ = engine; savedState_ = savedState; List<string> menuString = new List<string>(); if (Settings.getInstance().IsSoundAllowed_) { menuString.Add(STR_SOUND_ON); } else { menuString.Add(STR_SOUND_OFF); } menuString.Add(STR_RESOLUTION); if (Settings.getInstance().IsGamerServicesAllowed_) { menuString.Add(STR_CHANGE_STORAGE); } if (Settings.getInstance().IsInDebugMode_) { menuString.Add(STR_DEBUG_MODE_ON); } else { menuString.Add(STR_DEBUG_MODE_OFF); } menuString.Add(STR_SAVE_CONTINUE); menuString.Add(STR_SAVE_QUIT); menuString.Add(STR_QUIT_NOSAVE); menuString.Add(STR_RETURN); menuList_ = new MenuList(menuString, OPTIONS_MENU_POSITION); menuList_.Font_ = OPTIONS_FONT; menuList_.BaseColor_ = OPTIONS_MENU_UNSELECTED_COLOR; menuList_.SelectedColor_ = OPTIONS_MENU_SELECTED_COLOR; menuList_.Spacing_ = OPTIONS_MENU_SPACING; menuList_.CursorPos_ = OPTIONS_MENU_DEFAULT_SELECTED_ITEM; }
/// <summary> /// Constructs a state of gameplay using the provided level /// </summary> public EngineStateGameplay(Engine engine, Level level) { engine_ = engine; GlobalHelper.getInstance().setGameplayState(this); GlobalHelper.getInstance().getCurrentCamera().setScreenWidth((float)engine_.graphics_.PreferredBackBufferWidth); GlobalHelper.getInstance().getCurrentCamera().setScreenHeight((float)engine_.graphics_.PreferredBackBufferHeight); loadLevel(level); }
/// <summary> /// Use this ctor /// </summary> /// <param name="engine">A handle to the main Engine class</param> /// <param name="nextState">A handle to the EngineState to return when the story segment is done</param> /// <param name="durationOfStorySegment">How long, in seconds, you want the story segment to last. /// The player can always skip the story segment by pressing B, Start, or Back.</param> /// <param name="storyImgFilepath"></param> /// <param name="altText"></param> public EngineStateStorySegment(Engine engine, EngineStateInterface nextState, int durationOfStorySegment, string storyImgFilepath, string altText) { engine_ = engine; nextState_ = nextState; framesSpentInStory_ = 0; DurationOfStory_ = durationOfStorySegment; storyText_ = altText; try { isUsingImage_ = true; storyImg_ = new GameTexture(storyImgFilepath, engine.spriteBatch_, engine.GraphicsDevice); } catch { // That's okay, we will just use the altText. isUsingImage_ = false; } }
public EngineStateControls(Engine engine, EngineStateInterface returnState) : this(engine) { returnState_ = returnState; }
/// <summary> /// Load all the textures for the game. /// </summary> /// <param name="filepath">Filename of the texture document</param> /// <param name="spriteBatch">SpriteBatch for the game</param> /// <param name="graphics">GraphicsDevice for the game</param> public void loadTextures(string filename, Engine engine) { SpriteBatch spriteBatch = engine.spriteBatch_; GraphicsDevice graphics = engine.GraphicsDevice; using (ManagedXml manager = new ManagedXml(engine)) { try { XmlDocument document = manager.loadFromFile(filename); XmlNodeList textureXMLs = document.GetElementsByTagName("texture"); foreach (XmlNode node in textureXMLs) { KeyValuePair<string, GameTexture> tempPair = GameTexture.loadTextureFromFile(node.InnerText, spriteBatch, graphics); textures_.Add(tempPair.Key, tempPair.Value); } XmlNodeList images = document.GetElementsByTagName("image"); foreach (XmlNode node in images) { string key = "", image = ""; XmlNodeList children = node.ChildNodes; foreach (XmlNode child in children) { if (child.LocalName == "key") { key = child.InnerText; } else if (child.LocalName == "handle") { image = child.InnerText; } } textures_.Add(key, new GameTexture(image, spriteBatch, graphics)); } } catch (Exception e) { Console.Out.WriteLine("FATAL ERROR: Texture Map failed to load!"); throw e; } } // Don't collect here, because we will be reading in a lot of these XML docs //GC.Collect(); //GC.WaitForPendingFinalizers(); }
/// <summary> /// This is the constructor that should almost always be used /// </summary> /// <param name="filepath">The path to the .spritefont file, without .spritefont at the end</param> /// <param name="spriteBatch">The spriteBatch to be used when drawing text</param> /// <param name="engine">The main Engine class</param> public GameFont(string filename, SpriteBatch spriteBatch, Engine engine) { spriteBatch_ = spriteBatch; font_ = engine.Content.Load<SpriteFont>(filename); }
/// <summary> /// Loads SpriteFont information from file /// </summary> /// <param name="filepath">The .xml file that contains all the Font information</param> /// <param name="spriteBatch">The spriteBatch that will be used to draw text</param> /// <param name="engine">The main Engine class</param> public void loadFonts(string filename, SpriteBatch spriteBatch, Engine engine) { //TODO: Eventually, create automatic loading of fonts based on an xml file. // For now, just create the load for each font in this function fonts_.Add(FontEnum.Kootenay8, new GameFont("SpriteFonts/Kootenay8", spriteBatch, engine)); fonts_.Add(FontEnum.Kootenay14, new GameFont("SpriteFonts/Kootenay", spriteBatch, engine)); fonts_.Add(FontEnum.Kootenay48, new GameFont("SpriteFonts/Kootenay48", spriteBatch, engine)); fonts_.Add(FontEnum.Lindsey, new GameFont("SpriteFonts/Lindsey", spriteBatch, engine)); fonts_.Add(FontEnum.Miramonte, new GameFont("SpriteFonts/Miramonte", spriteBatch, engine)); fonts_.Add(FontEnum.MiramonteBold, new GameFont("SpriteFonts/MiramonteBold", spriteBatch, engine)); fonts_.Add(FontEnum.Pericles, new GameFont("SpriteFonts/Pericles", spriteBatch, engine)); fonts_.Add(FontEnum.PericlesLight, new GameFont("SpriteFonts/PericlesLight", spriteBatch, engine)); fonts_.Add(FontEnum.Pescadero, new GameFont("SpriteFonts/Pescadero", spriteBatch, engine)); fonts_.Add(FontEnum.PescaderoBold, new GameFont("SpriteFonts/PescaderoBold", spriteBatch, engine)); }
public EngineStateSplash(Engine engine) { engine_ = engine; splash_ = new GameTexture(@"Sprites\splash", engine.spriteBatch_, engine.GraphicsDevice, engine_.Content); }
public ManagedXml(Engine engine) : base() { content_ = new ContentManager(engine.Services); content_.RootDirectory = "Content"; }
/// <summary> /// Constructs a state of gameplay /// </summary> /// <param name="engine">Reference to the engine running the state</param> /// <param name="filepath">Path to level file which should be loaded.</param> public EngineStateGameplay(Engine engine, string filepath) : this(engine, Level.getLevelFromFile(filepath, engine)) { }