void Load()
 {
     if (SaveLoadSystem.SaveExists("CollectedItems"))
     {
         CollectedItems = SaveLoadSystem.Load <HashSet <string> >("CollectedItems");
     }
 }
Пример #2
0
    public void CompleteLevel()
    {
        Time.timeScale = 0;
        EndLevelScreen.gameObject.SetActive(true);

        if (playerStats.Lives == 3)
        {
            levelScore           += 1;
            threeLivesStar.sprite = activatedStarImagePrefab;
        }
        if (bonusActivator.activated)
        {
            levelScore += 1;
            activatedBonusStar.sprite = activatedStarImagePrefab;
        }

        saveLoadSystem.Load();

        //levelNumber starts at 1, so using levelScores.Count works.

        saveLoadSystem.gameData.levelScores[levelNumber] = levelScore;
        if (!saveLoadSystem.gameData.UnlockedLevelNames.Contains(sceneSwitcher.nextLevelSceneName))
        {
            saveLoadSystem.gameData.UnlockedLevelNames.Add(sceneSwitcher.nextLevelSceneName);
        }
        saveLoadSystem.Save();
    }
Пример #3
0
        // Load the game
        public void LoadGame()
        {
            SaveLoadObject loadedData = saveLoad.Load();

            // Update player
            GameObject player = GameObject.FindGameObjectWithTag("Player");

            player.transform.SetPositionAndRotation(loadedData.player.position, loadedData.player.rotation);
            player.GetComponent <PlayerHealth>().SetHealth(loadedData.player.health);
            ScoreManager.score = loadedData.player.score;

            //Update enemies
            // First remove existing enemies
            EnemyHealth[] enemies = GameObject.FindObjectsOfType <EnemyHealth>();
            foreach (EnemyHealth enemy in enemies)
            {
                Destroy(enemy.gameObject);
            }
            // Add saved enemies
            foreach (EnemyInfo newEnemy in loadedData.enemy)
            {
                GameObject prefab        = Resources.Load("Prefabs/" + newEnemy.prefabName) as GameObject;
                GameObject enemyInstance = Instantiate(prefab, newEnemy.position, newEnemy.rotation);
                enemyInstance.GetComponent <EnemyHealth>().SetHealth(newEnemy.health);
                // had to add that because when loaded it would add additional score if saved whild enemy killed
                enemyInstance.GetComponent <EnemyHealth>().yieldscore = newEnemy.yieldScore;
            }
        }
Пример #4
0
    private void OnEnable()
    {
        button = gameObject.GetComponent <Button>();

        if (!loadsCutscene)
        {
            foreach (Image image in levelStars)
            {
                image.gameObject.SetActive(false);
            }
        }

        button.onClick.AddListener(LoadAssociatedScene);

        saveLoadSystem.Load();

        if (saveLoadSystem.gameData.UnlockedLevelNames.Contains(nameOfLevelToLoad))
        {
            if (!loadsCutscene)
            {
                for (int i = 0; i < saveLoadSystem.gameData.levelScores[levelNumberToLoad]; i++)
                {
                    levelStars[i].gameObject.SetActive(true);
                }
            }
        }
        else
        {
            if (levelNumberToLoad != 0)
            {
                button.interactable = false;
            }
        }
    }
Пример #5
0
 void LoadInvetory()
 {
     if (SaveLoadSystem.SaveExists("Inventory"))
     {
         GiveItems(SaveLoadSystem.Load <List <Item> >("Inventory"));
     }
 }
Пример #6
0
    private void Start()
    {
        subject = Subject.getInstance();

        if (!observerDifficultAI.observerState && !observerVoice.observerState)
        {
            new observerDifficultAI(subject);
            new observerVoice(subject);
        }

        if (!File.Exists(Application.persistentDataPath + "save.binary"))
        {
            SettingData data = new SettingData(.5f, "MID");

            SaveLoadSystem.Save(data);

            diff = "MID";
            voi  = .5f;
        }
        else
        {
            diff = SaveLoadSystem.Load().difficult;
            voi  = SaveLoadSystem.Load().voice;
        }

        subject.setDifficultAndVoice(diff, voi);
    }
