void Awake() { // if Ropework manager is null, then find it if (ropework == null) { ropework = FindObjectOfType <Ropework.RopeworkManager>(); } // Start by hiding the container, line and option buttons if (dialogueContainer != null) { dialogueContainer.SetActive(false); } lineText.gameObject.SetActive(false); foreach (var button in optionButtons) { button.gameObject.SetActive(false); } // Hide the continue prompt if it exists if (continuePrompt != null) { continuePrompt.SetActive(false); } // Set the text speed from user settings this.textSpeed = SaveGameManager.GetCurrentGame().TextSpeed; }
void Start() { if (loadIfExists) { // Load test if (SaveGameManager.SaveGameExists) { Debug.Log("Save exists, loading."); testSaveGame = SaveGameManager.LoadGame(); } else { Debug.Log("Save file does not exist."); SaveGameManager.SaveGame(testSaveGame); } } if (deleteIfExists) { // Delete test SaveGameManager.DeleteSaveGame(); if (SaveGameManager.SaveGameExists) { Debug.Log("Save still exists, deleting failed."); } else { Debug.Log("Save deleted."); } } }
private void Awake() { if (_instance == null) { _instance = this; } else if (_instance == this) { Destroy(gameObject); } int saveGameManager = FindObjectsOfType <SaveGameManager>().Length; if (saveGameManager != 1) { Destroy(this.gameObject); } else { DontDestroyOnLoad(gameObject); } saveFile = new SaveFile(); filePath = Application.persistentDataPath + "/CarWar.save"; }
public static void saveProfile() { string data = _profile.toJSON().ToString(); SavedProfile tmpProfile = new SavedProfile(data); SaveGameManager.saveDataByUser <SavedProfile>(GameConstants.profileKey, tmpProfile); }
void Awake() { Instance = this; m_gameData = new GameData(); m_saveDataHash = new Hashtable(); SaveGameManager.LoadData(); }
public void AddPlayer(Player player) { //We do this even if fog of war is currently disabled (so we can enable it at any time) m_IsExplored = true; //Also explore all our neighbours for (int i = 0; i <= (int)Direction.West; ++i) { Node neighbour = m_Neighbours[i]; if (neighbour != null) { neighbour.Explore(); } } //Nodes dissapear mode if (SaveGameManager.GetBool(SaveGameManager.SAVE_OPTION_NODESDISAPPEAR, false)) { m_IsAccessible = false; } //Let the world know if (PlayerEnterEvent != null) { PlayerEnterEvent(player); } }
public void ModHealth(int mod) { health += mod; healthText.text = health.ToString(); hpBar.UpdateHP((float)health / (float)maxHealth); if (mod < 0) { GetComponent <Animator>().SetTrigger("Damage"); } if (health <= 0) { print("Victory!"); if (CombatInfo.FightType != -1) { CombatInfo.CombatsFinished++; } else { CombatInfo.HealthPotionCount = 3; } if (CombatInfo.FightType == -1) { CombatInfo.FightType = 0; } SaveGameManager.SaveGame(new Vector3(0, 0, 0), CombatInfo.CombatsFinished); GameState.curHealth = cm.player.health; CombatInfo.CoinCount += CombatInfo.CoinsToDrop; Die(); } }
/// <summary> /// Loads the saved level. /// </summary> /// <param name='data'> The data describing the level to load </param> public static LevelLoader LoadSavedLevel(string data) { LevelData ld; IsDeserializing = true; if (data.StartsWith("NOCOMPRESSION")) { ld = UnitySerializer.Deserialize <LevelData>(Convert.FromBase64String(data.Substring(13))); } else { ld = UnitySerializer.Deserialize <LevelData>(CompressionHelper.Decompress(data)); } SaveGameManager.Loaded(); var go = new GameObject(); Object.DontDestroyOnLoad(go); var loader = go.AddComponent <LevelLoader>(); loader.Data = ld; Application.LoadLevel(ld.Name); return(loader); }
/// <summary> /// Saves the game. /// </summary> public void SaveGame() { var save = new SaveGame(); if (HeroManager != null) { HeroManager.Save(ref save); } if (AbilityManager != null) { AbilityManager.Save(ref save); } if (RosterManager != null) { RosterManager.Save(ref save); } if (InventoryManager != null) { InventoryManager.Save(ref save); } if (WorldManager != null) { WorldManager.Save(ref save); } save.LastRewardTime = lastRewardTime; save.IsFilled = true; SaveGameManager.SaveGame(save); }
/// <summary> /// Save the current game with the provided name. /// </summary> public void SaveGame() { // Do nothing if the input field is empty. string baseFileName = this.inputField.text.RemoveEnd(".tscgame"); if (IsInvalidBaseFileName(baseFileName)) { return; } // Otherwise, create a Path object from the provided text content and check it for validity. If the file // path provided is illegal, then simply return. // TODO_LATER Add a message about illegal file name. PathInst targetPath = SaveGameManager.InitializeSaveFilePathFromFileName($"{baseFileName}.tscgame"); string path = targetPath.ToString(); if (!LocalFileUtils.ValidateDllPath(ref path)) { return; } // Save the game at the desired path. SaveGameManager.SaveGame(SaveFile.CreateSaveFile(this.gameSceneManager.gameState), targetPath); // Clear out the text input, and reload the saved games. this.inputField.text = ""; this.LoadSavedGames(); }
public void SetBody(uint index) { if (body != null && PlayerScriptableObject.GetBody(index) != null) { if (body.name != PlayerScriptableObject.GetBody(index).name) { Destroy(body); } } //log here if (body == null) { body = Instantiate(PlayerScriptableObject.GetBody(index)); if (bodyParent.transform != null) { body.transform.parent = bodyParent.transform; body.transform.localPosition = Vector3.zero; body.transform.localRotation = Quaternion.identity; body.name = PlayerScriptableObject.GetBody(index).name; SaveGameManager.Save(); } } //log here }
public void SetTurret(uint index) { if (turret != null && PlayerScriptableObject.GetTurret(index) != null) { if (turret.name != PlayerScriptableObject.GetTurret(index).name) { Destroy(turret); } } //log here if (turret == null) { turret = Instantiate(PlayerScriptableObject.GetTurret(index)); if (turretParent.transform != null) { turret.transform.parent = turretParent.transform; turret.transform.localPosition = Vector3.zero; turret.transform.localRotation = Quaternion.AngleAxis(90, Vector3.right); turret.name = PlayerScriptableObject.GetTurret(index).name; SaveGameManager.Save(); } } //log here }
/// <summary> /// Increments one of the StepRecords that can unlock Achievements. /// </summary> /// <param name="stepType">The eStepType to increment.</param> /// <param name="num">The amount to increment (default = 1).</param> static public void AchievementStep(Achievement.eStepType stepType, int num = 1) { StepRecord sRec = STEP_REC_DICT[stepType]; if (sRec != null) { sRec.Progress(num); // Iterate through all of the possible Achievements and see if the step // completes the Achievement foreach (Achievement ach in S.achievements) { if (!ach.complete) { // Pass the step information to the Achievement, to see if it is completed if (ach.CheckCompletion(stepType, sRec.num)) { // The result is true if the Achievement was newly completed AnnounceAchievementCompletion(ach); // Tell Unity Analytics that the Achievement has been completed // Also save the game any time we complete an Achievement SaveGameManager.Save(); } } } } else { Debug.LogWarning("AchievementManager:AchievementStep( " + stepType + ", " + num + " )" + "was passed a stepType that is not in STEP_REC_DICT."); } }
static public void AddScore(int num) { // Find the ScoreGT Text field only once. if (SCORE_GT == null) { GameObject go = GameObject.Find("ScoreGT"); if (go != null) { SCORE_GT = go.GetComponent <UnityEngine.UI.Text>(); } else { Debug.LogError("AsteraX:AddScore() - Could not find a GameObject named ScoreGT."); return; } SCORE = 0; } // SCORE holds the definitive score for the game. SCORE += num; if (!GOT_HIGH_SCORE && SaveGameManager.CheckHighScore(SCORE)) { // We just got the high score GOT_HIGH_SCORE = true; // Announce it using the AchievementPopUp AchievementPopUp.ShowPopUp("High Score!", "You've achieved a new high score."); } // Show the score on screen. For info on numeric formatting like "N0", see: // https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings SCORE_GT.text = SCORE.ToString("N0"); AchievementManager.AchievementStep(Achievement.eStepType.scoreAttained, SCORE); }
// Use this for initialization void Start() { _receivedPayload = GameObject.FindGameObjectWithTag("DreamPayload").GetComponent <DreamPayload>(); if (_receivedPayload == null) { return; } if (!_receivedPayload.DreamEnded) { return; } MainMenu.ChangeMenuState(UIMainMenu.MenuState.GRAPH); DreamDirector.AddPayloadToPriorDreams(_receivedPayload); DreamDirector.CurrentDay++; SaveGameManager.SaveCurrentGame(); // TODO: save game data to file // TODO: load from save file and populate graph _receivedPayload.ClearPayload(); Fader.FadeOut(0.5F); }
void Awake() { if (instance == null) { instance = this; } }
private void Awake() { #region Singleton Pattern SaveGameManager instance // check if instance already exists if (Instance == null) { // if not, set instance to this Debug.Log("SaveGameManager Instance created"); Instance = this; } // if instance already exists and it's not this: else if (Instance != null) { // then destroy this. this enforces our singleton pattern, meaning there can only ever be one instance of the SaveGameManager Debug.Log("SaveGameManager Instance already exists this.destroyed"); Destroy(gameObject); } DontDestroyOnLoad(this); #endregion // remove productName from the SaveGameBaseDirectory string tempPath = Application.persistentDataPath; SaveGameBaseDirectory = tempPath.Replace(Application.productName, ""); }
// Start is called before the first frame update void Start() { save = SaveGameManager.Load(); loveMeter.GetComponent <ProgressBar> ().current = save.love; hungerMeter.GetComponent <ProgressBar> ().current = save.hunger; tidynessMeter.GetComponent <ProgressBar> ().current = save.tidyNess; // Instantiate a poop prefab for every poop position foreach (PoopPosition poop in save.poopPositions) { Instantiate(poopModel, poop.returnVector(), Quaternion.Euler(0, 0, 0)); } save.poopPositions.Clear(); anim = gameObject.GetComponent <Animator> (); angry = gameObject.GetComponent <MeshRenderer> (); foreach (GameObject emotion in emojiMeshes) { emotionType.Add(emotion.name, emotion); } //private int timePassedSinceQuit = (int)SaveGameManager.loadMinusSave.TotalSeconds ; //loveMeter.GetComponent<ProgressBar> ().current -= (int)SaveGameManager.loadMinusSave.TotalSeconds * 1; //hungerMeter.GetComponent<ProgressBar> ().current += (int)SaveGameManager.loadMinusSave.TotalSeconds * 1; //loveMeter.GetComponent<ProgressBar> ().current -= (int)SaveGameManager.loadMinusSave.TotalSeconds * 1; InvokeRepeating("heightenNeeds", 1, 1); }
// Use this for initialization void Start() { if (S == null) { S = this; // Set the Singleton // a } else { Debug.LogError("AchievementManager.Awake() - Attempted to assign second AchievementManager.S!"); } if (SaveGameManager.Load() != null) { achievements = SaveGameManager.Load(); } ACH_DICT = new Dictionary <WeaponType, Achievement>(); for (int i = 0; i < achievements.Length; i++) { Achievement ach = achievements[i]; ACH_DICT[ach.type] = ach; Renderer cubeRend = achievementBoxes[i].transform.Find("Cube").GetComponent <Renderer>(); cubeRend.material.color = Main.GetWeaponDefinition(ach.type).projectileColor; GameObject chMark = achievementBoxes[i].transform.Find("checkedMark").gameObject; chMark.SetActive(ach.achieved); } }
public void AssignNodeTextCharacters(int seed = -1) { string availableTextCharacters = SaveGameManager.GetString(SaveGameManager.SAVE_LEVEL_TEXTCHARACTERS, "sdfghjkl"); //ClearNodeTextCharacters(); if (seed == -1) { UnityEngine.Random.InitState(System.Environment.TickCount); //Random enough? } else { UnityEngine.Random.InitState(seed); } //Give all the nodes a random character foreach (Node currentNode in m_Nodes) { //Create an array of all still available characters List <char> availableTextCharactersList = new List <char>(availableTextCharacters.ToCharArray()); //Remove characters that our neighbours neighbours have claimed for (int dir = 0; dir <= (int)Direction.West; ++dir) { Node neighbour = currentNode.GetNeighbour((Direction)dir); if (neighbour != null) { //Character this neighbour has claimed (this is allowed, you can have an E next to a another E (the one you're standing on)) //char takenChar = neighbour.GetTextCharacter(); //if (takenChar != '\0') { availableTextCharactersList.Remove(takenChar); } //Characters his neighbours have claimed for (int dir2 = 0; dir2 <= (int)Direction.West; ++dir2) { Node neighbour2 = neighbour.GetNeighbour((Direction)dir2); if (neighbour2 != null) { char takenChar = neighbour2.GetTextCharacter(); if (takenChar != '\0') { availableTextCharactersList.Remove(takenChar); } } } } } if (availableTextCharactersList.Count > 0) { //Pick a random character from the remaining list and assign it int randInt = UnityEngine.Random.Range(0, availableTextCharactersList.Count); currentNode.SetTextCharacter(availableTextCharactersList[randInt]); currentNode.name = currentNode.name + " - " + currentNode.GetTextCharacter(); } } }
protected override void OnUpdate() { this.Entities.With(this._deleteGroup).ForEach((Entity entity) => { SaveGameManager.DeleteSave(); this.PostUpdateCommands.DestroyEntity(entity); }); }
static void Prefix(SaveGameManager __instance) { defaultUseEncryption = __instance.useEncryption; if (isModEnabled) { __instance.useEncryption = false; } }
public void LoadGame() { if (SaveGameManager.CheckSaveEmpty()) { GameManager.newGame = false; } Game(); }
private void LoadGame() { GameData game = SaveGameManager.ReadGame(); PlaceMinionas(game.minionas); LoadStats(game); newGame = true; }
private void Start() { //Alter the settings to be super indie SaveGameManager.SetBool(SaveGameManager.SAVE_OPTION_NEWCHARSONMISTAKE, false); SaveGameManager.SetBool(SaveGameManager.SAVE_OPTION_FOGOFWAR, true); SaveGameManager.SetBool(SaveGameManager.SAVE_OPTION_NODESDISAPPEAR, false); SaveGameManager.SetBool(SaveGameManager.SAVE_OPTION_SCREENSHAKE, true); }
void Start() { GameObject.FindObjectOfType <SoundManager>().Play("Main"); if (!SaveGameManager.CheckSaveEmpty()) { button.interactable = false; } }
static public void GameOver() { SaveGameManager.CheckHighScore(SCORE); SaveGameManager.Save(); CustomAnalytics.SendFinalShipPartChoice(); CustomAnalytics.SendGameOver(); _S.EndGame(); }
public void SaveToLocal(string _key, object _value) { m_saveDataHash[_key] = _value; SaveGameManager.SaveData(m_saveDataHash); #if UNITY_EDITOR Debug.Log("save key: " + _key + " value: " + _value); #endif }
/// <summary> /// Resets the game when the button is clicked. /// </summary> public void ResetGame() { DestroyImmediate(GameManager.Instance.gameObject); var wasDeleted = SaveGameManager.DeleteSaveGame(); Debug.Log("DELETED GAME: " + wasDeleted); SceneManager.LoadScene("Start"); }
/// <inheritdoc /> /// <summary> /// Save the new value to the current save game whenever the value gets changed. /// </summary> /// <param name="input"></param> /// <param name="sendFeedBack"></param> protected override void Set(float input, bool sendFeedBack) { base.Set(input, sendFeedBack); if (sendFeedBack) { SaveGameManager.GetCurrentGame().TextSpeed = 1f - input; } }
public static SaveGameManager instance() { if (self==null) { self = new SaveGameManager(); //self.init(); } return self; }
public void cargarDatos(dbAccess dbacces) { SaveGameManager sgm = new SaveGameManager(); dbacces.OpenReadDB(); sgm = dbacces.Sgm; #region CargaArma controlLogico.SetArmas(sgm.ControlLogico.GetArmas()); #endregion #region CargarEscenarios controlLogico.SetListEscenario(sgm.ControlLogico.GetListEscenario()); #endregion #region CargaMembrecias controlLogico.SetMembresia(sgm.ControlLogico.GetMembresia()); #endregion #region cargaPuntuacion controlLogico.SetPuntuacion(sgm.ControlLogico.GetPuntuacion()); #endregion #region cargaPersonajes personajes = sgm.Personajes; #endregion #region Idioma lenguaje = sgm.Lenguaje; #endregion #region Navegacion navegacion = sgm.Navegacion; #endregion }
void InitSave() { SaveManager = new SaveGameManager(); }
public static void Save(string filePath, GameManager manager) { SaveGameManager data = new SaveGameManager (); data.level = manager.level; data.canDash = manager.canDash; data.canZoom = manager.canZoom; data.deaths = manager.deaths; data.canDoubleJump = manager.canDoubleJump; data.paused = manager.paused; data.username = manager.username; data.timer = manager.timer; //Debug.Log (data.level); Stream stream = File.Open(filePath, FileMode.Create); BinaryFormatter bformatter = new BinaryFormatter(); bformatter.Binder = new VersionDeserializationBinder(); bformatter.Serialize(stream, data); stream.Close(); }
public object GetAsset(SaveGameManager.AssetReference id) { if (id.index == -1) { return null; } object result; try { Type typeEx = UnitySerializer.GetTypeEx(id.type); Index<string, List<UnityEngine.Object>> index; if (!this.assetReferences.TryGetValue(typeEx, out index)) { index = (this.assetReferences[typeEx] = new Index<string, List<UnityEngine.Object>>()); IEnumerable<UnityEngine.Object> enumerable = Resources.FindObjectsOfTypeAll(typeEx).Except(UnityEngine.Object.FindObjectsOfType(typeEx)); foreach (UnityEngine.Object current in enumerable) { index[current.name].Add(current); } } List<UnityEngine.Object> list; if (!index.TryGetValue(id.name, out list)) { result = null; } else if (id.index >= list.Count) { result = null; } else { result = list[id.index]; } } catch { result = null; } return result; }
private void Awake() { if (this.Reference == null) { this.Reference = ScriptableObject.CreateInstance<StoredReferences>(); } if (Application.isEditor) { this.GetAllInactiveGameObjects(); } if (SaveGameManager.Instance != null && SaveGameManager.Instance != this) { UnityEngine.Object.Destroy(SaveGameManager.Instance.gameObject); } SaveGameManager.Instance = this; this.hasWoken = true; if (Application.isPlaying && !SaveGameManager.hasRun) { SaveGameManager._cached = this.Reference; SaveGameManager.hasRun = true; } else if (!Application.isPlaying) { SaveGameManager.hasRun = false; if (SaveGameManager._cached != null && SaveGameManager._cached.Count > 0) { this.Reference = SaveGameManager._cached.Alive(); } } if (SaveGameManager._initActions.Count > 0) { foreach (Action current in SaveGameManager._initActions) { current(); } SaveGameManager._initActions.Clear(); } }
private void Awake() { if (instance == null) { DontDestroyOnLoad(gameObject); instance = this; } else if (instance != this) { Destroy(gameObject); } _saveGameFilePath = Application.persistentDataPath + "/SaveGame.dat"; LoadGame(); }
void Awake() { Loom.Initialize(); if(Reference == null) Reference = ScriptableObject.CreateInstance<StoredReferences>(); if(Application.isEditor) { GetAllInactiveGameObjects(); } if(Instance != null && Instance != this) Destroy(Instance.gameObject); Instance = this; hasWoken = true; if(Application.isPlaying && !hasRun) { _cached = Reference; hasRun = true; } else if(!Application.isPlaying ) { hasRun = false; if(_cached != null && _cached.Count > 0) Reference = _cached.Alive(); } if(_initActions.Count > 0) { foreach(var a in _initActions) { a(); } _initActions.Clear(); } }