Exemple #1
0
        public void DoGameDelete(DungeonCrawlerGame.CharacterSaveFile gameSave)
        {
            IAsyncResult      result = StorageDevice.BeginShowSelector(PlayerIndex.One, null, null);
            StorageDevice     device = StorageDevice.EndShowSelector(result);
            CharSelectPreview preview;

            if (device != null && device.IsConnected)
            {
                DungeonCrawlerGame.DoDeleteGame(device, gameSave);
                gameSaves.Clear();
                loadGameSaves();
                if ((gameSaves.Count - 1) < selectedGameSave)
                {
                    selectedGameSave = (gameSaves.Count - 1);
                }
                for (int i = 0; i < gameSaves.Count; i++)
                {
                    preview = gameSaves.ElementAt(i);
                    preview.SetPosition(gameSavePosition + (movementOffset * (i - selectedGameSave)));
                    if (i == selectedGameSave)
                    {
                        preview.Color = selected;
                    }
                    else
                    {
                        preview.Color = unselected;
                    }
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// The constructor for the CharacterSelectionScreen
        /// </summary>
        public ContinueNewGameScreen(GraphicsDeviceManager graphics, DungeonCrawlerGame game)
        {
            // Get the game reference
            this.game = game;

            // Set up the viewport vars
            viewport         = graphics.GraphicsDevice.Viewport;
            center           = new Vector2(viewport.Width / 2, viewport.Height / 2);
            gameSavePosition = center - new Vector2(viewport.Width / 4, 0);

            // Set the colors and cursor vars
            selected            = Color.White;
            unselected          = Color.White * (1f / 2);
            controllerDelay     = 100f;
            selectedCursorAlpha = 0.7f;
            cursorMoved         = false;
            players             = new List <CharSelectPlayer>();

            cursorPositions = new Vector2[] { new Vector2(viewport.Width * 0.8f, viewport.Height * 0.2f),
                                              new Vector2(viewport.Width * 0.8f, viewport.Height * 0.4f),
                                              new Vector2(viewport.Width * 0.8f, viewport.Height * 0.6f),
                                              new Vector2(viewport.Width * 0.8f, viewport.Height * 0.8f), };

            // Initialize the sprite arrays
            buttons          = new ImageSprite[2, 3];
            buttonTexts      = new TextSprite[2, 3];
            buttonAggregates = new Aggregate[2, 3];

            // Initialize the sprite batch
            spriteBatch = new SpriteBatch(graphics.GraphicsDevice);

            gameSaves = new List <CharSelectPreview>();

            CharacterSelectionScreen = new CharacterSelectionScreen(graphics, game);
        }
        /// <summary>
        /// The constructor for the CharacterSelectionScreen
        /// </summary>
        public CharacterSelectionScreen(GraphicsDeviceManager graphics, DungeonCrawlerGame game)
        {
            // Get the game reference
            this.game = game;

            // Set up the viewport vars
            viewport = graphics.GraphicsDevice.Viewport;
            center   = new Vector2(viewport.Width / 2, viewport.Height / 2);

            // Set the colors and cursor vars
            selected            = Color.White;
            unselected          = Color.White * (1f / 2);
            controllerDelay     = 100f;
            selectedCursorAlpha = 0.7f;
            cursorMoved         = false;

            selectionDone = false;

            // Initialize the sprite arrays
            buttons          = new ImageSprite[2, 3];
            buttonTexts      = new TextSprite[2, 3];
            buttonAggregates = new Aggregate[2, 3];

            // Initialize the sprite batch
            spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
        }
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (DungeonCrawlerGame game = new DungeonCrawlerGame())
     {
         game.Run();
     }
 }
Exemple #5
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (DungeonCrawlerGame game = new DungeonCrawlerGame())
     {
         game.Run();
     }
 }
 /// <summary>
 /// Constructs a new DungeonCrawler game instance
 /// </summary>
 public DungeonCrawlerGame()
 {
     game     = this;
     graphics = new GraphicsDeviceManager(this);
     graphics.PreferredBackBufferWidth  = 1280;
     graphics.PreferredBackBufferHeight = 720;
     Content.RootDirectory = "Content";
     Components.Add(new GamerServicesComponent(this));
 }
Exemple #7
0
        public void DoGameSave(DungeonCrawlerGame.CharacterSaveFile gameSave)
        {
            IAsyncResult  result = StorageDevice.BeginShowSelector(PlayerIndex.One, null, null);
            StorageDevice device = StorageDevice.EndShowSelector(result);

            if (device != null && device.IsConnected)
            {
                DungeonCrawlerGame.DoSaveGame(device, gameSave);
            }
        }
Exemple #8
0
        public DungeonCrawlerGame.CharacterSaveFile LoadGameSave(CharSelectPreview preview)
        {
            IAsyncResult  result = StorageDevice.BeginShowSelector(PlayerIndex.One, null, null);
            StorageDevice device = StorageDevice.EndShowSelector(result);

            if (device != null && device.IsConnected)
            {
                return(DungeonCrawlerGame.DoLoadGame(device, preview.fileName));
            }
            return(new DungeonCrawlerGame.CharacterSaveFile());
        }
        /// <summary>
        /// Go through the components and save the pertinent information for the entity id
        /// Use this when saving the character in-game (possibly from a save menu or via autosaving)
        /// By: Joseph Shaw
        /// </summary>
        /// <param name="entityId">The entityID of the character we are saving</param>
        public static void SavePlayer(uint entityId)
        {
            DungeonCrawlerGame.CharacterSaveFile gameSave;
            PlayerInfo info      = game.PlayerInfoComponent[entityId];
            Equipment  equipment = game.EquipmentComponent[entityId];

            IAsyncResult  result = StorageDevice.BeginShowSelector(PlayerIndex.One, null, null);
            StorageDevice device = StorageDevice.EndShowSelector(result);

            if (device != null && device.IsConnected)
            {
                // Load file for this entityID
                gameSave = DoLoadGame(device, info.FileName);

                // Populate save info
                // Level information
                gameSave.level      = info.Level;
                gameSave.experience = info.Experience;

                // Other skills/stats
                gameSave.stats  = game.StatsComponent[entityId];
                gameSave.health = info.MaxHealth;
                gameSave.psi    = info.MaxPsiOrFatigue;
                gameSave.skill1 = info.skill1;
                gameSave.skill2 = info.skill2;
                gameSave.skill3 = info.skill3;
                gameSave.skill4 = info.skill4;
                gameSave.skill5 = info.skill5;
                gameSave.skill6 = info.skill6;
                gameSave.skill7 = info.skill7;
                gameSave.skill8 = info.skill8;
                gameSave.skill9 = info.skill9;

                gameSave.skillInfo = game.PlayerSkillInfoComponent[entityId];

                // Inventory Quantities and Weapon
                gameSave.healthPotions = equipment.HealthPotsQty;
                gameSave.manaPotions   = equipment.PsiPotsQty;
                gameSave.pogs          = equipment.PogsQty;
                gameSave.weaponType    = (int)equipment.WeaponID;

                // Quest information
                gameSave.quests = DungeonCrawlerGame.game.Quests;

                // Resave file
                DungeonCrawlerGame.DoSaveGame(device, gameSave, true);
            }
        }
Exemple #10
0
        public void loadGameSaves()
        {
            // Create the "New Game" slot
            CharSelectPreview charPreview = new CharSelectPreview(game.Content.Load <Texture2D>("Spritesheets/charSelectNewGame"), gameSavePosition, spriteFont, "New Game", " ", selected, "");

            gameSaves.Add(charPreview);

            IAsyncResult  result = StorageDevice.BeginShowSelector(PlayerIndex.One, null, null);
            StorageDevice device = StorageDevice.EndShowSelector(result);

            DungeonCrawlerGame.MasterSaveFile masterSaveFile;
            List <DungeonCrawlerGame.CharacterSaveFilePreview> listCSF = new List <DungeonCrawlerGame.CharacterSaveFilePreview>();

            if (device != null && device.IsConnected)
            {
                masterSaveFile = DungeonCrawlerGame.GetMasterSaveFile(device);
                if (masterSaveFile.charFiles == null)
                {
                    charPreview.fileNumber = 1;
                    charPreview.fileName   = "CharSave1";
                }
                else
                {
                    charPreview.fileNumber = masterSaveFile.charFiles.Count + 1;
                    charPreview.fileName   = "charSave" + charPreview.fileNumber;
                    //masterSaveFile.charFiles.Clear();
                    //DungeonCrawlerGame.SaveMasterFile(device, masterSaveFile);

                    foreach (DungeonCrawlerGame.CharacterSaveFilePreview csf in masterSaveFile.charFiles)
                    {
                        if (csf.charSprite == "" || csf.charSprite == null)
                        {
                            masterSaveFile.charFiles.Remove(csf);
                            DungeonCrawlerGame.SaveMasterFile(device, masterSaveFile);
                            break;
                        }
                        else
                        {
                            charPreview = LoadPreview(csf);
                            gameSaves.Add(charPreview);
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Go through the components and save the pertinent information for the entity id
        /// Use this when saving the character in-game (possibly from a save menu or via autosaving)
        /// </summary>
        /// <param name="entityId">The entityID of the character we are saving</param>
        public static void SavePlayer(uint entityId)
        {
            DungeonCrawlerGame.CharacterSaveFile gameSave;
            PlayerInfo info = game.PlayerInfoComponent[entityId];

            IAsyncResult  result = StorageDevice.BeginShowSelector(PlayerIndex.One, null, null);
            StorageDevice device = StorageDevice.EndShowSelector(result);

            if (device != null && device.IsConnected)
            {
                // Load file for this entityID
                gameSave = DoLoadGame(device, info.FileName);

                // Redo save info
                gameSave.stats  = game.StatsComponent[entityId];
                gameSave.health = info.Health;
                gameSave.psi    = info.Psi;
                //gameSave.Level = ?

                // Resave file
                DungeonCrawlerGame.DoSaveGame(device, gameSave);
            }
        }
        /// <summary>
        /// The constructor for the CharacterSelectionScreen
        /// </summary>
        public CharacterSelectionScreen(GraphicsDeviceManager graphics, DungeonCrawlerGame game)
        {
            // Get the game reference
            this.game = game;

            // Set up the viewport vars
            viewport = graphics.GraphicsDevice.Viewport;
            center = new Vector2(viewport.Width / 2, viewport.Height / 2);

            // Set the colors and cursor vars
            selected = Color.White;
            unselected = Color.White * (1f / 2);
            controllerDelay = 100f;
            selectedCursorAlpha = 0.7f;
            cursorMoved = false;

            selectionDone = false;

            // Initialize the sprite arrays
            buttons = new ImageSprite[2, 3];
            buttonTexts = new TextSprite[2, 3];
            buttonAggregates = new Aggregate[2, 3];

            // Initialize the sprite batch
            spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
        }
 /// <summary>
 /// Constructs a new DungeonCrawler game instance
 /// </summary>
 public DungeonCrawlerGame()
 {
     game = this;
     graphics = new GraphicsDeviceManager(this);
     graphics.PreferredBackBufferWidth = 1280;
     graphics.PreferredBackBufferHeight = 720;
     Content.RootDirectory = "Content";
     Components.Add(new GamerServicesComponent(this));
 }
        /// <summary>
        /// The constructor for the CharacterSelectionScreen
        /// </summary>
        public ContinueNewGameScreen(GraphicsDeviceManager graphics, DungeonCrawlerGame game)
        {
            // Get the game reference
            this.game = game;

            // Set up the viewport vars
            viewport = graphics.GraphicsDevice.Viewport;
            center = new Vector2(viewport.Width / 2, viewport.Height / 2);
            gameSavePosition = center - new Vector2(viewport.Width / 4, 0);

            // Set the colors and cursor vars
            selected = Color.White;
            unselected = Color.White * (1f / 2);
            controllerDelay = 100f;
            selectedCursorAlpha = 0.7f;
            cursorMoved = false;
            players = new List<CharSelectPlayer>();

            cursorPositions = new Vector2[] { new Vector2(viewport.Width * 0.8f, viewport.Height * 0.2f),
                                              new Vector2(viewport.Width * 0.8f,viewport.Height * 0.4f),
                                              new Vector2(viewport.Width * 0.8f,viewport.Height * 0.6f),
                                              new Vector2(viewport.Width * 0.8f,viewport.Height * 0.8f), };

            // Initialize the sprite arrays
            buttons = new ImageSprite[2, 3];
            buttonTexts = new TextSprite[2, 3];
            buttonAggregates = new Aggregate[2, 3];

            // Initialize the sprite batch
            spriteBatch = new SpriteBatch(graphics.GraphicsDevice);

            gameSaves = new List<CharSelectPreview>();

            CharacterSelectionScreen = new CharacterSelectionScreen(graphics, game);
        }
Exemple #15
0
        /// <summary>
        /// Loads a new level asynchronously
        /// </summary>
        /// <param name="level">The name of the level to load</param>
        public void LoadLevel(string level)
        {
            Loading = true;
            DungeonCrawlerGame game = (DungeonCrawlerGame)this.game;

            ThreadStart threadStarter = delegate
            {
                if (!LoadedTilemaps.ContainsKey(level))
                {
                    CurrentMap = game.Content.Load <Tilemap>("Tilemaps/" + level);
                    CurrentMap.LoadContent(game.Content);

                    // Load the background music
                    //if (CurrentMap.MusicTitle != null && CurrentMap.MusicTitle != "")
                    //{
                    //    CurrentSong = game.Content.Load<Song>("Music/" + CurrentMap.MusicTitle);
                    //}
                    //else
                    //{
                    //    CurrentSong = null;
                    //}
                    currentRoomID = game.RoomFactory.CreateRoom(level, CurrentMap.Width, CurrentMap.Height, CurrentMap.TileWidth, CurrentMap.TileHeight, CurrentMap.WallWidth, level);
                    Room room = game.RoomComponent[currentRoomID];



                    for (int i = 0; i < CurrentMap.GameObjectGroupCount; i++)
                    {
                        for (int j = 0; j < CurrentMap.GameObjectGroups[i].GameObjectData.Count(); j++)
                        {
                            GameObjectData goData   = CurrentMap.GameObjectGroups[i].GameObjectData[j];
                            Vector2        position = new Vector2(goData.Position.Center.X, goData.Position.Center.Y);

                            uint entityID = uint.MaxValue;


                            switch (goData.Category)
                            {
                            case "PlayerSpawn":
                                room.playerSpawns.Add(goData.properties["SpawnName"], new Vector2(goData.Position.X, goData.Position.Y));
                                break;

                            case "Enemy":
                                switch (goData.Type)
                                {
                                case "MovingTarget":
                                    entityID = game.EnemyFactory.CreateEnemy(EnemyFactoryType.MovingTarget, new Position
                                    {
                                        Center = new Vector2(goData.Position.X, goData.Position.Y), RoomID = currentRoomID, Radius = 32
                                    });
                                    break;

                                case "StationaryTarget":
                                    entityID = game.EnemyFactory.CreateEnemy(EnemyFactoryType.MovingTarget, new Position
                                    {
                                        Center = new Vector2(goData.Position.X, goData.Position.Y), RoomID = currentRoomID, Radius = 32
                                    });
                                    break;

                                default:
                                    break;
                                }
                                break;

                            case "NPC":
                                entityID = game.NPCFactory.CreateNPC((NPCName)Enum.Parse(typeof(NPCName), goData.Type), new Position
                                {
                                    Center = new Vector2(goData.Position.X, goData.Position.Y), RoomID = currentRoomID, Radius = 32
                                });
                                break;

                            case "Trigger":
                                switch (goData.Type)
                                {
                                case "Door":
                                    entityID = game.DoorFactory.CreateDoor(currentRoomID, goData.properties["DestinationRoom"], goData.properties["DestinationSpawnName"], goData.Position);
                                    break;

                                case "Wall":
                                    entityID = game.WallFactory.CreateWall(currentRoomID, goData.Position);
                                    break;

                                default:
                                    break;
                                }
                                break;
                            }
                            if (goData.properties.Keys.Contains("id"))
                            {
                                room.idMap.Add(goData.properties["id"], entityID);
                                room.targetTypeMap.Add(goData.properties["id"], goData.Type);
                            }
                        }
                    }

                    game.RoomComponent[currentRoomID] = room;

                    //// Load the game objects
                    //for (int i = 0; i < CurrentMap.GameObjectGroupCount; i++)
                    //{
                    //    for (int j = 0; j < CurrentMap.GameObjectGroups[i].GameObjectData.Count(); j++)
                    //    {
                    //        GameObjectData goData = CurrentMap.GameObjectGroups[i].GameObjectData[j];
                    //        Vector2 position = new Vector2(goData.Position.Center.X, goData.Position.Center.Y);
                    //        GameObject go;

                    //        switch (goData.Category)
                    //        {
                    //            case "PlayerStart":
                    //                ScrollingShooterGame.Game.Player.Position = position;
                    //                ScrollingShooterGame.Game.Player.LayerDepth = CurrentMap.GameObjectGroups[i].LayerDepth;
                    //                scrollDistance = -2 * position.Y + 300;
                    //                break;

                    //            case "LevelEnd":
                    //                break;

                    //            case "Powerup":
                    //                go = ScrollingShooterGame.GameObjectManager.CreatePowerup((PowerupType)Enum.Parse(typeof(PowerupType), goData.Type), position);
                    //                CurrentMap.GameObjectGroups[i].GameObjectData[j].ID = go.ID;
                    //                go.LayerDepth = CurrentMap.GameObjectGroups[i].LayerDepth;
                    //                go.ScrollingSpeed = CurrentMap.GameObjectGroups[i].ScrollingSpeed;
                    //                break;

                    //            case "Enemy":
                    //                go = ScrollingShooterGame.GameObjectManager.CreateEnemy((EnemyType)Enum.Parse(typeof(EnemyType), goData.Type), position);
                    //                CurrentMap.GameObjectGroups[i].GameObjectData[j].ID = go.ID;
                    //                go.LayerDepth = CurrentMap.GameObjectGroups[i].LayerDepth;
                    //                go.ScrollingSpeed = CurrentMap.GameObjectGroups[i].ScrollingSpeed;
                    //                break;
                    //            case "Boss":
                    //                go = ScrollingShooterGame.GameObjectManager.CreateBoss((BossType)Enum.Parse(typeof(BossType), goData.Type), position);
                    //                CurrentMap.GameObjectGroups[i].GameObjectData[j].ID = go.ID;
                    //                go.LayerDepth = CurrentMap.GameObjectGroups[i].LayerDepth;
                    //                go.ScrollingSpeed = CurrentMap.GameObjectGroups[i].ScrollingSpeed;
                    //                break;
                    //        }
                    //    }
                    //}

                    LoadedTilemaps.Add(level, CurrentMap);
                }
                else
                {
                    Room newRoom = game.RoomComponent.FindRoom(level);
                    if (newRoom.Tilemap == level)
                    {
                        CurrentMap    = LoadedTilemaps[level];
                        currentRoomID = newRoom.EntityID;
                    }
                }


                // Mark level as loaded
                Loading = false;
            };

            Thread loadingThread = new Thread(threadStarter);

            loadingThread.Start();
        }
 public CharSelectPreview LoadPreview(DungeonCrawlerGame.CharacterSaveFilePreview saveFilePreview)
 {
     CharSelectPreview charSelectPreview;
     Texture2D charSprite = game.Content.Load<Texture2D>(saveFilePreview.charSprite);
     string charSaveFile = saveFilePreview.CharacterSaveFile;
     string charType = saveFilePreview.characterType;
     string level = "Level: " + saveFilePreview.Level.ToString();
     Vector2 position = gameSavePosition + (movementOffset * gameSaves.Count);
     charSelectPreview = new CharSelectPreview(charSprite, position, spriteFont, charType, level, unselected, charSaveFile);
     return charSelectPreview;
 }
        public void DoGameSave(DungeonCrawlerGame.CharacterSaveFile gameSave)
        {
            IAsyncResult result = StorageDevice.BeginShowSelector(PlayerIndex.One, null, null);
            StorageDevice device = StorageDevice.EndShowSelector(result);

            if (device != null && device.IsConnected)
            {
                DungeonCrawlerGame.DoSaveGame(device, gameSave, true);
            }
        }
        public void DoGameDelete(DungeonCrawlerGame.CharacterSaveFile gameSave)
        {
            IAsyncResult result = StorageDevice.BeginShowSelector(PlayerIndex.One, null, null);
            StorageDevice device = StorageDevice.EndShowSelector(result);
            CharSelectPreview preview;

            if (device != null && device.IsConnected)
            {
                DungeonCrawlerGame.DoDeleteGame(device, gameSave);
                gameSaves.Clear();
                loadGameSaves();
                if ((gameSaves.Count - 1) < selectedGameSave)
                    selectedGameSave = (gameSaves.Count - 1);
                for (int i = 0; i < gameSaves.Count; i++)
                {
                    preview = gameSaves.ElementAt(i);
                    preview.SetPosition(gameSavePosition + (movementOffset * (i - selectedGameSave)));
                    if (i == selectedGameSave)
                        preview.Color = selected;
                    else
                        preview.Color = unselected;
                }
            }
        }