Пример #7
0
    public void SetupChallenge()
    {
        List <ChallengeInfo> challengeInfo = GuessManager.Instance.ChallengeInfos;

        challengeItemObjectPool.ReturnAllObjectsToPool();
        PlayerData playerData = SaveLoadSystem.Load();

        if (playerData != null)
        {
            for (int i = 0; i < challengeListContainer.childCount; i++)
            {
                GameObject challengeGO = challengeListContainer.GetChild(i).gameObject;
                challengeGO.SetActive(true);
                ChallengeListItem challenge = challengeGO.transform.GetComponent <ChallengeListItem>();
                challenge.Setup(challengeInfo[i].title, playerData.challengeList[i].curGoal, challengeInfo[i].goal, challengeInfo[i].challengeDescription);
            }
        }
        else
        {
            for (int i = 0; i < challengeListContainer.childCount; i++)
            {
                GameObject challengeGO = challengeListContainer.GetChild(i).gameObject;
                challengeGO.SetActive(true);
                ChallengeListItem challenge = challengeGO.transform.GetComponent <ChallengeListItem>();
                challenge.Setup(challengeInfo[i].title, 0, challengeInfo[i].goal, challengeInfo[i].challengeDescription);
            }
        }
    }
Пример #8
0
    void Start()
    {
        subject = Subject.getInstance();

        diff = SaveLoadSystem.Load().difficult;
        voi  = SaveLoadSystem.Load().voice;

        toggles[0].isOn = false;
        toggles[1].isOn = false;
        toggles[2].isOn = false;

        if (diff.Equals("EASY"))
        {
            toggles[0].isOn = true;
        }
        else if (diff.Equals("MID"))
        {
            toggles[1].isOn = true;
        }
        else
        {
            toggles[2].isOn = true;
        }

        voiceScrollBar.value = voi;
    }
Пример #9
0
    public void LoadInfo()
    {
        codePointsEntered   = SaveLoadSystem.Load <double>(codePointsKey);
        designPointsEntered = SaveLoadSystem.Load <double>(designPointsKey);
        artPointsEntered    = SaveLoadSystem.Load <double>(artPointsKey);

        currentGame = SaveLoadSystem.Load <GameDataType>(currentGameKey);
    }
Пример #10
0
 public void LoadNextLevel()
 {
     if ((level + 1) > SaveLoadSystem.Load().level)
     {
         SaveLoadSystem.Save(new GameData(level + 1));
     }
     SceneManager.LoadScene(level + 1);
 }
Пример #11
0
        void Start()
        {
            PlayerData playerData = SaveLoadSystem.Load();

            nextRewardIndex = playerData.rewardsIndex;
            UpdateCoinsTextUI();
            CheckForReward();
        }
Пример #12
0
 public void LoadCharacterStats()
 {
     if (SaveLoadSystem.SaveExists("PlayerStats"))
     {
         SaveCharacterStats stats = SaveLoadSystem.Load <SaveCharacterStats>("PlayerStats");
         this.Health  = stats.Health;
         this.Stamina = stats.Stamina;
     }
 }
Пример #13
0
    public void LoadInfo(double secondsPast)
    {
        List <int> countList = SaveLoadSystem.Load <List <int> >("upgrades");

        for (int i = 0; i < upgrades.Count; i++)
        {
            upgrades[i].currentUpgradeCount = countList[i];
        }
    }
Пример #14
0
 public void CompleteCutscene()
 {
     saveLoadSystem.Load();
     if (!saveLoadSystem.gameData.UnlockedLevelNames.Contains(sceneSwitcher.nextLevelSceneName))
     {
         saveLoadSystem.gameData.UnlockedLevelNames.Add(sceneSwitcher.nextLevelSceneName);
     }
     saveLoadSystem.Save();
 }
Пример #15
0
        public void OnHomeClick()
        {
            Save newSave = SaveLoadSystem.Load();

            newSave.LastCompletedLevel++;
            SaveLoadSystem.Save(newSave);

            Time.timeScale = 1.0f;
            SceneManager.LoadScene(0);
        }
Пример #16
0
    public void LoadInfo(int secondsMissed)
    {
        games = SaveLoadSystem.Load <List <GameDataType> >(saveGamesKey);
        money = SaveLoadSystem.Load <decimal>(saveMoneyKey);

        foreach (GameDataType game in games)
        {
            money += (((decimal)game.Quality * (decimal)game.Popularity * 55 + 5) / 60) * (decimal)secondsMissed;
        }
    }
