示例#1
0
    /// <summary>
    /// Event, called from Unity.
    /// Save/Load game
    /// </summary>
    public void SaveGame()
    {
        if (m_isItSave)
        {
            Game   gm   = new Game();
            string json = gm.Save();
            string path = "";
#if UNITY_WEBGL
            path = m_inputFileName.text;
            NetworkManager.SetText(MainMenu.m_sUserName, path, json);
#else
            path = Application.persistentDataPath + "/" + m_inputFileName.text + ".sav";
            if (File.Exists(path))
            {
                File.Delete(path);
            }
            File.WriteAllText(path, json);
#endif
        }
        else
        {
            if (!MainScript.m_isItInitialized)
            {
                _ms.StartGame();
            }
            Load();
        }
        MainScript.m_sIsButtonPressed = false;
        Resume();
        _ms.CloseMainMenu();
        if (m_previous != null && !ReferenceEquals(m_previous.gameObject, null))
        {
            m_previous.SetActive(false);
        }
    }
示例#2
0
 /// <summary>
 /// Close mainMenu and return to the game
 /// </summary>
 void Resume()
 {
     _ms.CloseMainMenu();
     m_sActiveMenu = null;
 }