public void UpdateGameMode(GameModeModel gameMode)
 {
     if (IsGameMode())
     {
         _context.GameMode.Add(gameMode);
     }
     _context.SaveChanges();
 }
Exemplo n.º 2
0
        private void OnOpenGameModeCommand()
        {
            var selectedPath = PlatformService.ShowSelectFolderDialog();

            if (string.IsNullOrEmpty(selectedPath) || !Directory.Exists(selectedPath))
            {
                return;
            }

            var gameModeModel = GameModeModel.Open(selectedPath);

            Root = new TreeElementViewModel(this, "Root", TreeElementType.Folder);
            var contentElement   = Root.AddChild(new TreeElementViewModel(this, "Content", TreeElementType.Folder));
            var dataElement      = Root.AddChild(new TreeElementViewModel(this, "Data", TreeElementType.Folder));
            var fragmentsElement = Root.AddChild(new TreeElementViewModel(this, "Fragments", TreeElementType.Folder));
            var MapsElement      = Root.AddChild(new TreeElementViewModel(this, "Maps", TreeElementType.Folder));
            var ScriptsElement   = Root.AddChild(new TreeElementViewModel(this, "Scripts", TreeElementType.Folder));

            Root.AddChild(new TreeElementViewModel(this, GameModeModel.GameModeJsonFile, TreeElementType.JsonFile)
            {
                //DetailsViewModel = new GameModeDataViewModel(gameModeModel.GameModeDataModel)
            });

            var texturesElement = contentElement.AddChild(new TreeElementViewModel(this, "Textures", TreeElementType.Folder));

            FillResourcesInHierarchy(texturesElement, gameModeModel.TextureModels, r => new TextureDetailViewModel(r));

            var modelsElement = contentElement.AddChild(new TreeElementViewModel(this, "Models", TreeElementType.Folder));

            FillResourcesInHierarchy(modelsElement, gameModeModel.ModelModels, r => new ModelDetailViewModel(PlatformService, r));

            var movesElement = dataElement.AddChild(new TreeElementViewModel(this, "Moves", TreeElementType.Folder));

            foreach (var move in gameModeModel.MoveModels)
            {
                movesElement.AddChild(new TreeElementViewModel(this, move.Id, TreeElementType.JsonFile)
                {
                    //DetailsViewModel = new MoveDataViewModel(move)
                });
            }

            var pokemonElement = dataElement.AddChild(new TreeElementViewModel(this, "Pokemon", TreeElementType.Folder));

            foreach (var pokemon in gameModeModel.PokemonModels)
            {
                pokemonElement.AddChild(new TreeElementViewModel(this, pokemon.Id, TreeElementType.JsonFile)
                {
                    //DetailsViewModel = new PokemonDataViewModel(pokemon)
                });
            }

            Root.SortChildren();
        }
Exemplo n.º 3
0
        public GameModeInfo(string directory)
        {
            DirectioryName = Path.GetFileName(directory);
            DirectoryPath = Path.Combine(GameModePathProvider.GameModeFolder, DirectioryName);

            IsValid = false;
            string gameModeFile = GameModePathProvider.GetGameModeFile(directory);

            if (File.Exists(gameModeFile))
            {
                try
                {
                    _gameModeModel = DataModel<GameModeModel>.FromFile(gameModeFile);
                    IsValid = true;
                }
                catch (DataLoadException)
                {
                    // todo: somehow log the exception, so that the information of the inner exception is preserved.
                    GameLogger.Instance.Log(MessageType.Error, "An error occurred trying to load the GameMode config file \"" + gameModeFile + "\".");
                }
            }
        }
Exemplo n.º 4
0
        public GameModeInfo(string directory)
        {
            DirectioryName = Path.GetFileName(directory);
            DirectoryPath  = Path.Combine(GameModePathProvider.GameModeFolder, DirectioryName);

            IsValid = false;
            string gameModeFile = GameModePathProvider.GetGameModeFile(directory);

            if (File.Exists(gameModeFile))
            {
                try
                {
                    _gameModeModel = DataModel <GameModeModel> .FromFile(gameModeFile);

                    IsValid = true;
                }
                catch (DataLoadException)
                {
                    // todo: somehow log the exception, so that the information of the inner exception is preserved.
                    GameLogger.Instance.Log(MessageType.Error, "An error occurred trying to load the GameMode config file \"" + gameModeFile + "\".");
                }
            }
        }