Beispiel #1
0
    public static void saveJson(string fileToWrite)
    {
        pe_SavefileNames pe_saveFileNames = new pe_SavefileNames();

        string[] saveFileNames = LoadJson.loadSaveFileNames().pe_saveFileNames;
        string[] newSaveFileNames;
        if (saveFileNames.Contains(fileToWrite))
        {
            newSaveFileNames = saveFileNames;
        }
        else
        {
            newSaveFileNames = new string[saveFileNames.Length + 1];
            saveFileNames.CopyTo(newSaveFileNames, 0);
            newSaveFileNames[saveFileNames.Length] = fileToWrite;
        }
        pe_saveFileNames.pe_saveFileNames = newSaveFileNames;
        writeToJson(JsonMapper.ToJson(pe_saveFileNames), "saveFileIndex.json");

        pe_GameState gameState = new pe_GameState();

        gameState.eventTransferManager = saveEventTransferManager();
        gameState.players               = savePlayers();
        gameState.board                 = saveBoard();
        gameState.playerCardStack       = savePlayerCardStack();
        gameState.playerDiscardStack    = savePlayerDiscardStack();
        gameState.infectionCardStack    = saveInfectionCardStack();
        gameState.infectionDiscardStack = saveInfectionDiscardStack();
        string jsonResult = JsonMapper.ToJson(gameState);

        Debug.Log(jsonResult);
        writeToJson(jsonResult, fileToWrite + ".json");
    }
Beispiel #2
0
    public static void saveJson(string fileToWrite)
    {
        // write to current filenameIndex file
        pe_SavefileNames pe_savefileNames = new pe_SavefileNames();

        string[] savefileNames = LoadJson.loadSavefileNames().pe_savefilenames;
        string[] newSavefileNames;
        if (savefileNames.Contains(fileToWrite))
        {
            newSavefileNames = savefileNames;
        }
        else
        {
            newSavefileNames = new string[savefileNames.Length + 1];
            savefileNames.CopyTo(newSavefileNames, 0);
            newSavefileNames [savefileNames.Length] = fileToWrite;
        }
        pe_savefileNames.pe_savefilenames = newSavefileNames;
        writeToJson(JsonMapper.ToJson(pe_savefileNames), "savefileIndex.json");

        pe_GameState gameState = new pe_GameState();

        gameState.eventTransferManager = saveEventTransferManager();
        gameState.players           = savePlayers();
        gameState.gameBoard         = saveGameBoard();
        gameState.units             = saveUnits();
        gameState.progressCardStack = saveProgressCardStack();
        string jsonresult = JsonMapper.ToJson(gameState);

        Debug.Log(jsonresult);
        writeToJson(jsonresult, fileToWrite + ".json");
    }
Beispiel #3
0
    public void LoadSavedGame()
    {
        Debug.Log("Menu.cs: <load button clicked>");
        string       selection = GameObject.FindGameObjectWithTag("FileSelection").GetComponent <SaveFileSelect> ().getSaveSelection();
        pe_GameState gameState = LoadJson.loadGameState(selection);

        gm.InitNetwork(gameState.players.total);
        gm.LoadGameMode            = true;
        gm.pe_playerArray          = gameState.players.playerArray;
        gm.pe_gameBoard            = gameState.gameBoard;
        gm.pe_units                = gameState.units.unitsInPlay;
        gm.pe_progressCardStack    = gameState.progressCardStack;
        gm.pe_eventTransferManager = gameState.eventTransferManager;
        SceneManager.LoadScene((int)Scenes.Loading);
    }
Beispiel #4
0
    public void LoadSavedGame()
    {
        Debug.Log("Menu.cs: Load button clicked...");
        string       selection = GameObject.FindGameObjectWithTag("FileSelection").GetComponent <SaveFileSelect>().getSaveSelection();
        pe_GameState gameState = LoadJson.loadGameState(selection);

        gm.initNetwork(gameState.players.total);
        gm.LoadGameMode             = true;
        gm.pe_players               = gameState.players;
        gm.pe_board                 = gameState.board;
        gm.pe_playerCardStack       = gameState.playerCardStack;
        gm.pe_playerDiscardStack    = gameState.playerDiscardStack;
        gm.pe_infectionCardStack    = gameState.infectionCardStack;
        gm.pe_infectionDiscardStack = gameState.infectionDiscardStack;
        gm.pe_eventTransferManager  = gameState.eventTransferManager;
        SceneManager.LoadScene((int)Scenes.Loading);
    }