Beispiel #1
0
        public static void LoadGame(string filename)
        {
            IFormatter formatter = new BinaryFormatter();
            Stream stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
            SaveGameData gd = (SaveGameData)formatter.Deserialize(stream);
            stream.Close();
            File.Delete(filename);
            //Create a new class of the hero just to set the static texture.

            GameCharacter temp;
            switch (gd.heroRole)
            {
                case Enums.Classes.Mage:
                    temp = new HeroClasses.Mage();
                    break;
                case Enums.Classes.Warrior:
                    temp = new HeroClasses.Warrior();
                    break;
                case Enums.Classes.Rogue:
                    temp = new HeroClasses.Rogue();
                    break;
                case Enums.Classes.Brawler:
                    temp = new HeroClasses.Brawler();
                    break;
                case Enums.Classes.Magus:
                    temp = new HeroClasses.Magus();
                    break;
                case Enums.Classes.Duelist:
                    temp = new HeroClasses.Duelist();
                    break;
                case Enums.Classes.Sentinel:
                    temp = new HeroClasses.Sentinel();
                    break;
                case Enums.Classes.Sorcerer:
                    temp = new HeroClasses.Sorcerer();
                    break;
                case Enums.Classes.Ranger:
                    temp = new HeroClasses.Ranger();
                    break;
                case Enums.Classes.Marksman:
                    temp = new HeroClasses.Marksman();
                    break;
                case Enums.Classes.Berserker:
                    temp = new HeroClasses.Berserker();
                    break;
                case Enums.Classes.Juggernaut:
                    temp = new HeroClasses.Juggernaut();
                    break;
                case Enums.Classes.SpellBlade:
                    temp = new HeroClasses.SpellBlade();
                    break;
                case Enums.Classes.SpellWeaver:
                    temp = new HeroClasses.Spellweaver();
                    break;
                case Enums.Classes.Assassin:
                    temp = new HeroClasses.Assassin();
                    break;
            }
            currentSaveSlot = gd.saveSlot;
            hero = gd.character;
            HeroClasses.Hero.level = gd.level;
            HeroClasses.Hero.jarBarAmount = gd.jarBarAmount;
            HeroClasses.Hero.MaxJarBarAmount = gd.jarBarMax;
            HeroClasses.Hero.heroRole = gd.heroRole;
            UpdateAbilities();
            GeneratedLevel nlevel = new GeneratedLevel(gd.seed, gd.levelComplexity, gd.dungeonLevel);
            currentLevel = nlevel.RetrieveLevel();
            currentLevel.CharacterEntities.Add(hero, currentLevel.GetStartPoint());
            showSaveSlotSelection = false;
            mainMenuOpen = false;
            gameStarted = true;
        }
Beispiel #2
0
        public static void GenerateLevel()
        {
            //levelSeed = enginerand.Next();

            levelComplexity = currentDungeonLevel * 30 + 50;
            //enginerand.Next(currentDungeonLevel*50 + 20) + currentDungeonLevel* 30 + 50;
            if (nextLevel == null)
            {
                nextLevel = new GeneratedLevel(levelSeed++, levelComplexity, currentDungeonLevel);
                currentDungeonLevel = 1;
            }
            currentLevel = nextLevel.RetrieveLevel();
            charIndex = 0;
            nextLevel = new GeneratedLevel(levelSeed++, levelComplexity, currentDungeonLevel);
            Log("Level generated.");
            currentLevel.CharacterEntities.Add(hero, currentLevel.GetStartPoint());
            drawXP = hero.getExperience();
            currentDungeonLevel++;
        }