Exemplo n.º 1
0
    // Get initial game state. Input specifies world size and map generation algorithm.
    public async Task <GameStateResponse> SendAsync(GameStateRequest req)
    {
        var unit = new Unit {
            Id = 0, Pos = new Vector(req.Size / 2, req.Size / 2)
        };

        var tiles = new Tile[req.Size, req.Size];

        if (req.MapType == MapType.HalfWaterHalfLand)
        {
            for (var j = 0; j < req.Size; j++)
            {
                for (var i = 0; i < req.Size; i++)
                {
                    tiles[i, j] = i > req.Size / 2 ? Tile.Water : Tile.Ground;
                }
            }
        }
        var game = new GameState(tiles, new [] { unit });

        UnityEngine.Debug.Log(game.AsciiVisualization());
        return(new GameStateResponse {
            IsSuccess = true, GameState = game
        });
    }
Exemplo n.º 2
0
 //TODO: clean up the models here
 public async Task <GameStateReply> CreateNewGameState(GameStateRequest request)
 {
     return(await _client.CreateNewGameStateAsync(request));
 }
Exemplo n.º 3
0
        public IActionResult CheckGameStatus([FromBody] GameStateRequest gameStateRequest)
        {
            GameResult result = Functions.GetGameResult(gameStateRequest.Gameboard);

            return(Json(result));
        }
Exemplo n.º 4
0
        public JsonResult CheckGameStatus([FromBody] GameStateRequest gameStateRequest)
        {
            GameResult result = Functions.GameFunctions.GetGameResult(gameStateRequest.Playground);

            return(Json(result));
        }