Exemplo n.º 1
0
        public async Task <GameViewModel> InsertGame(GameInputModel game)
        {
            var entityGame = await _gameRepository.GetGames(game.Title, game.Producer);

            if (entityGame.Count > 0)
            {
                throw new GameAlreadyExistException();
            }

            var gameInsert = new Game
            {
                Id          = Guid.NewGuid(),
                Title       = game.Title,
                Producer    = game.Producer,
                Price       = game.Price,
                Description = game.Description
            };

            await _gameRepository.InsertGames(gameInsert);

            return(new GameViewModel
            {
                Id = gameInsert.Id,
                Title = gameInsert.Title,
                Producer = gameInsert.Producer,
                Price = gameInsert.Price,
                Description = gameInsert.Description
            });
        }
 public Game(GameInputModel model)
 {
     this.Id       = Guid.NewGuid();
     this.Name     = model.Name;
     this.Producer = model.Producer;
     this.Price    = model.Price;
 }
Exemplo n.º 3
0
        /// <summary>
        /// フィールドに対する入力
        /// </summary>
        /// <param name="model"></param>
        public void GameInput(GameInputModel model)
        {
            if (model.InputMode == InputMode.PlaceTile)
            {
                if (SelectedTile == null)
                {
                    return;
                }
                PlaceTileMode = SelectedTile.PlaceMode;
                switch (PlaceTileMode)
                {
                case PlaceTileMode.PlaceTileSingle:
                    PlaceTileSingle(model);
                    break;

                case PlaceTileMode.PlaceTileDraw:
                    PlaceTileDraw(model);
                    break;

                case PlaceTileMode.PlaceTileRect:
                    PlaceTileRect(model);
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
Exemplo n.º 4
0
        public async Task <GameViewModel> Insert(GameInputModel game)
        {
            var gameEntity = await _gameRepository.Get(game.Name, game.Producer);

            if (gameEntity.Count > 0)
            {
                throw new GameAlreadyRegisteredExeption();
            }

            var gameInsert = new Game
            {
                Id       = Guid.NewGuid(),
                Name     = game.Name,
                Producer = game.Producer,
                Price    = game.Price
            };

            await _gameRepository.Insert(gameInsert);

            return new GameViewModel {
                       Id       = gameInsert.Id,
                       Name     = game.Name,
                       Producer = game.Producer,
                       Price    = game.Price
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// ボタン以外の点でインプットがあったら発火
 /// </summary>
 /// <param name="model"></param>
 public void InputOnGame(GameInputModel model)
 {
     foreach (var gameInputReceivable in _gameInputReceivables)
     {
         gameInputReceivable?.GameInput(model);
     }
 }
Exemplo n.º 6
0
 public void GameInput(GameInputModel model)
 {
     if (model.InputMode == InputMode.MoveCamera)
     {
         MoveCamera(_target.gameObject.transform.position - model.WorldDelta);
     }
 }
Exemplo n.º 7
0
 public static TilePlaceModel PlaceTileRect(this GameInputModel model)
 {
     return(model.ToPlaceModelInternal(
                new Vector3(model.WorldCurrentPos.x, model.WorldCurrentPos.y, 0),
                new Vector3(model.WorldDownPos.x, model.WorldDownPos.y, 0),
                PlaceTileMode.PlaceTileRect));
 }
Exemplo n.º 8
0
    void SetPreview(GameInputModel model)
    {
        _tilemap.ClearAllTiles();
        var placeModel = model.ToPlaceModel(_placeUseCase.PlaceTileMode);

        placeModel.Model = _allowTile;
        _tilemap.SetTileModel(placeModel);
    }
Exemplo n.º 9
0
 void PlaceTileRect(GameInputModel model)
 {
     if (model.State == GameInputState.PointerUp)
     {
         var placeModel = model.ToPlaceModel(PlaceTileMode.PlaceTileRect);
         placeModel.Model = SelectedTile;
         PlaceTile(placeModel);
         SelectedTile = null;
     }
 }
Exemplo n.º 10
0
 private static TilePlaceModel ToPlaceModelInternal(this GameInputModel model, Vector3 spos, Vector3 epos, PlaceTileMode mode)
 {
     return(new TilePlaceModel()
     {
         StartWorldPos = spos,
         EndWorldPos = epos,
         PlaceMode = mode,
         Model = null
     });
 }
Exemplo n.º 11
0
        public async Task <ActionResult> UpdateGame([FromRoute] Guid idGame, [FromRoute] GameInputModel gameInputModel)
        {
            try{
                await _gameService.Update(idGame, gameInputModel);

                return(Ok());
            } catch (GameNotRegisteredException) {
                return(NotFound("Jogo inexistente"));
            }
        }
Exemplo n.º 12
0
        public async Task <ActionResult <GameViewModel> > CreateGame([FromBody] GameInputModel gameInputModel)
        {
            try{
                var game = await _gameService.Insert(gameInputModel);

                return(Ok(game));
            } catch (GameAlreadyRegisteredExeption) {
                return(UnprocessableEntity("Já existe um jogo com este nome para esta produtora"));
            }
        }
Exemplo n.º 13
0
        public async Task <IActionResult> Edit(GameInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            var id = await this.gamesService.Update(input);

            return(this.RedirectToAction("Details", new { area = "", id }));
        }
Exemplo n.º 14
0
        public async Task <IActionResult> Create(GameInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View(input));
            }

            var rootPath = this.environment.WebRootPath;
            var id       = await this.gamesService.Create(input, rootPath);

            return(this.RedirectToAction(nameof(Details), new { id }));
        }
Exemplo n.º 15
0
        public async Task <ActionResult> UpdateGame([FromRoute] Guid idGame, [FromBody] GameInputModel gameInputModel)
        {
            try
            {
                await _gameService.Update(idGame, gameInputModel);

                return(Ok());
            }
            catch (GameNotRegisteredException ex)
            {
                return(NotFound("There is no such game."));
            }
        }
        public async Task <ActionResult <GameViewModel> > Create([FromBody] GameInputModel game)
        {
            try
            {
                var savedGame = await gameService.Create(game);

                return(Ok(savedGame));
            }
            catch (GameAlreadyExistException)
            {
                return(UnprocessableEntity("Já existe um jogo com este nome para esta produtora"));
            }
        }
Exemplo n.º 17
0
        public async Task <ActionResult <GameViewModel> > Post([FromBody] GameInputModel gameInputModel)
        {
            try
            {
                var game = await _gameService.Post(gameInputModel);

                return(Ok(game));
            }
            catch (Exception ex)
            {
                return(UnprocessableEntity("Já existe um jogo com este nome para esta produtora"));
            }
        }
Exemplo n.º 18
0
        public async Task <ActionResult> Put([FromRoute] Guid gameId, [FromBody] GameInputModel gameInputModel)
        {
            try
            {
                await _gameService.Put(gameId, gameInputModel);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(NotFound("Não existe este jogo"));
            }
        }
Exemplo n.º 19
0
        public async Task Update(Guid id, GameInputModel game)
        {
            var savedGame = await gameRepository.Get(id);

            if (savedGame == null)
            {
                throw new GameNotFoundException();
            }

            savedGame.UpdateFromGameInputModel(game);

            await gameRepository.Update(savedGame);
        }
Exemplo n.º 20
0
        /// <summary>
        /// フィールド入力があったとき
        /// </summary>
        /// <param name="model"></param>
        public void GameInput(GameInputModel model)
        {
            //タイプだけ選択解除
            if (model.State == GameInputState.PointerDown)
            {
                foreach (Transform o in _tileList.transform)
                {
                    Destroy(o.gameObject);
                }

                SelectedType = TileType.None;
            }
        }
        public async Task <ActionResult> Update([FromRoute] Guid id, [FromBody] GameInputModel game)
        {
            try
            {
                await gameService.Update(id, game);

                return(Ok());
            }
            catch (GameNotFoundException)
            {
                return(NotFound("Jogo não encontrado"));
            }
        }
Exemplo n.º 22
0
        public async Task <ActionResult <GameViewModel> > InsertGame([FromBody] GameInputModel gameInputModel)
        {
            try
            {
                var game = await _gameService.InsertGame(gameInputModel);

                return(Ok(game));
            }
            catch (GameAlreadyExistException ex)
            {
                return(UnprocessableEntity("There's alreade a game with that name for this producer."));
            }
        }
Exemplo n.º 23
0
 void Inject(
     ITilemapView tilemapView,
     ICameraView cameraView,
     IGameInputManager inputManager,
     IPlaceTileUseCase mapPlaceUseCase,
     ITileSelectView tileSelectView)
 {
     _tilemapView     = tilemapView;
     _cameraView      = cameraView;
     _inputManager    = inputManager;
     _tileSelectView  = tileSelectView;
     _mapPlaceUseCase = mapPlaceUseCase;
     _model           = new GameInputModel();
 }
Exemplo n.º 24
0
        public async Task <GameViewModel> Create(GameInputModel game)
        {
            var gamesWithNameAndProducer = await gameRepository.Get(game.Name, game.Producer);

            if (gamesWithNameAndProducer.Count > 0)
            {
                throw new GameAlreadyExistException();
            }

            var newGame = new Game(game);

            await gameRepository.Create(newGame);

            return(newGame.ToGameViewModel());
        }
Exemplo n.º 25
0
        public async Task Update(Guid id, GameInputModel game)
        {
            var gameEntity = await _gameRepository.Get(id);

            if (gameEntity == null)
            {
                throw new GameNotRegisteredException();
            }

            gameEntity.Name     = game.Name;
            gameEntity.Producer = game.Producer;
            gameEntity.Price    = game.Price;

            await _gameRepository.Update(gameEntity);
        }
Exemplo n.º 26
0
        public async Task Update(Guid id, GameInputModel game)
        {
            var entityGame = await _gameRepository.GetGames(id);

            if (entityGame == null)
            {
                throw new GameAlreadyExistException();
            }

            entityGame.Title    = game.Title;
            entityGame.Producer = game.Producer;
            entityGame.Price    = game.Price;

            await _gameRepository.UpdateGames(entityGame);
        }
Exemplo n.º 27
0
        public async Task <int> Update(GameInputModel input)
        {
            var game = gamesRepository.AllAsNoTrackingWithDeleted().FirstOrDefault(x => x.Id == input.Id);

            if (game == null)
            {
                throw new InvalidOperationException("The game could not be found");
            }

            game = AutoMapperConfig.MapperInstance.Map <Game>(input);

            gamesRepository.Update(game);
            await gamesRepository.SaveChangesAsync();

            // TODO: Fix Update of Genres
            //await genresService.RelateGameWithGenres(game.Id, input.GenreIds);
            return(input.Id);
        }
Exemplo n.º 28
0
        public async Task <int> Create(GameInputModel input, string rootPath)
        {
            var game = AutoMapperConfig.MapperInstance.Map <Game>(input);

            await gamesRepository.AddAsync(game);

            await gamesRepository.SaveChangesAsync();

            await genresService.RelateGameWithGenres(game.Id, input.GenreIds);

            if (input.MediaFiles.Any())
            {
                // TODO: Implement uploading of videos as well
                game.Images = await imageService.SaveImageFiles(input.MediaFiles, game.Id, rootPath);

                await gamesRepository.SaveChangesAsync();
            }

            return(game.Id);
        }
Exemplo n.º 29
0
    public void GameInput(GameInputModel model)
    {
        if (model.InputMode != InputMode.PlaceTile)
        {
            return;
        }
        switch (model.State)
        {
        case GameInputState.PointerDown:
        case GameInputState.Drug:
            SetPreview(model);
            break;

        case GameInputState.PointerUp:
            _tilemap.ClearAllTiles();
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
Exemplo n.º 30
0
        public static TilePlaceModel ToPlaceModel(this GameInputModel model, PlaceTileMode mode)
        {
            switch (mode)
            {
            case PlaceTileMode.PlaceTileSingle:
                return(model.PlaceTileSingle());

                break;

            case PlaceTileMode.PlaceTileDraw:
                return(PlaceTileDraw(model));

                break;

            case PlaceTileMode.PlaceTileRect:
                return(PlaceTileRect(model));

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }