Esempio n. 1
0
        public void SaveGameFile(DataEntities.Game game)
        {
            string fileContents = "";

            fileContents = Newtonsoft.Json.JsonConvert.SerializeObject(game, Newtonsoft.Json.Formatting.Indented);

            var path = System.IO.Path.Combine(_GameDirectory, GetFileNameFromFileType(DataEntities.FileLists.FileList.FileTypes.Game));

            var gameFileHander = new BusinessImplementation.GameFileHandler(this.Game);

            gameFileHander.CreateGameFolder();

            if (File.Exists(path) == false) //Create game file if it doesn't exist
            {
                using (StreamWriter sw = new StreamWriter(path))
                {
                    sw.Write("");
                }
            }

            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(path))
            {
                sw.Write(fileContents);
            }
        }
Esempio n. 2
0
        public void UpdateAllFiles()
        {
            bool hasSaveFile = GameFileHandler.DoesSaveExist();

            var gameHandlerBLL = new BusinessImplementation.GameFileHandler(this.Game);
            var modHandlerBLL  = new BusinessImplementation.ModHandler(this.Game);

            this.Game = gameHandlerBLL.GetGame();

            //Create all necessary files
            gameHandlerBLL.CreateGameFolder();
            modHandlerBLL.CreateModsFolder();
            CreateDefaultFiles();

            //Get File Lists
            var modsFileList = modHandlerBLL.LoadMods();
            var gameFileList = gameHandlerBLL.GetGameFileLists();

            _FileLists.AddRange(modsFileList);
            _FileLists.AddRange(gameFileList);

            //Save first time stuff in game
            if (hasSaveFile == false)
            {
                using (var generateRandomBLL = new BusinessImplementation.GenerateRandomObject(this.Game))
                {
                    this.Game.Races = generateRandomBLL.CreateAllRaces();

                    this.Game.Player = generateRandomBLL.GetPlayer();
                }

                //Testing
                this.Game.Player.Location = new DataEntities.Location()
                {
                    Name         = "Morrowind",
                    Destinations = new List <DataEntities.Destination>()
                    {
                        new DataEntities.Destination()
                        {
                            Name = "bar"
                        },
                        new DataEntities.Destination()
                        {
                            Name = "fat man"
                        }
                    }
                };

                SaveGameFile(Game);
            }
        }