Пример #17
0
    /// <summary>
    /// 初期化
    /// </summary>
    public void Initialization()
    {
        FindObjectOfType <FadeManager>().StartFadeIn();
        userData = (UserData)SaveLoadSystem.Load("UserData");
        if (userData == null)
        {
            Instantiate(userDataInput);
            return;
        }

        SetUserDataUI();
    }
Пример #18
0
    public static void Load(bool actOnData = true)
    {
        SaveLoadSystem.Load(ref gameData);

        if (!actOnData || gameData.sceneAlias == "" || gameData.sceneAlias == null)
        {
            return;
        }

        Player.preloadPosition = new Vector2(gameData.playerPosition[0], gameData.playerPosition[1]);
        MHS.LoadScene(gameData.sceneAlias);
    }
Пример #19
0
        public void Load(string baseId)
        {
            var            UID   = GetComponent <UniqueID>().uid;
            ContainerState state = SaveLoadSystem.Load <ContainerState>(baseId, UID);

            if (state == null)
            {
                state = new ContainerState();
            }

            SetAmount(state.currentAmount);
        }
Пример #20
0
        public void Load(string baseId)
        {
            var state = SaveLoadSystem.Load <FavoriteCoffeeState>(baseId, "FavoriteCoffeeController");

            if (state == null)
            {
                state = new FavoriteCoffeeState();
            }

            favoriteCoffees = state.favoriteCoffees;
            currentIndex    = state.currentIndex;
        }
Пример #21
0
 public void Play()
 {
     if (SaveLoadSystem.Load().savedGame == true)
     {
         main.StartMain(SaveLoadSystem.Load());
         mainObj.SetActive(false);
         systemGenerationModeMain.transform.GetChild(0).gameObject.SetActive(false);
     }
     else
     {
         NewGame(true);
     }
 }
Пример #22
0
    public void SetLoadButton()
    {
        SetButtons(loadButtons, (position) =>
        {
            var slot = (SaveSlot)position;

            var data = SaveLoadSystem.Load(slot);
            if (data != null)
            {
                SceneManager.LoadScene($"Level{data.level.ToString()}");
            }
        });
    }
Пример #23
0
    public void Load()
    {
        SaveData data = SaveLoadSystem.Load();

        player.GetComponent <Player>().HP                 = data.hp;
        player.GetComponent <Player>().acceptedQuest      = data.acceptedQuest;
        player.GetComponent <Player>().finishedQuests     = data.finishedQuests;
        player.GetComponent <Player>().acceptedActivity   = data.acceptedActivity;
        player.GetComponent <Player>().finishedActivities = data.finishedActivities;
        player.GetComponent <Player>().monsterKills       = data.monsterKills;

        npc.GetComponent <ContentHandler>().availableQuests     = data.availableQuests;
        npc.GetComponent <ContentHandler>().availableActivities = data.availableActivities;
    }
Пример #24
0
        private void Awake()
        {
            _currentLevel = SaveLoadSystem.Load().LastCompletedLevel;

            for (int levelIndex = 0; levelIndex < _currentLevel; levelIndex++)
            {
                _levels[levelIndex].image.color  = Color.green;
                _levels[levelIndex].interactable = false;
            }

            for (int levelIndex = _currentLevel + 1; levelIndex < _levels.Length; levelIndex++)
            {
                _levels[levelIndex].interactable = false;
            }
        }
Пример #25
0
 public void SetStartButton()
 {
     SetButtons(startButtons, (position) =>
     {
         var slot = (SaveSlot)position;
         SaveLoadSystem.Load(slot);
         var data = new SavingData
         {
             level       = 1,
             playerName  = playerNameInput.text,
             score       = 0,
             timeElapsed = 0
         };
         SaveLoadSystem.Save(slot, data);
         SceneManager.LoadScene($"Level{data.level.ToString()}");
     });
 }
Пример #26
0
    void SetUpLevelButtons()
    {
        GameData data = SaveLoadSystem.Load();

        for (int i = 0; i < levelButtons.Length; i++)
        {
            levelButtons[i].interactable = false;
        }
        for (int i = 0; i < data.level; i++)
        {
            if (levelButtons[i] != null)
            {
                levelButtons[i].interactable = true;
            }
        }
        levelButtons[0].interactable = true;
        levelButtons[1].interactable = true;
    }
