Ejemplo n.º 1
0
    /// <summary>
    /// Load the specified info.
    /// </summary>
    /// <returns>
    /// If Load Succeed return true , Load Failed return false.
    /// </returns>
    static public bool Load(ViNoSaveInfo info)
    {
        bool levelNameNotMatchThisScene = !info.data.m_LoadedLevelName.Equals(Application.loadedLevelName);

        if (levelNameNotMatchThisScene)
        {
            ViNoDebugger.LogError("SaveData Level Name is : \""
                                  + info.data.m_LoadedLevelName + "\" but this level is \"" + Application.loadedLevelName + "\"");
            return(false);
        }

        // Load Scene from XML.
        if (ViNoSceneManager.Instance != null)
        {
            ViNoSceneManager.Instance.Load(info);
        }

        bool haveLevelName = !string.IsNullOrEmpty(info.data.m_LoadedLevelName);
        bool haveNodeName  = !string.IsNullOrEmpty(info.data.m_NodeName);
        bool isLoad        = (haveLevelName && haveNodeName);

        if (isLoad)
        {
            // Deserialize VM.
            VM vm = VM.Instance;
            if (vm != null)
            {
                vm.ClearTextBuilder();

                SystemUtility.ClearAllTextBoxMessage();

                vm.Deserialize(info.data.m_NodeName);

                GameObject scenarioObj = GetScenarioObject(info);

                // Play from File ?.
                ScenarioNode scenario = scenarioObj.GetComponent <ScenarioNode>();
                scenario.startFromSave = true;
                scenario.PlayFrom(info.data.m_NodeName);
            }

            // Load Sound.
            if (ISoundPlayer.Instance != null)
            {
                ISoundPlayer pl = ISoundPlayer.Instance;
                pl.OnLoad(info.data);
            }

            // Deactivate Selections.
            if (ISelectionsCtrl.Instance != null)
            {
                ISelectionsCtrl.Instance.ChangeActive(false);
            }
        }
        return(isLoad);
    }