Exemple #1
0
 public void saveClick()
 {
     Game.gameState.setSaveTime(DateTime.Now);
     SavedGameController.saveGame(Game.gameState, saveName.text);
     Debug.Log("Saved Game!");
     saveGameContainer.gameObject.SetActive(false);
 }
Exemple #2
0
    public void listGame(FileInfo file)
    {
        GameState       gameState = SavedGameController.loadGame(file.FullName);
        GameObject      listing   = Instantiate(gameDetailsPrefab, gameContainer);
        SaveGameDetails details   = listing.GetComponent <SaveGameDetails>();

        details.init(file.Name.Substring(0, file.Name.Length - 6), gameState);
    }
Exemple #3
0
 private void Awake()
 {
     if (SavedGameController.instance != null)
     {
         Destroy(this.gameObject);
     }
     else
     {
         instance = this;
     }
 }
Exemple #4
0
    // Should be called once before
    public static void PREGAMEupdateGameState(GameState gs)
    {
        if (PV != null && PV.IsMine)
        {
            Debug.Log(Game.myPlayer.getNetworkID() + " ~ Updating GameState...");

            PV.RPC("PREGAMEupdateGameState", RpcTarget.AllBuffered, SavedGameController.serializeGameState(gs));
        }
        else
        {
            Debug.Log(Game.myPlayer.getNetworkID() + " ~ Could not access PhotoView");
        }
    }
Exemple #5
0
    public static void saveGame(GameState gs, string saveName)
    {
        Debug.Log("Saving Game...");
        string path = Application.persistentDataPath + "/" + saveName + ".andor";

        Debug.Log("Under path: " + path);


        //Debug.Log(JSONGameState(gs));

        string saveData = SavedGameController.serializeGameState(gs);

        Debug.Log(saveData);


        File.WriteAllText(path, saveData);

        /*using (StreamWriter file = File.CreateText(path))
         * {
         *  //JsonSerializer serializer = new JsonSerializer();
         *  //serialize object directly into file stream
         *  //serializer.Serialize(file, _data);
         * }*/
    }
 public GameState DeepCopy()
 {
     return(SavedGameController.deserializeGameState(SavedGameController.serializeGameState(this)));
 }