Exemplo n.º 1
0
 public static void RetainNecessaryComponents(StateComponents stateComponents, StateSpaceComponents spaceComponents)
 {
     //Transfer components, then delete all AI-related components and all item related components that aren't in the players' inventories.
     stateComponents.StateSpaceComponents = spaceComponents;
     List<Guid> itemsToKeep = new List<Guid>();
     foreach(Guid id in stateComponents.StateSpaceComponents.Entities.Where(x => (x.ComponentFlags & ComponentMasks.CombatReadyAI) == ComponentMasks.CombatReadyAI).Select(x => x.Id))
     {
         //Change this to only hostile AI when allies need to be implemented.
         stateComponents.StateSpaceComponents.EntitiesToDelete.Add(id);
     }
     foreach (Guid id in stateComponents.StateSpaceComponents.Entities.Where(x => (x.ComponentFlags & ComponentMasks.PickupItem) == ComponentMasks.PickupItem).Select(x => x.Id))
     {
         foreach(Guid player in spaceComponents.Entities.Where(x => (x.ComponentFlags & Component.COMPONENT_PLAYER) == Component.COMPONENT_PLAYER).Select(x => x.Id))
         {
             InventoryComponent inventory = stateComponents.StateSpaceComponents.InventoryComponents[player];
             if(!inventory.Artifacts.Contains(id) && !inventory.Consumables.Contains(id))
             {
                 stateComponents.StateSpaceComponents.EntitiesToDelete.Add(id);
                 break;
             }
             else
             {
                 itemsToKeep.Add(id);
             }
         }
     }
     foreach(Guid id in stateComponents.StateSpaceComponents.Entities.Where(x => (x.ComponentFlags & Component.COMPONENT_PLAYER) != Component.COMPONENT_PLAYER).Select(x => x.Id))
     {
         if(!itemsToKeep.Contains(id))
         {
             stateComponents.StateSpaceComponents.EntitiesToDelete.Add(id);
         }
     }
 }
Exemplo n.º 2
0
        public static void RetainNecessaryComponents(StateComponents stateComponents, StateSpaceComponents spaceComponents)
        {
            //Transfer components, then delete all AI-related components and all item related components that aren't in the players' inventories.
            stateComponents.StateSpaceComponents = spaceComponents;
            List <Guid> itemsToKeep = new List <Guid>();

            foreach (Guid id in stateComponents.StateSpaceComponents.Entities.Where(x => (x.ComponentFlags & ComponentMasks.CombatReadyAI) == ComponentMasks.CombatReadyAI).Select(x => x.Id))
            {
                //Change this to only hostile AI when allies need to be implemented.
                stateComponents.StateSpaceComponents.EntitiesToDelete.Add(id);
            }
            foreach (Guid id in stateComponents.StateSpaceComponents.Entities.Where(x => (x.ComponentFlags & ComponentMasks.PickupItem) == ComponentMasks.PickupItem).Select(x => x.Id))
            {
                foreach (Guid player in spaceComponents.Entities.Where(x => (x.ComponentFlags & Component.COMPONENT_PLAYER) == Component.COMPONENT_PLAYER).Select(x => x.Id))
                {
                    InventoryComponent inventory = stateComponents.StateSpaceComponents.InventoryComponents[player];
                    if (!inventory.Artifacts.Contains(id) && !inventory.Consumables.Contains(id))
                    {
                        stateComponents.StateSpaceComponents.EntitiesToDelete.Add(id);
                        break;
                    }
                    else
                    {
                        itemsToKeep.Add(id);
                    }
                }
            }
            foreach (Guid id in stateComponents.StateSpaceComponents.Entities.Where(x => (x.ComponentFlags & Component.COMPONENT_PLAYER) != Component.COMPONENT_PLAYER).Select(x => x.Id))
            {
                if (!itemsToKeep.Contains(id))
                {
                    stateComponents.StateSpaceComponents.EntitiesToDelete.Add(id);
                }
            }
        }
 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];
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
 public static void RetainPlayerStatistics(StateComponents stateComponents, StateSpaceComponents spaceComponents)
 {
     Guid id = spaceComponents.Entities.Where(x => (x.ComponentFlags & Component.COMPONENT_PLAYER) == Component.COMPONENT_PLAYER).Select(x => x.Id).First();
     SkillLevelsComponent skills = spaceComponents.SkillLevelsComponents[id];
     GameplayInfoComponent gameInfo = spaceComponents.GameplayInfoComponent;
     stateComponents.GameplayInfo = gameInfo;
     stateComponents.PlayerSkillLevels = skills;
 }
