// Start is called before the first frame update
    void Start()
    {
        string scenarioName = GlobalProfile.GetCurrentSceneName();

        GlobalProfile.getInstance().LoadGame(textureManager);
        GlobalProfile.getInstance().addItem(new InventoryItem(cenario_pista, scenarioName, textureManager.GetSpritePista(cenario_pista), cenario_desc));
        GlobalProfile.getInstance().SaveGame();
        //Carrega dados do cenĂ¡rio
        if (SaveGameSystem.DoesSaveGameExist("slot" + GlobalProfile.Slot + "_" + scenarioName))
        {
            scenarioData = (ScenarioData)SaveGameSystem.LoadGame("slot" + GlobalProfile.Slot + "_" + scenarioName);

            if (scenarioData != null)
            {
                //Limpando os personagens e instanciando de novo
                foreach (Transform child in personagens_folder.transform)
                {
                    GameObject.Destroy(child.gameObject);
                }

                for (int i = 0; i < scenarioData.characters.Count; i++)
                {
                    GameObject character = Instantiate(personagemPrefab);
                    character.transform.SetParent(personagens_folder.transform, false);
                    character.GetComponent <SpeechableCharacter>().LoadData(scenarioData.characters[i], speechManager, this);
                }

                //Limpando pistas e instanciando de novo
                foreach (Transform child in pistas_folder.transform)
                {
                    GameObject.Destroy(child.gameObject);
                }

                for (int i = 0; i < scenarioData.pistas.Count; i++)
                {
                    GameObject pista = Instantiate(pistaPrefab);
                    pista.transform.SetParent(pistas_folder.transform, false);
                    pista.GetComponent <PistaItem>().LoadData(scenarioData.pistas[i], speechManager, this);
                }

                //Limpando exits e instanciando de novo
                foreach (Transform child in exits_folder.transform)
                {
                    GameObject.Destroy(child.gameObject);
                }

                for (int i = 0; i < scenarioData.exits.Count; i++)
                {
                    GameObject exit = Instantiate(exitPrefab);
                    exit.transform.SetParent(exits_folder.transform, false);
                    exit.GetComponent <ExitPoint>().LoadData(scenarioData.exits[i], this, speechManager);
                }
            }
        }


        if (GlobalProfile.getInstance().dialogIgnition != null)
        {
            speechManager.OpenText(GlobalProfile.getInstance().dialogIgnition);
        }

        //string output = JsonUtility.ToJson(CreateScenarioData(),true);
        //Debug.Log(output);
    }
Example #2
0
 public void Exit()
 {
     //TODO: Salva cenĂ¡rio
     if (data.enabled)
     {
         ScenarioData data = manager.CreateScenarioData();
         bool         succ = SaveGameSystem.SaveGame(data, "slot" + GlobalProfile.Slot + "_" + GlobalProfile.GetCurrentSceneName());
         GlobalProfile.getInstance().SaveGame();
         Cursor.SetCursor(null, hotSpot, cursorMode);
         manager.fadeEffect.ExitScene(this.data.exitPoint);
     }
 }
    public void SaveGame()
    {
        ScenarioData data = CreateScenarioData();
        bool         succ = SaveGameSystem.SaveGame(data, "slot" + GlobalProfile.Slot + "_" + GlobalProfile.GetCurrentSceneName());

        GlobalProfile.getInstance().SaveGame();
    }