Esempio n. 1
0
    public void DeleteSave()
    {
        // O ideal é que apareça um dialoig de confirmação

        GlobalProfile.gameSlots.Slots.Remove(id);
        Destroy(gameObject);

        for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
        {
            string name = GetSceneNameByPath(SceneUtility.GetScenePathByBuildIndex(i));
            if (SaveGameSystem.DoesSaveGameExist("slot" + id + "_" + name))
            {
                SaveGameSystem.DeleteSaveGame("slot" + id + "_" + name);
            }
        }
        if (SaveGameSystem.DoesSaveGameExist("slot" + id + "_inventory"))
        {
            SaveGameSystem.DeleteSaveGame("slot" + id + "_inventory");
        }
        if (SaveGameSystem.DoesSaveGameExist("slot" + id + "_messages"))
        {
            SaveGameSystem.DeleteSaveGame("slot" + id + "_messages");
        }


        populate.RemovePage(this);
    }
Esempio n. 2
0
    public void SaveForest()
    {
        //get save file
        SaveGame prev_save;

        if (SaveGameSystem.DoesSaveGameExist(savePath) && SaveGameSystem.LoadGame(savePath) != null)
        {
            prev_save = SaveGameSystem.LoadGame(savePath);
        }

        else
        {
            prev_save        = new SaveGame();
            prev_save.data   = 500;
            prev_save.forest = new TreeData[treeGen.forestSize];
        }


        //update save file
        prev_save.data += 1;
        foreach (Tree tree in treeGen.forest)
        {
            prev_save.forest[tree.potNum] = new TreeData(tree);
        }
        SaveGameSystem.SaveGame(prev_save, savePath);
        Debug.Log("saved forest");
        flashPanel.GetComponent <Flash>().flashFor(0.5f);
    }
Esempio n. 3
0
 // Start is called before the first frame update
 void Start()
 {
     if (SaveGameSystem.DoesSaveGameExist("slot" + GlobalProfile.Slot + "_quadro"))
     {
         LoadQuadroData(SaveGameSystem.LoadGame("slot" + GlobalProfile.Slot + "_quadro") as QuadroData);
     }
 }
Esempio n. 4
0
    public void load()
    {
        SaveGame prev_save;

        if (SaveGameSystem.DoesSaveGameExist(savePath) && SaveGameSystem.LoadGame(savePath) != null)
        {
            prev_save = SaveGameSystem.LoadGame(savePath);
            Debug.Log("found prev save. data: " + prev_save.data + "forestSize: " + prev_save.forest.Length);
            //if no trees are planted in the forest, generate a new bunch
            if (prev_save.forest[0] == null && treeGen.forest[0] == null)
            {
                treeGen.makeAForest();
            }

            else
            {
                treeGen.plantForest(prev_save.forest);
            }
        }
        else
        {
            Debug.Log("no prev save found");
            treeGen.makeAForest();
        }
    }
Esempio n. 5
0
    public void loadAlmanac()
    {
        SaveGame prev_save;

        if (SaveGameSystem.DoesSaveGameExist(savePath) && SaveGameSystem.LoadGame(savePath) != null)
        {
            prev_save = SaveGameSystem.LoadGame(savePath);
            Debug.Log("found prev save. data: " + prev_save.data + "forestSize: " + prev_save.forest.Length);

            //get saved almanac
            if (prev_save.almanac != null)
            {
                for (int i = 0; i < prev_save.almanac.Length; i++)
                {
                    if (prev_save.almanac[i])
                    {
                        Almanac.loadFoundSpecies((Species)Almanac.speciesTypes[i]);
                    }
                }
            }
        }
        else
        {
            Debug.Log("no prev save found");
        }
    }
Esempio n. 6
0
    public static void SaveAlmanac()
    {
        //get save file
        SaveGame prev_save;

        if (SaveGameSystem.DoesSaveGameExist(savePath) && SaveGameSystem.LoadGame(savePath) != null)
        {
            prev_save = SaveGameSystem.LoadGame(savePath);
        }

        else
        {
            prev_save        = new SaveGame();
            prev_save.data   = 500;
            prev_save.forest = new TreeData[treeGen.forestSize];
        }

        //update save file
        prev_save.almanac = new bool[Almanac.speciesTypes.Count];
        for (int i = 0; i < Almanac.speciesTypes.Count; i++)
        {
            if (((Species)Almanac.speciesTypes[i]).found)
            {
                prev_save.almanac[i] = true;
            }
            else
            {
                prev_save.almanac[i] = false;
            }
        }
        SaveGameSystem.SaveGame(prev_save, savePath);
        Debug.Log("saved almanac");
    }
