Пример #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
        });
    }
Пример #2
0
 //TODO: clean up the models here
 public async Task <GameStateReply> CreateNewGameState(GameStateRequest request)
 {
     return(await _client.CreateNewGameStateAsync(request));
 }
Пример #3
0
        public IActionResult CheckGameStatus([FromBody] GameStateRequest gameStateRequest)
        {
            GameResult result = Functions.GetGameResult(gameStateRequest.Gameboard);

            return(Json(result));
        }
Пример #4
0
        public JsonResult CheckGameStatus([FromBody] GameStateRequest gameStateRequest)
        {
            GameResult result = Functions.GameFunctions.GetGameResult(gameStateRequest.Playground);

            return(Json(result));
        }