public void test() { if (IsMage) { newPlayer.PlayerClass = new BaseMageClass(); DescriptionText.text = newPlayer.PlayerClass.CharacterClassDescription; StatsText.text = "Stamina: " + newPlayer.PlayerClass.Stamina.ToString() + "\n" + "Endurance: " + newPlayer.PlayerClass.Endurance.ToString() + "\n" + "Strength: " + newPlayer.PlayerClass.Strength.ToString() + "\n" + "Intellect: " + newPlayer.PlayerClass.Intellect.ToString() + "\n" + "Agility: " + newPlayer.PlayerClass.Agility.ToString() + "\n" + "Resistance: " + newPlayer.PlayerClass.Resistance.ToString() + "\n"; Debug.Log("You Selected Mage Class"); } if (IsWarrior) { newPlayer.PlayerClass = new BaseWarriorClass(); DescriptionText.text = newPlayer.PlayerClass.CharacterClassDescription; StatsText.text = "Stamina: " + newPlayer.PlayerClass.Stamina.ToString() + "\n" + "Endurance: " + newPlayer.PlayerClass.Endurance.ToString() + "\n" + "Strength: " + newPlayer.PlayerClass.Strength.ToString() + "\n" + "Intellect: " + newPlayer.PlayerClass.Intellect.ToString() + "\n" + "Agility: " + newPlayer.PlayerClass.Agility.ToString() + "\n" + "Resistance: " + newPlayer.PlayerClass.Resistance.ToString() + "\n"; Debug.Log("You Selected Warrior Class"); } playerName = PlayerName.text; Debug.Log(playerName); CreateNewPlayer(); StoreNewPlayerInfo(); SaveInformation.SaveAllInformation(); }
private static ISaveUpgradeStep?FindPathToVersion(SaveInformation saveInfo, string fromVersion, string toVersion) { var step = SaveUpgradeSteps.GetUpgradeStepForVersion(fromVersion); if (step == null) { return(null); } saveInfo.ThriveVersion = fromVersion; var nextVersion = step.VersionAfterUpgrade(saveInfo); // Stop if found target version if (VersionUtils.Compare(nextVersion, toVersion) >= 0) { return(step); } // Otherwise verify that there exists steps until the toVersion if (FindPathToVersion(saveInfo, nextVersion, toVersion) == null) { // No further path found return(null); } return(step); }
public void SaveAnswer() { int questionNum = questionIndex - 1; List <string> answers = new List <string>(); if (currentToggleGroup != null) { foreach (Toggle t in currentToggleGroup.ActiveToggles()) { if (t.isOn) { answers.Add(t.GetComponentInChildren <Text>().text); } } } if (currentInputField != null) { answers.Add(currentInputField.text); } if (currentToggleList.Count != 0) { foreach (Toggle t in currentToggleList) { if (t.isOn) { answers.Add(t.GetComponentInChildren <Text>().text); } } } GameInformation.TeacherQuestions.Add(questionNum, answers); SaveInformation.SaveAllInformation(); }
public void Display() { if (!isFileFounded) { SearchFiles(); } ShowFiles(ref text, amountOfFiles, files); MenuAfterSearch(ref selectedOption, header, text); if (selectedOption == 0) { SortingFiles.SortingByName(ref files, amountOfFiles); Display(); } else if (selectedOption == 1) { SortingFiles.SortingBySize(ref files, amountOfFiles); Display(); } else if (selectedOption == 2) { SaveInformation saveInfo = new SaveInformation(header, text); amountOfFiles = 0; } else if (selectedOption == 3) { MainMenu menu = new MainMenu(); } }
void OnGUI() { if (string.IsNullOrEmpty(GameInformation.PlayerName)) { playerName = GUILayout.TextArea(playerName, 15); isWarden = GUILayout.Toggle(isWarden, "Warden Class"); isDerezzer = GUILayout.Toggle(isDerezzer, "Derezzer Class"); isTracker = GUILayout.Toggle(isTracker, "Tracker Class"); if (GUILayout.Button("Create")) { if (isWarden) { newPlayer.PlayerClass = new BaseWardenClass(); } else if (isDerezzer) { newPlayer.PlayerClass = new BaseDerezzerClass(); } else if (isTracker) { newPlayer.PlayerClass = new BaseTracerClass(); } CreatePlayer(); StoreNewPlayerInfo(); SaveInformation.SaveAllInformation(); } } }
protected virtual void PerformUpgradeOnInfo(SaveInformation saveInformation) { saveInformation.ThriveVersion = VersionAfter; // Update the ID of the save as it is in practice save with different content saveInformation.ID = Guid.NewGuid(); }
public static void WriteSaveJSONToFile(SaveInformation saveInfo, JObject saveStructure, Image screenshot, string saveName) { var serialized = saveStructure.ToString(Formatting.None); WriteRawSaveDataToFile(saveInfo, serialized, screenshot, saveName); }
void Awake() { if (instance == null) { instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } if (_firstClear = false) { PlayerPrefs.DeleteAll(); GameInformation.FirstClear = true; SaveInformation.SaveAllInformation(); } GameInformation.SpeechAutoPlay = true; SaveInformation.SaveAllInformation(); //LoadInformation.LoadAllInformation(); Debug.Log(GameInformation.CorrectPreQuestions.Count); }
private void BuyItem(GameObject selectedItemPrefab, BaseItem item) { //if player has enough money to buy the item if (GameInformation.PlayerMoney >= item.ItemValue) { //remove the item from the shop inventory _shopItems.Remove(item); //remove the prefab associated with the item _shopitemPrefabs.Remove(selectedItemPrefab); //add the item to the player's inventory GameInformation.PlayerInventory.Add(item); //decrease the player's currency by the price GameInformation.PlayerMoney -= item.ItemValue; //save all information SaveInformation.SaveAllInformation(); //destroy the prefab Destroy(selectedItemPrefab); } else { Debug.Log("Not enough money!"); } }
public void CheckIfAllTopicsAreDone() { if (readingDone && differencesDone && wrongDone) { areaReturnButton.SetActive(true); Scene currentScene = SceneManager.GetActiveScene(); int buildIndex = currentScene.buildIndex; if (buildIndex == 8) { GameInformation.TPJComplete = true; } else if (buildIndex == 15) { GameInformation.OTComplete = true; } else if (buildIndex == 16) { GameInformation.RHComplete = true; } else if (buildIndex == 20) { GameInformation.IFGComplete = true; } SaveInformation.SaveAllInformation(); } }
private void OnGUI() { _playerName = GUILayout.TextArea(_playerName); _isMageClass = GUILayout.Toggle(_isMageClass, "Mage Class"); _isWarrriorClass = GUILayout.Toggle(_isWarrriorClass, "Warrior Class"); if (GUILayout.Button("Create")) { if (_isMageClass) { _newPlayer.PlayerClass = new BaseMageClass(); } else if (_isWarrriorClass) { _newPlayer.PlayerClass = new BaseWarriorClass(); } CreateNewPlayer(); StoreNewPlayerInfo(); SaveInformation.SaveAllInformation(); /*Debug.Log("Player Name: " + _newPlayer.PlayerName); * Debug.Log("Player class: " + _newPlayer.PlayerClass.CharacterClassName); * Debug.Log("Player level: " + _newPlayer.PlayerLevel);*/ } if (GUILayout.Button("Load")) { //LoadInformation.LoadAllInformation(); SceneManager.LoadScene("TestLoading"); } }
#pragma warning disable CS0114 // Member hides inherited member; missing override keyword private void Awake() #pragma warning restore CS0114 // Member hides inherited member; missing override keyword { base.Awake(); DontDestroyOnLoad(gameObject); saveInformation = new SaveInformation(); }
void OnGUI() { playerName = GUILayout.TextArea(playerName, 15); isScholarClass = GUILayout.Toggle(isScholarClass, "Scholar Class"); isWarriorClass = GUILayout.Toggle(isWarriorClass, "Warrior Class"); if (GUILayout.Button("Create")) { if (isScholarClass) { newPlayer.PlayerClass = new BaseScholarClass(); } else if (isWarriorClass) { newPlayer.PlayerClass = new BaseWarriorClass(); } newPlayer.PlayerLevel = 1; newPlayer.PlayerStrength = newPlayer.PlayerClass.Strength; newPlayer.PlayerDexterity = newPlayer.PlayerClass.Dexterity; newPlayer.PlayerIntelligence = newPlayer.PlayerClass.Intelligence; newPlayer.PlayerName = playerName; StoreNewPlayerInfo(); SaveInformation.SaveAllInformation(); Debug.Log("Player Name: " + newPlayer.PlayerName); Debug.Log("Player Class" + newPlayer.PlayerClass.CharacterClassName); Debug.Log("Player Level: " + newPlayer.PlayerLevel); Debug.Log("Player Strength: " + newPlayer.PlayerStrength); Debug.Log("Player Dexterity: " + newPlayer.PlayerDexterity); Debug.Log("Player Intelligence: " + newPlayer.PlayerIntelligence); } if (GUILayout.Button("Load")) { Application.LoadLevel("tset"); } }
// Update is called once per frame void Update() { LoadInformation.LoadRecord(); if (Player.coin > Player.record) { Player.record = Player.coin; SaveInformation.SaveRecordScore(Player.record); } scores = Player.record.ToString();// lay diem so ve xau string if (index < scores.Length) { for (int i = 0; i < scores.Length; i++)// so sanh de lay anh hien thi so diem tuong ung { foreach (Sprite s in sp) { if (s.name == scores[scores.Length - 1 - index].ToString()) { r.sprite = s; } } } } }
private static void WriteRawSaveDataToFile(SaveInformation saveInfo, string saveContent, Image screenshot, string saveName) { FileHelpers.MakeSureDirectoryExists(Constants.SAVE_FOLDER); var target = SaveFileInfo.SaveNameToPath(saveName); var justInfo = ThriveJsonConverter.Instance.SerializeObject(saveInfo); string tempScreenshot = null; if (screenshot != null) { // TODO: if in the future Godot allows converting images to in-memory PNGs that should be used here tempScreenshot = PathUtils.Join(Constants.SAVE_FOLDER, "tmp.png"); if (screenshot.SavePng(tempScreenshot) != Error.Ok) { GD.PrintErr("Failed to save screenshot for inclusion in save"); tempScreenshot = null; } } try { WriteDataToSaveFile(target, justInfo, saveContent, tempScreenshot); } finally { // Remove the temp file if (tempScreenshot != null) { FileHelpers.DeleteFile(tempScreenshot); } } }
void OnGUI() { playerName = GUILayout.TextField(playerName, 10); isMageClass = GUILayout.Toggle(isMageClass, "Mage Class"); isWarriorClass = GUILayout.Toggle(isWarriorClass, "Warrior Class"); if (GUILayout.Button("Create")) { if (isMageClass) { newPlayer.PlayerClass = new BaseMageClass(); } else if (isWarriorClass) { newPlayer.PlayerClass = new BaseWarriorClass(); } CreateNewPlayer(); StoreNewPlayerInfo(); SaveInformation.SaveAllInformation(); SceneManager.LoadScene("main"); } if (GUILayout.Button("Load")) { SceneManager.LoadScene("main"); } }
public string PerformUpgrade(SaveInformation saveInfo, string inputSave, string outputSave) { var versionDifference = VersionUtils.Compare(VersionAfter, saveInfo.ThriveVersion); if (versionDifference == int.MaxValue) { throw new Exception("Could not compare version in save to version it would be upgraded to"); } if (versionDifference <= 0) { throw new ArgumentException("This converter can't upgrade the provided save"); } // SaveInformation is not used here as saveInfo is assumed to be up to date var(freshInfo, saveStructure, screenshot) = Save.LoadJSONStructureFromFile(inputSave); if (freshInfo.ThriveVersion != saveInfo.ThriveVersion) { GD.PrintErr("Unexpected save version in freshly loaded save information"); } PerformUpgradeOnJSON(saveStructure); PerformUpgradeOnInfo(saveInfo); CopySaveInfoToStructure(saveStructure, saveInfo); // TODO: should the "Name" in saveStructure be updated? (there's a bigger need to update it when making the // backup file rather than here...) Save.WriteSaveJSONToFile(saveInfo, saveStructure, screenshot, outputSave); return(VersionAfter); }
public static void UpdateInventory() { LoadInformation.LoadAllInformation(); InventoryManager._inventory = GameInformation.PlayerInventory; if (InventoryManager._inventory.Count != 0) { for (int i = 0; i < InventoryManager._inventory.Count; i++) { if (InventoryManager._inventory[i] != null) { Color c; Image itemImage = InventoryManager._inventorySlotIcons[i].GetComponent <Image>(); c = itemImage.color; c.a = 1; itemImage.color = c; itemImage.sprite = IconDB._icons[InventoryManager._inventory[i].ItemIcon]; } } } for (int i = InventoryManager._inventory.Count; i < InventoryManager._inventorySlots.Count; i++) { Color c; Image itemImage = _inventorySlotIcons[i].GetComponent <Image>(); c = itemImage.color; c.a = 0; itemImage.color = c; } SaveInformation.SaveAllInformation(); }
public void Display() { MenuBuilder.WriteHeader("Пошук файлів за розширенням імен"); if (!isFileFounded) { FileNameInput(); SearchFiles(); } ShowFiles(ref text, amountOfFiles, files); MenuAfterSearch(ref selectedOption, header, text); if (selectedOption == 0) { SortingFiles.SortingByName(ref files, amountOfFiles); Display(); } else if (selectedOption == 1) { SortingFiles.SortingBySize(ref files, amountOfFiles); Display(); } else if (selectedOption == 2) { SaveInformation saveInfo = new SaveInformation(header, text); amountOfFiles = 0; } else if (selectedOption == 3) { MainMenu menu = new MainMenu(); } }
public void ScoreAnswerAndContinue() { if (currentAnswer == true) { if (trueToggle.isOn) { Debug.Log("Correct!"); GameInformation.CorrectPreQuestions.Add(shuffledQuestions[questionIndex - 1]); } else { Debug.Log("Incorrect. :("); GameInformation.PreQuestions.Add(shuffledQuestions[questionIndex - 1]); } } else { if (falseToggle.isOn) { Debug.Log("Correct!"); GameInformation.CorrectPreQuestions.Add(shuffledQuestions[questionIndex - 1]); } else { Debug.Log("Incorrect. :("); GameInformation.PreQuestions.Add(shuffledQuestions[questionIndex - 1]); } } SaveCertaintyRating(); trueToggle.isOn = false; falseToggle.isOn = false; rating0.isOn = false; rating1.isOn = false; rating2.isOn = false; if (questionIndex != shuffledQuestions.Count) { progressFill.fillAmount = ((float)questionIndex / (float)shuffledQuestions.Count); DisplayNextQuestion(); } else { for (int i = 0; i < GameInformation.PreCertainty.Length; i++) { Debug.Log(GameInformation.PreCertainty[i].ToString()); } progressFill.fillAmount = ((float)questionIndex / (float)shuffledQuestions.Count); paper.SetActive(false); endText.SetActive(true); nextSceneButton.SetActive(true); done = true; GameInformation.PreCompletionTime = completionTime; } SaveInformation.SaveAllInformation(); Debug.Log(GameInformation.PreQuestions.Count); }
public void ConfirmarDefinitivo(string primeiracena) { GameInformation.loadingSave = false; SaveInformation.SaveAll(); SceneManager.LoadScene(primeiracena); }
void OnGUI() { playerName = GUILayout.TextArea(playerName, 15); isMageClass = GUILayout.Toggle(isMageClass, "Mage Class"); isWarriorClass = GUILayout.Toggle(isWarriorClass, "Warrior Class"); if (GUILayout.Button("Create")) { if (isMageClass) { newPlayer.PlayerClass = new BaseMageClass(); } else if (isWarriorClass) { newPlayer.PlayerClass = new BaseWarriorClass(); } CreateNewPlayer(); Debug.Log("Player name: " + newPlayer.PlayerName); Debug.Log("Player class: " + newPlayer.PlayerClass.CharacterClassName); Debug.Log("Player level: " + newPlayer.PlayerLevel); Debug.Log("Player strength: " + newPlayer.Strength); Debug.Log("Player gold: " + newPlayer.Gold); Debug.Log("Player resistance: " + newPlayer.Resistance); StoreNewPlayerInformation(); SaveInformation.SaveAllInformation(); } if (GUILayout.Button("Load")) { Application.LoadLevel("test"); } }
public void Attribute() { newPlayer.Playerlevel = 15; newPlayer.PlayerName = playerName; //HERO ATTRIBUTE newPlayer.Stamina = newPlayer.playerClass.stamina; newPlayer.Health = newPlayer.playerClass.endurance; //MAIN HERO ATTRIBUTE newPlayer.Intellect = newPlayer.playerClass.intellect; newPlayer.Agility = newPlayer.playerClass.agility; newPlayer.Strength = newPlayer.playerClass.strength; StoreInfo(); SaveInformation.SaveAllInformation(); //MAIN INFO Debug.Log("Player Class: " + newPlayer.playerClass.CharacterClassName); Debug.Log("Player Level: " + newPlayer.Playerlevel); Debug.Log("Player Name is: " + newPlayer.PlayerName); //MAIN ATTRIBUTES Debug.Log("Player Intellect: " + newPlayer.Intellect); Debug.Log("Player Strength: " + newPlayer.Strength); Debug.Log("Player Agility: " + newPlayer.Agility); //ATTRIBUTES Debug.Log("Player Stamina: " + newPlayer.Stamina); Debug.Log("Player Endurance: " + newPlayer.Health); }
public void IncreaseAbilityScore(int ID) { if (ID == 1) { if (_activeBoosts < GameInformation.PlayerClass.ClassAbilities[1].AbilityMaxRank && GameInformation.PlayerXP >= GameInformation.PlayerClass.ClassAbilities[1].AbilityXPToLevel[_activeBoosts]) { GameInformation.PlayerClass.ClassAbilities[1].AbilityCurrentRank++; GameInformation.PlayerXP -= GameInformation.PlayerClass.ClassAbilities[1].AbilityXPToLevel[_activeBoosts]; _activeBoosts++; GameInformation.PlayerBoosts[6] = _activeBoosts; } else { Debug.Log("max rank reached or not enough xp"); } } else if (ID == 2) { if (_passiveBoosts < GameInformation.PlayerClass.ClassAbilities[2].AbilityMaxRank && GameInformation.PlayerXP >= GameInformation.PlayerClass.ClassAbilities[2].AbilityXPToLevel[_passiveBoosts]) { GameInformation.PlayerClass.ClassAbilities[2].AbilityCurrentRank++; GameInformation.PlayerXP -= GameInformation.PlayerClass.ClassAbilities[2].AbilityXPToLevel[_passiveBoosts]; _passiveBoosts++; GameInformation.PlayerBoosts[7] = _passiveBoosts; } else { Debug.Log("max rank reached or not enough xp"); } } SaveInformation.SaveAllInformation(); }
public void ApplyChanges() { if (speechAutoPlayToggle.isOn) { GameInformation.SpeechAutoPlay = true; SaveInformation.SaveAllInformation(); Debug.Log(GameInformation.SpeechAutoPlay); } else { GameInformation.SpeechAutoPlay = false; SaveInformation.SaveAllInformation(); } if (colorblindModeToggle.isOn) { GameInformation.ColorblindMode = true; SaveInformation.SaveAllInformation(); cbm = GameObject.Find("ColorblindManager").GetComponent <ColorblindManager>(); cbm.UpdateColorScheme(); } else { GameInformation.ColorblindMode = false; SaveInformation.SaveAllInformation(); SceneManager.LoadScene(14); Debug.Log(GameInformation.SpeechAutoPlay); } }
public void Commit() { GameInformation.Stamina = levelPointsToAllocate[0]; GameInformation.Endurance = levelPointsToAllocate[1]; GameInformation.Strenght = levelPointsToAllocate[2]; GameInformation.Agility = levelPointsToAllocate[3]; GameInformation.Intelect = levelPointsToAllocate[4]; GameInformation.Resistance = levelPointsToAllocate[5]; GameInformation.MagicResistance = levelPointsToAllocate[6]; GameInformation.PlayerName = name; GameInformation.PlayerLevel = Convert.ToInt32(level); GameInformation.Gold = Convert.ToInt32(gold); GameInformation.CurrentXP = Convert.ToInt32(currentXP); GameInformation.RequiredXP = Convert.ToInt32(requiredXP); GameInformation.AvailableLevelPoints = Points.LevelPoints; GameInformation.AvailableLevelPoints = Points.LevelPoints; SaveInformation.SaveAllInformation(); commitedPoints = true; Combat.healthCheckedOnce = false; Combat.energyCheckOnce = false; Combat.manaCheckOnce = false; Combat.damageCheckedOnce = false; ClickToMove.checkSpeedOnce = false; ProjectileStrike.checkRangeDamage = false; PopulatePanel(); }
public void Load() { using (StreamReader r = new StreamReader(filename)) { string json = r.ReadToEnd(); SaveInformation loadInfo = JsonUtility.FromJson <SaveInformation>(json); CustomerManager.Instance.allCustomers = loadInfo.allCustomers; DayCycle.Instance.LoadDay(loadInfo.dayNumber); Budget.Instance.LoadFunds(loadInfo.budget); loadInfo.waiters .ForEach(w => RestaurantManager.Instance.InstantateWorker(new Waiter(w))); loadInfo.hosts .ForEach(w => RestaurantManager.Instance.InstantateWorker(new Host(w))); loadInfo.cooks .ForEach(w => RestaurantManager.Instance.InstantateWorker(new Cook(w))); Storage.Instance.products = loadInfo.products; loadInfo.activeRecipes .ForEach(a => RecipeManager.Instance.AddActiveRecipe(a)); Person.LastIdUsed = lastPersonId; } }
void OnGUI() { // Add all the other classes soon playerName = GUILayout.TextArea(playerName, 15); isMageClass = GUILayout.Toggle(isMageClass, "Mage Class"); isWarriorClass = GUILayout.Toggle(isWarriorClass, "Warrior Class"); if (GUILayout.Button("Create")) { if (isMageClass) { newPlayer.PlayerClass = new BaseMageClass(); } else if (isWarriorClass) { newPlayer.PlayerClass = new BaseWarriorClass(); } CreateNewPlayer(); StoreNewPlayerInfo(); SaveInformation.SaveAllInformation(); } if (GUILayout.Button("Load")) { SceneManager.LoadScene("Test"); } }
/// <summary> /// Overwrite the current save with a new one /// </summary> /// <param name="file"></param> void Rewrite(SaveInformation file) { saveInfo.SpiderHealth = file.SpiderHealth; saveInfo.playerPosition = file.playerPosition; saveInfo.FrogsKilled = file.FrogsKilled; saveInfo.dialogNumber = file.dialogNumber; saveInfo.screens = file.screens; }
public void AssignID() { GameInformation.UserID = UniqueID.GetID(); SaveInformation.SaveAllInformation(); Debug.Log(GameInformation.UserID); }