Ejemplo n.º 1
0
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (SRPGGame game = new SRPGGame())
     {
         game.Run();
     }
 }
Ejemplo n.º 2
0
        public static List <SaveGame> FetchAll(SRPGGame game)
        {
            var files     = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Armadillo\\Save").GetFiles("*.asg", SearchOption.TopDirectoryOnly);
            var savegames = new List <SaveGame>();

            foreach (var f in files)
            {
                int number;
                if (int.TryParse(f.Name.Replace("save", "").Replace(".asg", ""), out number))
                {
                    savegames.Add(Load(game, number));
                }
            }
            return(savegames);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load a specified file number.
        /// </summary>
        /// <param name="game">the game being loaded</param>
        /// <param name="fileNumber">The file number to be loaded.</param>
        public static SaveGame Load(SRPGGame game, int fileNumber)
        {
            var save = new SaveGame()
            {
                Number = fileNumber
            };

            var filename = string.Format(
                "{0}\\Armadillo\\Save\\save{1}.asg",
                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                fileNumber
                );

            if (File.Exists(filename) == false)
            {
                throw new Exception("file does not exist, can't load");
            }

            var r = new BinaryReader(File.OpenRead(filename));

            var guid     = r.ReadBytes(16);
            var filetype = r.ReadInt16();
            var version  = r.ReadInt16();

            // confirm the file is correct
            if (!guid.SequenceEqual(Guid) || filetype != 1 || version != 1)
            {
                throw new Exception("file is not in correct format");
            }

            // skip save date
            r.ReadInt64();
            save.Name     = r.ReadString();
            save.GameTime = r.ReadInt64();
            save.Zone     = r.ReadString();
            save.Door     = r.ReadString();

            // how many party members (16-bit int)
            var partyCount = r.ReadInt16();

            for (var i = 0; i < partyCount; i++)
            {
                // name (length-prefixed string)
                var character = Combatant.FromTemplate(game, "party/" + r.ReadString().ToLower());

                // stat xp levels - dawish + hp/mp (32-bit int)
                character.Stats[Stat.Health]       = r.ReadInt32();
                character.Stats[Stat.Mana]         = r.ReadInt32();
                character.Stats[Stat.Defense]      = r.ReadInt32();
                character.Stats[Stat.Attack]       = r.ReadInt32();
                character.Stats[Stat.Wisdom]       = r.ReadInt32();
                character.Stats[Stat.Intelligence] = r.ReadInt32();
                character.Stats[Stat.Speed]        = r.ReadInt32();
                character.Stats[Stat.Hit]          = r.ReadInt32();

                character.AbilityExperienceLevels.Clear();

                var abilityCount = r.ReadInt16();
                for (var j = 0; j < abilityCount; j++)
                {
                    var ability = Ability.Factory(game, r.ReadString());
                    character.AbilityExperienceLevels.Add(ability, r.ReadInt32());
                }

                character.EquipItem(Item.Factory(game, r.ReadString()));
                character.EquipItem(Item.Factory(game, r.ReadString()));
                //character.EquipItem(Item.Factory(game, r.ReadString()));

                save.Party.Add(character);
            }

            save.Money = r.ReadInt32();


            var inventoryCount = r.ReadInt16();

            for (var i = 0; i < inventoryCount; i++)
            {
                var item = Item.Factory(game, r.ReadString());
                // todo process quantity properly
                r.ReadInt16();
                save.Inventory.Add(item);
            }

            var roomCount = r.ReadInt32();

            for (var i = 0; i < roomCount; i++)
            {
                var roomName     = r.ReadString();
                var roomDataSize = r.ReadInt32();
                var roomData     = r.ReadBytes(roomDataSize);
                save.RoomDetails.Add(roomName, roomData);
            }

            /*
             * // number of battles completed (16-bit int)
             * binaryWriter.Write(BattlesCompleted.Count);
             * // foreach battle
             * foreach (var battle in BattlesCompleted)
             * {
             *  //   battle name (length-prefixed string)
             *  binaryWriter.Write(battle.Key);
             *  //   score (32-bit int)
             *  binaryWriter.Write(battle.Value);
             *
             * }
             * // 64 bit tutorial details
             * binaryWriter.Write(TutorialsCompleted);
             */
            r.Close();

            return(save);
        }