コード例 #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);
            }
        }
コード例 #2
0
        public GameHandler()
        {
            //Where are of the files are saved to
            BusinessImplementation.FileHandler._GamePath = AppDomain.CurrentDomain.BaseDirectory;
            BusinessImplementation.FileHandler.UpdateGamePaths();

            //Creates and updates files if needed
            using (var fileHandlerBLL = new BusinessImplementation.FileHandler(Game))
            {
                fileHandlerBLL.UpdateAllFiles();

                this.Game = fileHandlerBLL.Game; //This is retrieved from the fileHandlerBLL
            }

            //this.Game = BusinessImplementation.FileHandler.LoadGameFile();
        }
コード例 #3
0
        public DataEntities.Game GetGame()
        {
            var ret = new DataEntities.Game();

            //var modPath = Path.Combine(FileHandler.GamePath, "mods", directory);
            var jsonPath = Path.Combine(FileHandler._GameDirectory, "game.json");

            if (File.Exists(jsonPath))
            {
                var cereal = Newtonsoft.Json.JsonConvert.DeserializeObject <DataEntities.Game>(File.ReadAllText(jsonPath));

                ret = cereal;
            }
            else //Couldn't find file
            {
                ret = new DataEntities.Game();
            }

            return(ret);
        }
コード例 #4
0
 public FileHandler(DataEntities.Game game)
 {
     this.Game = game;
 }
コード例 #5
0
 public ProcessInput(DataEntities.Game game)
 {
     this.Game = game;
 }
コード例 #6
0
 public ModHandler(DataEntities.Game game)
 {
     this.Game = game;
 }
コード例 #7
0
 public CommandHandler(DataEntities.Game game)
 {
     this.Game = game;
 }
コード例 #8
0
 public Location(DataEntities.Game game)
 {
     this.Game = game;
 }
コード例 #9
0
 public GenerateRandomObject(DataEntities.Game game)
 {
     this.Game = game;
 }