示例#1
0
        public LevelManager(ContentManager content, SaveData data, int levelType = 1)
        {
            Content = content;

            switch (levelType)
            {
                case 0:
                    levels.Add("RandomTestLevel", new RandomLevel("RandomTestLevel", 80, 60, 32, 32));
                    SetCurrentLevel("RandomTestLevel");
                    break;
                case 1:
                    levels.Add("RandomTestDungeon", new Dungeon(80, 60, 32, 32));
                    SetCurrentLevel("RandomTestDungeon");
                    break;
            }

            em = new EntityManager(data);

            if (data != null)
                LoadSave(data);

            LoadMonsters();
            EntityManager.AddNpc(new Citizen(new Vector2(128, 128)));
            pathSquare = Content.Load<Texture2D>("Test\\square");
        }
 public GamePlayScreen(Game game, GameStateManager manager, SaveData data)
     : base(game, manager)
 {
     ssm = new SpriteSheetManager(GameRef.GraphicsDevice, GameRef.Content);
     tsm = new TileSheetManager(GameRef.GraphicsDevice, GameRef.Content);
     lm = new LevelManager(GameRef.Content, data);
 }
        public EntityManager(SaveData data)
        {
            player = new Player(data.Name, new Vector2(0, 0));
            pathFinder = new Pathfinder(LevelManager.GetCurrentLevel());

            bounds = new DrawableRectangle(ProjectData.Graphics.GraphicsDevice, new Vector2(32, 32), Color.Red, true);
        }
示例#4
0
        /// <summary>
        /// Set up the project elements
        /// </summary>
        /// <param name="content">General content manager so we can load files from different classes</param>
        /// <param name="graphics">Graphics device manager that is created in the main game class</param>
        public ProjectData(ContentManager content, GraphicsDeviceManager graphics)
        {
            Graphics = graphics;
            Content = content;

            parser = new SaveDataParser();  // Initialize the save data parser... duh right?

            try
            {
                lastPerson = new StreamReader(SaveDataParser.myGamesDir + "\\last_person.txt").ReadLine();  // Figure out who the last person was
            }
            catch (FileNotFoundException ex)
            {
                System.Diagnostics.Debug.WriteLine("last_person file does not exist.\n" + ex.ToString());
            }

            if (lastPerson != null)
                cachedSave = SaveDataParser.LoadGameState(lastPerson);  // Make the game able to "Continue" game

            guiBeep = Content.Load<SoundEffect>("Sounds\\gui_beep");      // Basic UI sound when "Up" or "Down" are pressed
            guiSelect = Content.Load<SoundEffect>("Sounds\\gui_select");  // Basic UI sound when "Enter" is pressed

            smallFont = content.Load<SpriteFont>("Fonts\\dialogFont");
        }
示例#5
0
 public void LoadSave(SaveData data)
 {
     EntityManager.player.God = data.GodModeEnabled;
     EntityManager.player.Name = data.Name;
     EntityManager.player.NoClip = data.NoClipEnabled;
     EntityManager.player.Health = data.Health;
     EntityManager.player.Position = data.Position;
     EntityManager.player.Direction = data.Direction;
     EntityManager.player.SuperSpeed = data.SuperSpeedEnabled;
     EntityManager.player.ExperienceLevel = data.ExperienceLevel;
     EntityManager.player.ExperiencePoints = data.ExperiencePoints;
 }
        /// <summary>
        /// Saves a save data state into the list and xml file
        /// </summary>
        /// <param name="saveInfo">Save state to save</param>
        public static void SaveState(SaveData saveInfo)
        {
            bool overridedData = false;
            savedStatus = true;

            // Loop through all saves and if a name already exists, it'll be overidden
            saveStates.ForEach(delegate(SaveData data)
            {
                if (saveInfo.Name.Equals(data.Name))    // if the name exists in the list
                {
                    overridedData = true;   // Trigger overridden data
                    saveStates[saveStates.IndexOf(data)] = saveInfo;
                }
            });

            // If no data has been overridden, append the save state
            if (!overridedData && saveStates.Count < MAXSAVES)
                saveStates.Add(saveInfo);

            Stream dataStream = File.Create(saveDir);
            try
            {
                serializer.Serialize(dataStream, saveStates);   // Serialize the list into the xml file (dataStream)
            }
            finally
            {
                dataStream.Close();
            }
        }