Exemplo n.º 6
0
        public static void RetainPlayerStatistics(StateComponents stateComponents, StateSpaceComponents spaceComponents)
        {
            Guid id = spaceComponents.Entities.Where(x => (x.ComponentFlags & Component.COMPONENT_PLAYER) == Component.COMPONENT_PLAYER).Select(x => x.Id).First();
            SkillLevelsComponent  skills   = spaceComponents.SkillLevelsComponents[id];
            GameplayInfoComponent gameInfo = spaceComponents.GameplayInfoComponent;

            stateComponents.GameplayInfo      = gameInfo;
            stateComponents.PlayerSkillLevels = skills;
        }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
 public static void CreateGameplayInfo(StateComponents stateComponents, StateSpaceComponents spaceComponents)
 {
     if (stateComponents != null)
     {
         GameplayInfoComponent info = stateComponents.GameplayInfo;
         info.FloorsReached += 1;
         spaceComponents.GameplayInfoComponent = info;
     }
     else
     {
         //Set GameplayInfo
         spaceComponents.GameplayInfoComponent = new GameplayInfoComponent() { Kills = 0, StepsTaken = 0, FloorsReached = 1, Madness = 0 };
     }
 }
Exemplo n.º 9
0
 public static void CreateGameplayInfo(StateComponents stateComponents, StateSpaceComponents spaceComponents)
 {
     if (stateComponents != null)
     {
         GameplayInfoComponent info = stateComponents.GameplayInfo;
         info.FloorsReached += 1;
         spaceComponents.GameplayInfoComponent = info;
     }
     else
     {
         //Set GameplayInfo
         spaceComponents.GameplayInfoComponent = new GameplayInfoComponent()
         {
             Kills = 0, StepsTaken = 0, FloorsReached = 1, Madness = 0
         };
     }
 }
Exemplo n.º 10
0
        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;
        }
Exemplo n.º 11
0
 public static void LoadPlayerSkillset(StateComponents stateComponents, StateSpaceComponents spaceComponents)
 {
     foreach (Guid id in spaceComponents.Entities.Where(x => (x.ComponentFlags & Component.COMPONENT_PLAYER) == Component.COMPONENT_PLAYER).Select(x => x.Id))
     {
         if (stateComponents != null)
         {
             spaceComponents.SkillLevelsComponents[id] = stateComponents.PlayerSkillLevels;
         }
         else
         {
             spaceComponents.SkillLevelsComponents[id] = new SkillLevelsComponent()
             {
                 CurrentHealth = 100,
                 Health        = 100,
                 Defense       = 50,
                 Accuracy      = 100,
                 Wealth        = 0
             };
         }
     }
 }
Exemplo n.º 12
0
 public static void LoadPlayerSkillset(StateComponents stateComponents, StateSpaceComponents spaceComponents)
 {
     foreach(Guid id in spaceComponents.Entities.Where(x => (x.ComponentFlags & Component.COMPONENT_PLAYER) == Component.COMPONENT_PLAYER).Select(x => x.Id))
     {
         if (stateComponents != null)
         {
             spaceComponents.SkillLevelsComponents[id] = stateComponents.PlayerSkillLevels;
         }
         else
         {
             spaceComponents.SkillLevelsComponents[id] = new SkillLevelsComponent()
             {
                 CurrentHealth = 100,
                 Health = 100,
                 Defense = 50,
                 Accuracy = 100,
                 Wealth = 0
             };
         }
     }
 }
Exemplo n.º 13
0
 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
            };
        }