Пример #27
0
    public void LoadData()
    {
        PlayerData dataList = SaveLoadSystem.Load();

        if (dataList != null)
        {
            for (int i = 0; i < categoryList.gameObject.transform.childCount; i++)
            {
                CategoryListItem categoryListItem = categoryList.gameObject.transform.GetChild(i).gameObject.transform.GetComponent <CategoryListItem>();
                foreach (var data in dataList.dataList)
                {
                    if (data.categoryName == categoryListItem.categoryName)
                    {
                        categoryListItem.NumOfActiveLevel = data.completedLevel;
                    }
                }
            }
            CoinNumber = dataList.coins;
        }
    }
Пример #28
0
        public void ClaimRewardButton()
        {
            PlayerData playerData = SaveLoadSystem.Load();

            Reward reward = rewardsDB.GetReward(nextRewardIndex);

            //playerData.coins += reward.amount;
            GuessGameplay.Instance.CoinNumber += reward.amount;
            UpdateCoinsTextUI();

            //save next reward index
            nextRewardIndex++;
            if (nextRewardIndex >= rewardsDB.rewardsCount)
            {
                nextRewardIndex = 0;
            }
            playerData.rewardsIndex = nextRewardIndex;

            SaveLoadSystem.Save();
            DeactivateReward();
        }
Пример #29
0
        private void LoadTournament()
        {
            _tournament = SaveLoadSystem.Load(_printer);

            var tournamentMenuList = new List <MenuItem>
            {
                new MenuItem(PlayRound, " Play next round"),
                new MenuItem(ShowGrid, " Show tournament grid"),
            };

            if (_tournament is SingleEliminationTournament)
            {
                tournamentMenuList.Add(new MenuItem(SelectOneSidedGrid, " Select one-sided type of grid"));
                tournamentMenuList.Add(new MenuItem(SelectDoubleSidedGrid, " Select double-sided type of grid"));
                _tournamentGridType = TournamentGridType.OneSided;
            }

            var tournamentMenu = new Menu(tournamentMenuList, "Playing tournament ...");

            tournamentMenu.Start();
        }
 void Start()
 {
     string[] files = Directory.GetDirectories(FileNameGetter.SaveFolderLocation);
     foreach (string file in files)
     {
         string[] subfiles = Directory.GetFiles(file, "*.txt");
         foreach (string subfile in subfiles)
         {
             GetFileNames.Add(Path.GetFileName(subfile));
         }
     }
     foreach (string file in files)
     {
         string[] subfiles = Directory.GetFiles(file, "*.png");
         foreach (string subfile in subfiles)
         {
             byte[]    byteArray = File.ReadAllBytes(subfile);
             Texture2D texture   = new Texture2D(500, 500);
             texture.LoadImage(byteArray);
             Screenshots.Add(texture);
         }
     }
     for (int i = 0; i < GetFileNames.Count; ++i)
     {
         GetFileNames[i] = GetFileNames[i].Replace(".txt", "");
         string LoadString = SaveLoadSystem.Load(GetFileNames[i]);
         if (LoadString != null)
         {
             SaveFile   saveFile = JsonUtility.FromJson <SaveFile>(LoadString);
             GameObject clone    = Instantiate(Info);
             clone.transform.SetParent(Parent);
             clone.transform.localScale = new Vector3(1, 1, 1);
             clone.transform.GetChild(1).GetComponent <TextMeshProUGUI>().text = saveFile.WorldName + "\nSeed: " + saveFile.Seed + "\n" + saveFile.ModeName;
             clone.transform.GetChild(0).GetComponent <Button>().onClick.AddListener(delegate { SendData(saveFile); });
             clone.transform.GetChild(0).GetComponent <Button>().image.sprite = Sprite.Create(Screenshots[i], new Rect(0, 0, Screenshots[i].width, Screenshots[i].height), new Vector2());
             clone.transform.GetChild(2).GetComponent <Button>().onClick.AddListener(delegate { DeleteWorld(FileNameGetter.SaveFolderLocation + saveFile.WorldName, clone, saveFile.WorldName); });
         }
     }
 }