/// <summary> /// On Connected /// </summary> /// <param name="task"></param> private static void OnConnectReceived(Task <Object> task) { try { _user = new User(task.Result.ToString()); // Load facebook achievements and progress PlayerProgress.Load(_user.Id); // Set Authorized Connection |= FacebookState.Authorized; //string profilePictureUrl = String.Format("/{0}/picture?type={1}", _user.Id, "square"); } catch (AggregateException aex) { aex.Handle((e) => { if (e is FacebookOAuthException) { } return(false); }); } }
public void ApplyLoadedData(object data) { Debug.Log("------------PlayerProgress loaded data applying..."); var d = data as PlayerProgress; if (d == null) { d = new PlayerProgress(); } Flags = d.Flags; Score.ApplyLoadedData(d.Score); Stats = d.Stats; //if some gamers olready have some saved data //we need to repair it to new stats range Stats.RepairMaxMinRanges(); Skills.ApplyLoadedData(d.Skills); Equipment = d.Equipment; Squad.ApplyLoadedData(d.Squad); Level = d.Level; Debug.Log("------------PlayerProgress loaded data was applyed"); }
void Awake() { #region OLD SAVE SYSTEM //recordCards[0] = FindObjectOfType<CardBrain>(); //if (recordCards[0].isActiveAndEnabled) // Debug.Log("Success"); //PlayerProgress playerProgress = SaveSystem.LoadPlayer(); //PlayerProgress progress = playerProgress; //recordCards[0].score = progress.s_score; //recordCards[0].time = progress.s_timeOfPlay; //recordCards[0].enemyKilled = progress.s_enemyKilled; #endregion for (int i = 0; i < recordCards.Length - 1; i++) { CardBrain card = GameObject.Find("Record0" + (i + 1)).GetComponent <CardBrain>(); PlayerProgress progress = SaveGame.Load <PlayerProgress>("PlayerProgress0" + (i + 1)); if (progress == null) { return; } card.gameObject.SetActive(true); // think of better represantation card.score = progress.s_score; card.enemyKilled = progress.s_enemyKilled; card.time = progress.s_timeOfPlay; } // load info //recordCards = Loadinfo(); }
private PlayerProgress CreateEmptyProgress() { var progress = new PlayerProgress(new Score(0, 1), new LevelStage(0, 0)); _saveLoadService.SaveProgress(); return(progress); }
// Start is called before the first frame update void Start() { _upgradesPanel = GameObject.Find("GlobalUpgrades"); _upgradesPanelPlayerWallet = GameObject.Find("PlayerWallet"); //Load all upgrades into the Global Player Progress class PlayerProgress playerProgress = new PlayerProgress(); playerProgress = playerProgress.loadProgress(); Debug.Log("Finished loading"); GlobalPlayerProgress.UpdateUpgradePanel(playerProgress); GlobalPlayerProgress.UpdatePlayerWallet(playerProgress, _upgradesPanelPlayerWallet); _upgradesPanel.SetActive(false); unlockedLevels = GlobalPlayerProgress.GetUnlockedLevels(playerProgress); if (unlockedLevels.Count == 0) { unlockedLevels.Add(0); } foreach (int levelId in unlockedLevels) { GameObject levelBtn = GameObject.Find("Level_" + levelId + "_Btn"); levelBtn.GetComponent <Button>().onClick.AddListener(() => showPanelForLevel(levelId)); Addressables.LoadAssetAsync <Sprite>("Assets/Emerald Treasure/images/ui_seekbar_tick.png").Completed += delegate(AsyncOperationHandle <Sprite> handle) { levelBtn.GetComponent <Image>().sprite = handle.Result; }; } }
IEnumerator UnlockingLevels() { if (pprogScript == null) { pprogScript = GameObject.Find("_player").GetComponent <PlayerProgress>(); } levelProgression = pprogScript.levelProgress; for (int i = 0; i < levelsButtons.Length; i++) { if (i + 1 > pprogScript.levelProgress) { levelsButtons[i].GetComponent <Button>().interactable = false; levelsButtons[i].transform.GetChild(0).gameObject.SetActive(true); //levelsButtons[i].GetComponent<Image>().sprite = locked; } else { levelsButtons[i].transform.GetChild(0).gameObject.GetComponent <Animator>().SetBool("unlocked", true); yield return(new WaitForSeconds(0.6f)); levelsButtons[i].GetComponent <Button>().interactable = true; levelsButtons[i].transform.GetChild(0).gameObject.SetActive(false); } } yield return(null); }
public void PrintMenu(PlayerProgress playerProgress, IOptionsContainer optionsContainer) { foreach (var elem in optionsContainer.CurrentStageOptions(playerProgress, false)) { writer.WriteLine(elem); } }
/// <summary> /// Deletes the player progress' footprint in PlayerPrefs /// </summary> public void RemoveProgress() { PlayerPrefs.DeleteKey($"{_name}_levelIndex"); PlayerPrefs.DeleteKey(_name); CurrentPlayer = null; }
public IEnumerable <string> CurrentStageOptions(PlayerProgress playerProgress, bool returnKey = false) { if (!returnKey) { var tempOptions = options .Where(x => x.Value.PlayerProgress == playerProgress) .Where(x => x.Value.IsUnlocked) .Where(x => x.Value.CanBeUsedManyTimes || !x.Value.IsUsed); if (!tempOptions.Any()) { return new List <string> { Exceptions.Models.Exceptions.NoCommandsAvailable } } ; return(tempOptions.Select(x => x.Value.CommandDisplay).ToList()); } var temp = options .Where(x => x.Value.PlayerProgress == playerProgress) .Where(x => x.Value.IsUnlocked) .Where(x => x.Value.CanBeUsedManyTimes || !x.Value.IsUsed) .Select(option => option.Value.CommandKey).ToList(); return(temp); }
//Function called externally to save player progress. Called from the pause menu in GamePlay scene, and CreateTileGrid.cs in Start public void SavePlayerProgress() { //Sending out an event to toggle the save game icon UI on EVTData startSaveData = new EVTData(); startSaveData.saveData = new SaveDataEVT(true); EventManager.TriggerEvent(SaveDataEVT.eventNum, startSaveData); //Making sure the save folder exists this.CheckSaveDirectory(GameData.globalReference.saveFolder); //Creating a new PlayerProgress class that we'll save PlayerProgress currentProgress = new PlayerProgress(GameData.globalReference, TileMapManager.globalReference, LevelUpManager.globalReference, CharacterManager.globalReference, QuestTracker.globalReference); //Serializing the current progress string jsonPlayerProgress = JsonUtility.ToJson(currentProgress, true); //Writing the JSON progress data to a new text file in the given folder's directory File.WriteAllText(Application.persistentDataPath + GameData.globalReference.saveFolder + "/" + this.defaultProgressFileName, jsonPlayerProgress); //Sending out an event to toggle the save game icon UI off EVTData endSaveData = new EVTData(); endSaveData.saveData = new SaveDataEVT(false); EventManager.TriggerEvent(SaveDataEVT.eventNum, endSaveData); }
public SavablePlayerData() { playerProgress = new PlayerProgress(); settings = new Settings(true); Reset(); }
// Starts the GameManager void Start() { tries = 5; gameState = State.StoryTelling; SetStoryTellingActive(true); actualCheckPoint = spawnPoint; InitBike(); //Load Record Time int recordTime = LoadPlayerProgress(); if (recordTime > 0) { _playerProgress = new PlayerProgress(recordTime); _gameUI.setRecordTime(recordTime); } else { _playerProgress = new PlayerProgress(Int32.MaxValue); } _gameUI.SetNumberOfTries(); }
public static List <int> GetUnlockedLevels(PlayerProgress playerProgress) { List <int> _unlockedLevels = new List <int>(); foreach (int levelId in playerProgress.UnlockedLevels) { if (!_unlockedLevels.Contains(levelId)) { _unlockedLevels.Add(levelId); } if (unlockLevels.ContainsKey(levelId)) { foreach (int toUnlockLevelId in unlockLevels[levelId]) { if (!_unlockedLevels.Contains(toUnlockLevelId)) { _unlockedLevels.Add(toUnlockLevelId); } } } } return(_unlockedLevels); }
// Save public PlayerProgressWrapper(PlayerProgress progressData) { lastLevelLoaded = progressData.lastLevelLoaded; maxLevelAchieved = progressData.maxLevelAchieved; // seasons = progressData.seasons; // seasons are saved separately (Different folder and files). }
public static PlayerProgress DeleteProgress() { PlayerProgress newPlayerProgress = PlayerProgress.CreateNewPlayer(); SavePlayer(newPlayerProgress); return(newPlayerProgress); }
void SaveProgress() { PlayerProgress currLevelProgress = new PlayerProgress( levelMode, levelNo, starPercent, timePassed, wrongTries, nextNumber, true, false ); ProgressController.SaveProgress(currLevelProgress); // If there is no level or we could not get one star, do not unlock next level. if (levelNo == levels.Count || starPercent < starPercents[0]) { UICont.DisableNextButton(); return; } // We have a next level, so unlock it. PlayerProgress nextLevelProgress = ProgressController.GetProgress(levelMode, levelNo + 1); nextLevelProgress.locked = false; ProgressController.SaveProgress(nextLevelProgress); }
public PlayerScoreRecorder(PlayerProgress player) { m_score = player.s_score; m_enemyKilled = player.s_enemyKilled; timeOfPlay = player.s_timeOfPlay; moneyAmount = player.s_moneyAmount; }
public void SaveGame() { Game Game = new Game(); BadgeManagerSetup BadgeManagerSetup = FindObjectOfType <BadgeManagerSetup>(); if (BadgeManagerSetup) { Game.Badges = new List <BadgeStruct>(); foreach (GameObject Badge in GameObject.FindGameObjectsWithTag("Badge")) { BadgeStruct SaveData = new BadgeStruct(); GameObject BadgeHolderGameObject = Badge.transform.parent.gameObject; BadgeHolder BadgeHolder = BadgeHolderGameObject.GetComponent <BadgeHolder>(); string PrefabPath = BadgeHolder.PrefabResourcePath; SaveData.Name = BadgeHolderGameObject.transform.name; SaveData.PrefabResourcePath = PrefabPath; SaveData.LocalPosition = BadgeHolderGameObject.transform.localPosition; SaveData.LocalRotation = BadgeHolderGameObject.transform.localRotation; Game.Badges.Add(SaveData); Debug.Log("Save data:" + SaveData.Name + " path " + SaveData.PrefabResourcePath); } } PlayerProgress PlayerProgress = FindObjectOfType <PlayerProgress>(); PlayerProgress.Save(Game); }
// KEY VALUE // LEVEL_MODE~LEVEL_NUMBER STAR_PERCENT~BEST_TIME~BEST_TRY~BEST_COUNT~CLEARED-LOCKED // TIME_AND_TRY~3 99.12~30.23~8~5~True~False public static void SaveProgress(PlayerProgress progress) { PlayerProgress lastProgress = GetProgress(progress.levelMode, progress.levelNumber); float starPercent = Mathf.Max(lastProgress.starPercent, progress.starPercent); float bestTime = Mathf.Min(lastProgress.bestTime, progress.bestTime); int bestTry = Mathf.Min(lastProgress.bestTry, progress.bestTry); int bestCount = Mathf.Max(lastProgress.bestCount, progress.bestCount); bool completed = progress.completed; bool locked = progress.locked; string progressKey = string.Format( "{0}~{1}", progress.levelMode, progress.levelNumber ); string progressValue = string.Format( "{0}~{1}~{2}~{3}~{4}~{5}", starPercent, bestTime, bestTry, bestCount, completed, locked ); PlayerPrefs.SetString(progressKey, progressValue); }
public void StartGame() { PlayerState = PlayerProgress.robot; PlayerHP = 100; PhasesComplete = 0; LoadProgressScene(PhasesComplete); }
public void LoadGame() { PlayerProgress PlayerProgress = FindObjectOfType <PlayerProgress>(); Game Game = PlayerProgress.Load(); if (Game != null) { foreach (BadgeHolder Badge in FindObjectsOfType <BadgeHolder>()) { Destroy(Badge.gameObject); } BadgeManagerSetup BadgeManagerSetup = FindObjectOfType <BadgeManagerSetup>(); foreach (BadgeStruct BadgeStruct in Game.Badges) { Debug.Log("Loading data " + BadgeStruct.Name + " path " + BadgeStruct.PrefabResourcePath); GameObject NewBadge = Instantiate(BadgeManagerSetup.BadgePrefab); NewBadge.transform.name = BadgeStruct.Name; NewBadge.transform.parent = BadgeManagerSetup.transform; BadgeHolder BadgeHolder = NewBadge.GetComponent <BadgeHolder>(); BadgeHolder.PrefabResourcePath = BadgeStruct.PrefabResourcePath; NewBadge.transform.localPosition = BadgeStruct.LocalPosition; NewBadge.transform.localRotation = BadgeStruct.LocalRotation; } } }
public static PlayerProgress CreateNewPlayer() { PlayerProgress newPlayer = new PlayerProgress(); return(newPlayer); }
/// <summary> /// Deletes the given save file after prompting the user for confirmation /// </summary> /// <param name="slotNumber">Number of the save slot</param> private void DeleteSaveFile(int slotNumber) { string player; switch (slotNumber) { case 1: player = save1; save1 = ""; PlayerPrefs.SetString("save1", ""); break; case 2: player = save2; save2 = ""; PlayerPrefs.SetString("save2", ""); break; case 3: player = save3; save3 = ""; PlayerPrefs.SetString("save3", ""); break; default: throw new Exception($"Slot {slotNumber} does not exist"); } var progress = new PlayerProgress(player); progress.RemoveProgress(); // empty the button of this save file PresentSaveFileButton(slotNumber, ""); }
void LoadScore() { playerProgress = new PlayerProgress(); if (PlayerPrefs.HasKey("highScore")) { playerProgress.highScore = PlayerPrefs.GetInt("highScore"); } }
private void Start() { playerProgress = GetComponent <PlayerProgress>(); timeStreaming = GetComponent <TimeStreaming>(); babyHappiness = GetComponent <BabyHappiness>(); filthyRoom = GetComponent <FilthyRoom>(); dayProgress = GetComponent <DayProgress>(); }
public static void SavePlayer(PlayerProgress playerData) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(PlayerPath(), FileMode.Create); formatter.Serialize(stream, playerData); stream.Close(); }
private DataController SavePlayerProgress(PlayerProgress playerProgress) { string dataAsJson = JsonUtility.ToJson(playerProgress); string progressPath = Application.persistentDataPath + "/playerProgress.json"; File.WriteAllText(progressPath, dataAsJson); return(this); }
private void LoadPlayerProgress() { playerProgress = new PlayerProgress(); if (PlayerPrefs.HasKey("highestScore")) { playerProgress.highestScore = PlayerPrefs.GetInt("highestScore"); } }
/** * Loads unlocked upgrades from the JSON extracted player progress file into the GlobalPlayerProgress class */ private static void LoadUnlockedUpgradesInGlobalProgress(PlayerProgress playerProgress) { foreach (int upgradeId in playerProgress.UnlockedUpgrades) { Addressables.LoadAssetAsync <UpgradeScriptableObject>("Upgrade_" + upgradeId).Completed += delegate(AsyncOperationHandle <UpgradeScriptableObject> handle) { GlobalPlayerProgress.UnlockedUpgrades.Add(handle.Result); }; } }
//loads the headrotation if it exists private void LoadPlayerProgress() { playerProgress = new PlayerProgress(); if (PlayerPrefs.HasKey("highestScore")) { playerProgress.headRotation = PlayerPrefs.GetFloat("highestScore"); } }
public void initialize(ContentUtil content, SceneActivationParameters parameters) { HighscoreParams stageParams = (HighscoreParams) parameters.parameters; this.stageName = stageParams.stage; this.nextScore = stageParams.newScore; this.showInputSound = new Sound("menu/select", content); this.createSound = new Sound("menu/click", content); this.background = content.load<Texture2D>(null == stageParams.background ? "bgr_highscore" : stageParams.background); this.lineBackground = new ScaledTexture(content.load<Texture2D>( null == stageParams.background ? "hud/highscore_line" : stageParams.background+"_line"), .4f); this.scores = new HighscoreList(); this.scores.loadForScene(stageName); this.exit = false; this.nameInput = new TextInput(); /*if (null == this.nextScore) { this.nextScore = new PlayerProgress(); this.nextScore.score = 4321; }*/ if (null != this.nextScore) { this.nameInput.setMessage("You scored " + this.nextScore.score + ". Please enter your name."); this.showInputSound.play(); this.nameInput.startListening(); } //this.scores.add(new Scoring("Batman", this.nextScore.score, true)); this.initTime = Environment.TickCount; }
public HighscoreParams(String stageName, String background, PlayerProgress newScore) { this.stage = stageName; this.background = background; this.newScore = newScore; }