public static void read(out SaveProfile instance) { string currentDirectory = Directory.GetCurrentDirectory(); string path = currentDirectory + "\\setting.xml"; if (File.Exists(path)) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(SaveProfile)); TextReader textReader = new StreamReader(path); instance = (SaveProfile)xmlSerializer.Deserialize(textReader); textReader.Close(); } else { instance = new SaveProfile { look = 5f, blink = 5f, wink_l = 5f, wink_r = 5f, brow = 5f, teeth = 5f, smile = 5f, smirk_l = 5f, smirk_r = 5f }; } }
public void Set(int index, SaveProfile profile, LoadPanel panel) { this.loadPanel = panel; this.index = index; countText.text = index.ToString(); lvlText.text = profile.lvl.ToString(); essenceText.text = profile.essence.ToString(); timePlayedText.text = GetFormattedTime(profile.timePlayed); button.onClick.RemoveAllListeners(); button.onClick.AddListener(() => panel.LoadSlot(profile)); transform.Find("Button").GetComponent <ProfileSlotOnSelect>().Set(index, panel); }
public IEnumerator SaveTestWithEnumeratorPasses() { SaveProfile p = new SaveProfile(0, 0, 0, 0, 0, 0, null, null, null, null, null, null, 0, false, false, false, false, false, 0, 0, 0, 0, 0, null); SaveManager.SaveProfile(p); SaveProfile pp = SaveManager.LoadProfile(0); yield return(new WaitForFixedUpdate()); Debug.Log(p.id + " " + pp.id); Assert.AreEqual(p.id, pp.id); }
public static void save(SaveProfile instance) { string currentDirectory = Directory.GetCurrentDirectory(); string path = currentDirectory + "\\setting.xml"; if (!File.Exists(path)) { FileStream fileStream = File.Create(path); fileStream.Close(); } XmlSerializer xmlSerializer = new XmlSerializer(typeof(SaveProfile)); TextWriter textWriter = new StreamWriter(path); xmlSerializer.Serialize(textWriter, instance); textWriter.Close(); }
public SaveProfile GetCurrentProfile() { List <int> inventoryAmounts; List <string> inventoryItems = equipment.GetItemIds(out inventoryAmounts); List <int> hubChestAmounts; List <string> hubChestItems = hubChest.GetItemIds(out hubChestAmounts); SaveProfile p = new SaveProfile(currentProfileID, level, essence, storedEssence, timePlayed, numberOfDeaths, inventoryItems, inventoryAmounts, hubChestItems, hubChestAmounts, enemyKillCount, checkpoints, lastHubPortalID, hubUnloked, playerMovement.dashUnlocked, playerMovement.midAirDashUnlocked, playerMovement.downwardAttackUnlocked, playerMovement.wallJumpingUnlocked, playerMovement.maxJumpCount, playerMovement.dashDistance, playerMovement.minDelayBetweenDashes, playerMovement.maxMidairDashesCount, playerMovement.invincibilityFrameTime, hubSaveState); return(p); }
private void OnModMessage(object sender, StardewModdingAPI.Events.ModMessageReceivedEventArgs e) { if (e.FromModID != iTile.ModID) { return; } SaveManager saveMng = CoreManager.Instance.saveManager; if (!Context.IsMainPlayer && e.Type == sessionDataKey) { SaveProfile session = e.ReadAs <SaveProfile>(); if (session != null) { saveMng.InitSessionExternal(session); } } else if (e.Type == pasteActionKey) { Packet data = e.ReadAs <Packet>(); string locName = data.LocationName; if (data == null || data.TileProfile == null || string.IsNullOrEmpty(locName)) { return; } if (saveMng.session != null) { saveMng.session.GetLocationProfileSafe(locName).HandleTileReplacement(data.TileProfile, false); } } else if (e.Type == restoreActionKey) { Packet data = e.ReadAs <Packet>(); string locName = data.LocationName; if (data == null || data.LayerId == null || string.IsNullOrEmpty(locName)) { return; } if (saveMng.session != null) { saveMng.session.GetLocationProfileSafe(locName).RestoreTile(data.Position, data.LayerId, false); } } }
public void LoadFromProfile(SaveProfile profile) { currentProfileID = profile.id; timePlayed = profile.timePlayed; level = profile.lvl; essence = profile.essence; storedEssence = profile.essenceStored; numberOfDeaths = profile.numberOfDeaths; lastHubPortalID = profile.lastHubPortalID; hubUnloked = profile.hubUnloked; enemyKillCount = profile.enemyKillCount != null ? profile.enemyKillCount : new Dictionary <string, int>(); checkpoints = profile.checkpoints; numberOfDeaths = profile.numberOfDeaths; playerMovement.dashUnlocked = profile.dashUnlocked; playerMovement.midAirDashUnlocked = profile.midAirDashUnlocked; playerMovement.downwardAttackUnlocked = profile.downwardAttackUnlocked; playerMovement.wallJumpingUnlocked = profile.wallJumpingUnlocked; playerMovement.maxJumpCount = profile.maxJumpCount; playerMovement.dashDistance = profile.dashDistance; playerMovement.minDelayBetweenDashes = profile.minDelayBetweenDashes; playerMovement.maxMidairDashesCount = profile.maxMidairDashesCount; playerMovement.invincibilityFrameTime = profile.invincibilityFrameTime; hubSaveState = profile.hubSaveState; SetItemStats(); CalculateLevelUpPrice(); statusGUI.UpdateEssenceText(); statusGUI.UpdateHealthbar(); statusGUI.UpdateInventoryStats(); statusGUI.UpdateLevelText(); // cia tik pavyzdys kaip gauti kill count, gali istrint ar uzkomentuoti print("EnemyKillCounts: "); print("Executioner: " + GetEnemyKillCount(typeof(AI_Executioner))); print("male naga: " + GetEnemyKillCount(typeof(AI_MaleNaga))); print("male naga enraged: " + GetEnemyKillCount(typeof(AI_MaleNagaEnraged))); print("female naga: " + GetEnemyKillCount(typeof(AI_FemaleNaga))); print("female naga enraged: " + GetEnemyKillCount(typeof(AI_FemaleNagaEnraged))); print("fire golem: " + GetEnemyKillCount(typeof(AI_FireGolem))); print("ghoul: " + GetEnemyKillCount(typeof(AI_Ghoul))); print("imp: " + GetEnemyKillCount(typeof(AI_Imp))); print("necromancer: " + GetEnemyKillCount(typeof(AI_Necromancer))); print("slug: " + GetEnemyKillCount(typeof(AI_Slug))); }
public void LoadGame(int profileID = -1) { if (profileID == -1) { profileID = 0; } SaveProfile profile = SaveManager.LoadProfile(profileID); //print(profile); player.LoadFromProfile(profile); player.equipment.LoadByIds(profile.itemsInInventory, profile.itemInInventoryAmounts); player.hubChest.LoadByIds(profile.itemsInHubChest, profile.itemInHubChestAmounts); player.SetItemStats(); player.statusGUI.UpdateInventoryStats(); player.statusGUI.UpdatePotionCharges(); settings = SaveManager.LoadSettings(); }
public void SaveGame(bool force = false) { if (!force) { if (gameSavingAfterIntervalRoutine == null) { gameSavingAfterIntervalRoutine = StartCoroutine(SaveGameAfterInterval(0.5f)); } } else { SaveProfile profile = player.GetCurrentProfile(); SaveManager.SaveProfile(profile); settings.lastSavedProfile = profile.id; SaveManager.SaveSettings(settings); } }
public static void ExhangeProfiles(int id1, int id2) { Debug.Log("Exchanging profiles: " + id1 + " and " + id2); if (id1 == id2) { return; } SaveProfile p1 = LoadProfile(id1); SaveProfile p2 = LoadProfile(id2); int tmp = p1.id; p1.id = p2.id; p2.id = tmp; SaveProfile(p1); SaveProfile(p2); }
protected override void OnTriggerActivate(Collider2D other) { if (!saved && other.CompareTag("Player")) { PlayerUpgrades upgrades = other.GetComponent <PlayerUpgrades>(); if (upgrades) { GameData gameData = upgrades.GetDataForSaving(); if (gameData != null) { DialogueHandler.instance.StartDialogue(saveDialogue); saved = true; gameData.spawnLocation = this.UniqueID; SaveProfile saveProfile = new SaveProfile(gameData.ProfileName, true); saveProfile.Save(gameData); } else { Debug.LogWarning("SaveStation: " + nameof(GameData) + " is null."); } } else { Debug.LogWarning("SaveStation: Player doesn't have " + nameof(PlayerUpgrades) + " component."); } Health health = other.GetComponent <Health>(); if (health) { health.Heal(health.MaxHP); } else { Debug.LogWarning("SaveStation: Player doesn't have" + nameof(Health) + " component."); } } }
private void CreateGame() { if (!loadStarted) { if (string.IsNullOrWhiteSpace(textMesh.text)) { textMesh.text = "Invalid name"; return; } SaveProfile saveProfile = new SaveProfile(textMesh.text); defaultGameData.ProfileName = textMesh.text; saveProfile.Save(defaultGameData); loadStarted = true; SceneLoader loader = new SceneLoader(loadingScene); loader.ScenesToUnload.Add(gameObject.scene.name); if (isIntroEnabled) { loader.ScenesToLoad.Add(introStartScene); } else { loader.ScenesToLoad.Add(playerScene); loader.Destination = defaultGameData.spawnLocation; } loader.GameData = defaultGameData; try { loader.FadeScenes(); } catch (InvalidOperationException e) { loadStarted = false; } } }
private void Messenger_Unload(object sender, EventArgs eventArgs) { SaveProfile?.Invoke(this, EventArgs.Empty); }
private void Start() { MainMenu.node = new int[18]; for (int i = 0; i < 18; i++) { MainMenu.node[i] = 0; } if (this.headArea == new Rect(0f, 0f, 0f, 0f)) { this.headArea = new Rect(600f, 70f, 225f * this.int_scale, 200f * this.int_scale); } if (this.head == new Rect(0f, 0f, 0f, 0f)) { this.head = new Rect(0f, 0f, 200f * this.int_scale, 200f * this.int_scale); } this.sp = new SaveProfile(); try { EmotivProfile.read(out this.sp); EdkDll.EE_ExpressivSetThreshold(0u, EdkDll.EE_ExpressivAlgo_t.EXP_HORIEYE, EdkDll.EE_ExpressivThreshold_t.EXP_SENSITIVITY, (int)(100f * this.sp.look)); EdkDll.EE_ExpressivSetThreshold(0u, EdkDll.EE_ExpressivAlgo_t.EXP_BLINK, EdkDll.EE_ExpressivThreshold_t.EXP_SENSITIVITY, (int)(100f * this.sp.blink)); EdkDll.EE_ExpressivSetThreshold(0u, EdkDll.EE_ExpressivAlgo_t.EXP_WINK_LEFT, EdkDll.EE_ExpressivThreshold_t.EXP_SENSITIVITY, (int)(100f * this.sp.wink_l)); EdkDll.EE_ExpressivSetThreshold(0u, EdkDll.EE_ExpressivAlgo_t.EXP_WINK_RIGHT, EdkDll.EE_ExpressivThreshold_t.EXP_SENSITIVITY, (int)(100f * this.sp.wink_r)); EdkDll.EE_ExpressivSetThreshold(0u, EdkDll.EE_ExpressivAlgo_t.EXP_EYEBROW, EdkDll.EE_ExpressivThreshold_t.EXP_SENSITIVITY, (int)(100f * this.sp.brow)); EdkDll.EE_ExpressivSetThreshold(0u, EdkDll.EE_ExpressivAlgo_t.EXP_CLENCH, EdkDll.EE_ExpressivThreshold_t.EXP_SENSITIVITY, (int)(100f * this.sp.teeth)); EdkDll.EE_ExpressivSetThreshold(0u, EdkDll.EE_ExpressivAlgo_t.EXP_SMILE, EdkDll.EE_ExpressivThreshold_t.EXP_SENSITIVITY, (int)(100f * this.sp.smile)); EdkDll.EE_ExpressivSetThreshold(0u, EdkDll.EE_ExpressivAlgo_t.EXP_SMIRK_RIGHT, EdkDll.EE_ExpressivThreshold_t.EXP_SENSITIVITY, (int)(100f * this.sp.smirk_r)); EdkDll.EE_ExpressivSetThreshold(0u, EdkDll.EE_ExpressivAlgo_t.EXP_SMIRK_LEFT, EdkDll.EE_ExpressivThreshold_t.EXP_SENSITIVITY, (int)(100f * this.sp.smirk_l)); } catch (Exception var_1_1F3) { } }