public void OnResetButtonClicked() { QuestionPanel.Show("Do you want to save the game?", () => { // ez a QuestionPanel YesAction-je /* * string fileName = DateTime.Now.ToString("yyyy-dd-M--HH-mm-ss") + ".txt"; * string path = Application.dataPath; * * Debug.Log(path); * * DirectoryInfo di = new DirectoryInfo(Path.Combine(path, "Games")); * if (!di.Exists) * di.Create(); * * * Debug.Log(Path.Combine(di.FullName, fileName)); * Debug.Log("Mentve"); * var sr = File.CreateText(Path.Combine(di.FullName, fileName)); * //sr.WriteLine(JsonUtility.ToJson(tables)); * JsonSerializerSettings settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }; * // sr.WriteLine(JsonConvert.SerializeObject(new MainMenuManager.SerializableObjects(), settings)); * * sr.WriteLine(JsonConvert.SerializeObject(CommandProcessor.Instance.getStackToSave(), settings)); * sr.Close();*/ GameSaveDataHolder gsdh = GameObject.FindGameObjectWithTag("GameSaveDataHolder").GetComponent <GameSaveDataHolder>(); gsdh.SaveToJSON(); CommandProcessor.Instance.CmdResetServerCommand(); LogManager.Instance.RpcShowLogPopup("Game saved"); }, () => { // ez a questionPanel NoAction-je CommandProcessor.Instance.CmdResetServerCommand(); }); }
public void loadGameFromJson(int index) { string dataAsJson = File.ReadAllText(Path.Combine(Application.dataPath, Path.Combine("Games", listOfGames[index].Name))); /* JsonSerializerSettings settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }; * Stack<CommandStackEntry> stack; * stack = JsonConvert.DeserializeObject<Stack<CommandStackEntry>>(dataAsJson, settings); * * // objectsForLoadGame = JsonConvert.DeserializeObject<MainMenuManager.SerializableObjects>(dataAsJson, settings); * List<string> templist = new List<string>(); * Debug.Log(objectsForLoadGame); * * /* foreach (MainMenuPlayer p in objectsForLoadGame.playerList) { * templist.Add(p.playerName); * } * DropdownDialog.Show(templist, "Players", null); * * * CommandProcessor.Instance.setRedoStack(stack); * Debug.Log("delegétmukodik"); */ GameSaveDataHolder gsdh = GameObject.FindGameObjectWithTag("GameSaveDataHolder").GetComponent <GameSaveDataHolder>(); gsdh.LoadFromJSON(dataAsJson); }
void Awake() { if (Instance == null) { Instance = this; // tabledata = GameObject.FindGameObjectWithTag("TableEditorDataHolder").GetComponent<TableEditorDataHolder>(); // players = GameObject.FindGameObjectsWithTag("Player").GetComponent<Player>(); TableEditorDataHolder tedh = GameObject.FindGameObjectWithTag("TableEditorDataHolder").GetComponent <TableEditorDataHolder>(); tables = tedh.getTables(); DontDestroyOnLoad(gameObject); } else { DestroyImmediate(gameObject); } }
public void OnIngameExitPressed() { if (isHosting) { QuestionPanel.Show("Are you sure you want to exit to the lobby?", () => { QuestionPanel.Show("Do you want to save the game?", () => { // ez a QuestionPanel YesAction-je /* * string fileName = DateTime.Now.ToString("yyyy-MM-dd--HH-mm-ss")+".txt"; * string path = Application.dataPath; * * Debug.Log(path); * * DirectoryInfo di = new DirectoryInfo(Path.Combine(path, "Games")); * if (!di.Exists) * di.Create(); * * * Debug.Log(Path.Combine(di.FullName, fileName)); * Debug.Log("Mentve"); * var sr = File.CreateText(Path.Combine(di.FullName, fileName)); * //sr.WriteLine(JsonUtility.ToJson(tables)); * JsonSerializerSettings settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }; * // SerializableObjects so = new SerializableObjects(); * //so.loadForSave(); * // sr.WriteLine(JsonConvert.SerializeObject(CommandProcessor.Instance.getStackToSave(), settings)); * * sr.WriteLine(JsonConvert.SerializeObject(gsdh, settings)); * sr.Close(); */ GameSaveDataHolder gsdh = GameObject.FindGameObjectWithTag("GameSaveDataHolder").GetComponent <GameSaveDataHolder>(); gsdh.SaveToJSON(); lobbyNetworkManager.ChangeToLobbyScene(); HideMainMenu(); lobbyPanel.Show(() => { ShowMainMenu(); lobbyNetworkManager.StopHost(); }); }, () => { // ez a questionPanel NoAction-je lobbyNetworkManager.ChangeToLobbyScene(); HideMainMenu(); lobbyPanel.Show(() => { ShowMainMenu(); lobbyNetworkManager.StopHost(); }); }); }, null); } else { QuestionPanel.Show("Are you sure you want to leave the match?", () => { lobbyNetworkManager.StopClient(); lobbyPanel.Hide(); ShowMainMenu(); }, null); } }