public void LoadLevel(ContentManager content, GraphicsDeviceManager graphics, Camera camera, StateComponents stateComponents, bool createEntities = true) { this.stateComponents = stateComponents; if(stateComponents.StateSpaceComponents != null) { this.stateSpaceComponents = stateComponents.StateSpaceComponents; } sprites = content.Load<Texture2D>(DevConstants.Graphics.SpriteSheet); dungeonSprites = content.Load<Texture2D>(dungeonSpriteFile); messageFont = content.Load<SpriteFont>(DevConstants.Graphics.MessageFont); asciiDisplay = content.Load<SpriteFont>(DevConstants.Graphics.AsciiFont); optionFont = content.Load<SpriteFont>(DevConstants.Graphics.OptionFont); UI = content.Load<Texture2D>(DevConstants.Graphics.UISheet); camera.AttachedToPlayer = true; if(createEntities) { LevelChangeSystem.CreateGameplayInfo(stateComponents, stateSpaceComponents); DungeonCreationSystem.TallGrassGeneration(ref dungeonGrid, dungeonDimensions, stateSpaceComponents.random, freeTiles, stateSpaceComponents); DungeonCreationSystem.WaterGeneration(ref dungeonGrid, dungeonDimensions, stateSpaceComponents.random, freeTiles, stateSpaceComponents, waterTiles); DungeonCreationSystem.CreateDungeonDrops(stateSpaceComponents, dungeonGrid, dungeonDimensions, freeTiles); DungeonCreationSystem.CreateDungeonMonsters(stateSpaceComponents, dungeonGrid, dungeonDimensions, DevConstants.Grid.CellSize, freeTiles); LevelChangeSystem.LoadPlayerSkillset(stateComponents, stateSpaceComponents); LevelChangeSystem.CreateMessageLog(stateSpaceComponents); } mapToPlayer = new DijkstraMapTile[(int)dungeonDimensions.X, (int)dungeonDimensions.Y]; }
public MenuState(IStateSpace space, Camera camera, ContentManager content, GraphicsDeviceManager graphics, IState prevState = null, MouseState mouseState = new MouseState(), GamePadState gamePadState = new GamePadState(), KeyboardState keyboardState = new KeyboardState(), DungeonInfo saveInfo = null) { this.Content = new ContentManager(content.ServiceProvider, "Content"); Graphics = graphics; PrevMouseState = mouseState; PrevGamepadState = gamePadState; PrevKeyboardState = keyboardState; StateComponents = saveInfo == null ? new StateComponents() : saveInfo.stateComponents; SetStateSpace(space, camera, saveInfo == null); previousState = prevState; }
public PlayingState(IStateSpace space, Camera camera, ContentManager content, GraphicsDeviceManager graphics, IState prevState = null, MouseState mouseState = new MouseState(), GamePadState gamePadState = new GamePadState(), KeyboardState keyboardState = new KeyboardState(), DungeonInfo saveInfo = null) { this.Content = new ContentManager(content.ServiceProvider, "Content"); Graphics = graphics; PrevMouseState = mouseState; PrevGamepadState = gamePadState; PrevKeyboardState = keyboardState; SkillLevelsComponent newPlayerStats = new SkillLevelsComponent() { CurrentHealth = 100, Health = 100, Accuracy = 100, Defense = 10, Wealth = 0, MinimumDamage = 1, MaximumDamage = 3, DieNumber = 1 }; StateComponents = saveInfo == null ? new StateComponents() { PlayerSkillLevels = newPlayerStats } : saveInfo.stateComponents; SetStateSpace(space, camera, saveInfo == null); previousState = prevState; }
public PauseState(Camera camera, ContentManager content, GraphicsDeviceManager graphics, IState prevState, MouseState mouseState = new MouseState(), GamePadState gamePadState = new GamePadState(), KeyboardState keyboardState = new KeyboardState()) { this.Content = new ContentManager(content.ServiceProvider, "Content"); Graphics = graphics; PrevMouseState = mouseState; PrevGamepadState = gamePadState; PrevKeyboardState = keyboardState; StateComponents = new StateComponents(); titleText = content.Load<SpriteFont>("Fonts/TitleText"); optionText = content.Load<SpriteFont>("Fonts/OptionText"); optionSelection = 0; menuOptions = new Option[optionsAmount]; Title = "GAME PAUSED"; menuOptions[0] = new Option() { Enabled = true, Message = "OPTIONS" }; menuOptions[1] = new Option() { Enabled = true, Message = "SAVE AND RETURN TO TITLE" }; menuOptions[2] = new Option() { Enabled = true, Message = "UNPAUSE" }; previousState = prevState; }
public TitleState(Camera camera, ContentManager content, GraphicsDeviceManager graphics, MouseState mouseState = new MouseState(), GamePadState gamePadState = new GamePadState(), KeyboardState keyboardState = new KeyboardState()) { this.Content = new ContentManager(content.ServiceProvider, "Content"); Graphics = graphics; PrevMouseState = mouseState; PrevGamepadState = gamePadState; PrevKeyboardState = keyboardState; StateComponents = new StateComponents(); titleText = content.Load<SpriteFont>(DevConstants.Graphics.TitleText); optionText = content.Load<SpriteFont>(DevConstants.Graphics.OptionFont); optionSelection = 0; menuOptions = new Option[optionsAmount]; Title = "PLACEHOLDER TITLE"; menuOptions[0] = new Option() { Enabled = true, Message = "NEW GAME" }; menuOptions[1] = new Option() { Enabled = false, Message = "CONTINUE" }; menuOptions[2] = new Option() { Enabled = true, Message = "OPTIONS" }; menuOptions[3] = new Option() { Enabled = true, Message = "QUIT GAME" }; previousState = null; FileIO.LoadDungeonData(ref DungeonInfo); if (DungeonInfo != null) { menuOptions[1].Enabled = true; } }
public void LoadLevel(ContentManager content, GraphicsDeviceManager graphics, Camera camera, StateComponents stateComponents, bool createEntities = true) { Title = "GAME SETTINGS"; titleText = content.Load<SpriteFont>("Fonts/TitleText"); optionText = content.Load<SpriteFont>("Fonts/OptionText"); smallText = content.Load<SpriteFont>("Fonts/InfoText"); optionSelection = 0; menuOptions = new Option[optionsAmount]; //Resolution Option menuOptions[(int)Options.RESOLUTION] = new Option() { Message = "RESOLUTION: ", OptionsCollection = new List<object>(), Selection = 0 }; //Set to current resolution after populating resolutions foreach (DisplayMode display in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes) { Vector2 resolution = new Vector2(display.Width, display.Height); if(!menuOptions[(int)Options.RESOLUTION].OptionsCollection.Contains(resolution) && resolution.X > 900) { menuOptions[(int)Options.RESOLUTION].OptionsCollection.Add(resolution); } } menuOptions[(int)Options.RESOLUTION].Selection = menuOptions[(int)Options.RESOLUTION].OptionsCollection.FindIndex(x => (Vector2)x == gameSettings.Resolution) > 0 ? menuOptions[(int)Options.RESOLUTION].OptionsCollection.FindIndex(x => (Vector2)x == gameSettings.Resolution) : 0; //Scale Options menuOptions[(int)Options.GRAPHICS_SCALE] = new Option() { Message = "GRAPHICS SCALE: ", OptionsCollection = new List<object>(), Selection = 0 }; //Set to current scale after populating scale resolutions menuOptions[(int)Options.GRAPHICS_SCALE].OptionsCollection.Add(.25f); menuOptions[(int)Options.GRAPHICS_SCALE].OptionsCollection.Add(.5f); menuOptions[(int)Options.GRAPHICS_SCALE].OptionsCollection.Add(.75f); menuOptions[(int)Options.GRAPHICS_SCALE].OptionsCollection.Add(1f); menuOptions[(int)Options.GRAPHICS_SCALE].OptionsCollection.Add(1.25f); menuOptions[(int)Options.GRAPHICS_SCALE].OptionsCollection.Add(1.5f); menuOptions[(int)Options.GRAPHICS_SCALE].OptionsCollection.Add(2f); menuOptions[(int)Options.GRAPHICS_SCALE].Selection = menuOptions[(int)Options.GRAPHICS_SCALE].OptionsCollection.FindIndex(x => Convert.ToDouble(x) == (double)gameSettings.Scale) > 0 ? menuOptions[(int)Options.GRAPHICS_SCALE].OptionsCollection.FindIndex(x => Convert.ToDouble(x) == (double)gameSettings.Scale) : 0; //Borderless Option menuOptions[(int)Options.BORDERLESS] = new Option() { Message = "WINDOW BORDERLESS: ", OptionsCollection = new List<object>(), Selection = 0 }; //Set to current borderless option menuOptions[(int)Options.BORDERLESS].OptionsCollection.Add(true); menuOptions[(int)Options.BORDERLESS].OptionsCollection.Add(false); menuOptions[(int)Options.BORDERLESS].Selection = menuOptions[(int)Options.BORDERLESS].OptionsCollection.FindIndex(x => (bool)x == gameSettings.Borderless); //Vsync Option menuOptions[(int)Options.VSYNC] = new Option() { Message = "VSYNC: ", OptionsCollection = new List<object>(), Selection = 0 }; //Set to current vsync option menuOptions[(int)Options.VSYNC].OptionsCollection.Add(true); menuOptions[(int)Options.VSYNC].OptionsCollection.Add(false); menuOptions[(int)Options.VSYNC].Selection = menuOptions[(int)Options.VSYNC].OptionsCollection.FindIndex(x => (bool)x == gameSettings.Vsync); //Message Filter Option menuOptions[(int)Options.GLOW_FILTER] = new Option() { Message = "SHOW GLOWING BORDERS: ", OptionsCollection = new List<object>(), Selection = 0 }; //Set to current message filter option menuOptions[(int)Options.GLOW_FILTER].OptionsCollection.Add(true); menuOptions[(int)Options.GLOW_FILTER].OptionsCollection.Add(false); menuOptions[(int)Options.GLOW_FILTER].Selection = menuOptions[(int)Options.GLOW_FILTER].OptionsCollection.FindIndex(x => (bool)x == gameSettings.ShowGlow); //Save Changes menuOptions[(int)Options.SAVE_CHANGES] = new Option() { Message = "[SAVE CHANGES]", OptionsCollection = null, Selection = 0 }; //Restore default menuOptions[(int)Options.RESTORE_DEFAULTS] = new Option() { Message = "[RESTORE DEFAULTS]", OptionsCollection = null, Selection = 0 }; //Cancel menuOptions[(int)Options.CANCEL] = new Option() { Message = "[CANCEL]", OptionsCollection = null, Selection = 0 }; }