Esempio n. 7
0
 public void LoadGame(TextureManager manager)
 {
     if (SaveGameSystem.DoesSaveGameExist("slot" + Slot + "_messages"))
     {
         messages = SaveGameSystem.LoadGame("slot" + Slot + "_messages") as SerializedMessages;
     }
     LoadInventory(manager);
 }
Esempio n. 8
0
 // Start is called before the first frame update
 void Start()
 {
     if (!SaveGameSystem.DoesSaveGameExist("slot0"))
     {
         NewSave.gameObject.SetActive(true);
     }
     else
     {
         NewSave.gameObject.SetActive(false);
     }
 }
Esempio n. 9
0
 public static void Initialize()
 {
     if (!SaveGameSystem.DoesSaveGameExist("pimba_game"))
     {
         Debug.Log("Save not found, creating one");
         playerProfile = new PlayerProfile();
         SaveGameSystem.SaveGame(playerProfile, "pimba_game");
     }
     else
     {
         SaveGame sg = SaveGameSystem.LoadGame("pimba_game");
         playerProfile = sg as PlayerProfile;
         Debug.Log(playerProfile);
     }
 }
Esempio n. 10
0
        void Start()
        {
            // Show Resume button only when a savegame exists
            if (SaveGameSystem.DoesSaveGameExist(SaveGameSystem.DEFAULT_SAVE_GAME_NAME))
            {
                ResumeButton.gameObject.SetActive(true);
            }

#if UNITY_STANDALONE
            if (SettingsManager.GetWindowState())
            {
                Screen.fullScreenMode = FullScreenMode.FullScreenWindow;
            }
            else
            {
                Screen.fullScreenMode = FullScreenMode.Windowed;
            }
#endif
        }
Esempio n. 11
0
    public static void LoadShop(ShopItemPopulator populator)
    {
        if (shopCache == null || !shopCache.updated)
        {
            if (Application.internetReachability == NetworkReachability.NotReachable)
            {
                //Não tem internet, pega do arquivo de cache;
                if (SaveGameSystem.DoesSaveGameExist("shop"))
                {
                    shopCache         = (ShopStructure)SaveGameSystem.LoadGame("shop");
                    shopCache.updated = false;
                }
            }
            else
            {
                //Tem internet
                FirebaseApp.DefaultInstance.SetEditorDatabaseUrl("https://pimba-ball.firebaseio.com/");
                DatabaseReference reference = FirebaseDatabase.DefaultInstance.GetReference("flamelink");

                //LÊ O SHOP DO FIREBASE
                Task tkk = reference.GetValueAsync().ContinueWith((Task <DataSnapshot> task) =>
                {
                    if (task.IsFaulted)
                    {
                        Debug.LogError(task.Exception);
                    }
                    else if (task.IsCompleted)
                    {
                        DataSnapshot snap = task.Result;
                        Dictionary <string, object> myDict = (Dictionary <string, object>)snap.Value;

                        shopCache = new ShopStructure(myDict, false, true);

                        populator.QueueToExecute(() => {
                            bool res = SaveGameSystem.SaveGame(shopCache, "shop");
                            Debug.Log("Loja carregada, tentei salvar no cache, funcionou? " + res);
                        });
                    }
                });
            }
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        pages = new List <List <SlotUI> >();
        pages.Add(new List <SlotUI>());

        if (SaveGameSystem.DoesSaveGameExist("slots"))
        {
            GlobalProfile.gameSlots = (SlotsData)SaveGameSystem.LoadGame("slots");
        }
        else
        {
            GlobalProfile.gameSlots = new SlotsData();
            SaveGameSystem.SaveGame(GlobalProfile.gameSlots, "slots");
        }


        foreach (int key in GlobalProfile.gameSlots.Slots.Keys)
        {
            Slot slot = GlobalProfile.gameSlots.Slots[key];

            GameObject slotGO = Instantiate(slotsPrefab);
            slotGO.transform.SetParent(slotsGroup.transform, false);
            //slotGO.transform.SetAsFirstSibling();

            SlotUI ui = slotGO.GetComponent <SlotUI>();
            ui.id          = slot.id;
            ui.populate    = this;
            ui.dataInicio  = slot.date;
            ui.cenario     = slot.scenario;
            ui.tempoDeJogo = slot.gameTime;
            ui.fadeEffect  = fadeEffect;

            AddToPage(ui);
            ui.gameObject.SetActive(false);
        }

        LoadPage(0);
    }
    // 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);
    }