Ejemplo n.º 1
0
    // start game

    /*
     *  Server only
     *  Called from ServerNetworkManager
     *  Starts new game or loads game from file
     */
    public void ServerStartNewGame(bool isNewGame)
    {
        Debug.Log("ServerStartNewGame");
        if (!isServer)
        {
            throw new Exception("ServerStartNewGame not a server, return");
        }

        string path = null;

        if (isNewGame)
        {
            path = gameApp.startMapsPath + gameApp.GetInputField("MapToLoad");
        }
        else
        {
            path = gameApp.savedGamesPath + gameApp.GetInputField("GameToLoad");
        }
        JObject newGameJson = gameApp.ReadJsonFile(path);

        List <GameApp.PlayerMenu> PlayerMenuList = gameApp.GetAllPlayersFromMenu();

        PlayersFromJsonAndMenu(newGameJson, PlayerMenuList, isNewGame);
        MapFromJson((JObject)newGameJson["map"], isNewGame);
        InfoFromJson((JObject)newGameJson["info"], isNewGame);

        // because "NextTurn" will increment
        currentPlayerIndex -= 1;
        NextTurn();
    }