public static void SendFinalShipPartChoice() { Dictionary <string, object> dict = new Dictionary <string, object>(); dict.Add("time", DateTime.Now); int num; //This is designed to accommodate additional eShipPartTypes foreach (ShipPart.eShipPartType type in (ShipPart.eShipPartType[]) Enum.GetValues(typeof(ShipPart.eShipPartType))) { if (dict.Count == 10) { //This is necessary because AnalyticsEvent.Custom has a hard //Limit on this dict size of 10, according to //https://docs.unityed.com/Manual/UnityAnalyticsCustomEventsSDK.html break; } num = ShipCustomizationPanel.GetSelectedPart(type); dict.Add(type.ToString(), num); } AnalyticsEvent.Custom("ShipPartChoice", dict); }
static public void DeleteSave() { if (File.Exists(filePath)) { File.Delete(filePath); saveFile = new SaveFile(); Debug.Log("SaveGameManager:DeleteSave() – Successfully deleted save file."); } else { Debug.LogWarning("SaveGameManager:DeleteSave() – Unable to find and delete save file!" + " This is absolutely fine if you've never saved or have just deleted the file."); } // Lock the file to prevent any saving LOCK = true; // Select the basic ShipParts ShipCustomizationPanel.SelectPart(ShipPart.eShipPartType.body, 0); ShipCustomizationPanel.SelectPart(ShipPart.eShipPartType.turret, 0); // Clear the Steps & Achievements AchievementManager.ClearStepsAndAchievements(); // Unlock the file LOCK = false; }
static public void AnnounceAchievementCompletion(Achievement ach) { ShipCustomizationPanel.UnlockPart(ach.partType, ach.partNum); string desc = ach.description.Replace("#", ach.stepCount.ToString("N0")); S.TriggerPopUp(ach.name, desc); }
static public void Load() { if (File.Exists(filePath)) { string dataAsJson = File.ReadAllText(filePath); #if DEBUG_VerboseConsoleLogging Debug.Log("SaveGameManager:Load() – File text is:\n" + dataAsJson); #endif try { saveFile = JsonUtility.FromJson <SaveFile>(dataAsJson); } catch { Debug.LogWarning("SaveGameManager:Load() – SaveFile was malformed.\n" + dataAsJson); return; } #if DEBUG_VerboseConsoleLogging Debug.Log("SaveGameManager:Load() – Successfully loaded save file."); #endif LOCK = true; // Load the Achievements AchievementManager.LoadDataFromSaveFile(saveFile); // Load the selected ShipParts ShipCustomizationPanel.SelectPart(ShipPart.eShipPartType.body, saveFile.selectedBody); ShipCustomizationPanel.SelectPart(ShipPart.eShipPartType.turret, saveFile.selectedTurret); LOCK = false; } else { #if DEBUG_VerboseConsoleLogging Debug.LogWarning("SaveGameManager:Load() – Unable to find save file. " + "This is totally fine if you've never gotten a game over " + "or completed an Achievement, which is when the game is saved."); #endif LOCK = true; // Init Achievements AchievementManager.ClearStepsAndAchievements(); // Init the selected ShipParts ShipCustomizationPanel.SelectPart(ShipPart.eShipPartType.body, 0); ShipCustomizationPanel.SelectPart(ShipPart.eShipPartType.turret, 0); LOCK = false; } }
void UnlockPartsAfterLoadingGame() { foreach (Achievement ach in achievements) { if (ach.complete) { ShipCustomizationPanel.UnlockPart(ach.partType, ach.partNum); } else { ShipCustomizationPanel.LockPart(ach.partType, ach.partNum); } } }
void UnlockAchievement(int achievementNumberInList) { if (achievementNumberInList == -1) { achievementNameDisplay.text = "HIGH SCORE"; achievementDescriptionDisplay.text = "You've achieved a new high score."; } else { achievementNameDisplay.text = Achievements[achievementNumberInList].name; achievementDescriptionDisplay.text = Achievements[achievementNumberInList].description; ShipCustomizationPanel.UnlockPart(Achievements[achievementNumberInList].partType, Achievements[achievementNumberInList].partNum); CustomAnalytics.SendAchievementUnlocked(Achievements[achievementNumberInList]); } anim.SetBool("Achievement appear", true); Invoke("AchievementDisappear", durationOfShowingAchievement); SaveGameManager.Save(); }
static public void Save() { // If this is LOCKed, don't save if (LOCK) { return; } saveFile.stepRecords = AchievementManager.GetStepRecords(); saveFile.achievements = AchievementManager.GetAchievements(); saveFile.selectedBody = ShipCustomizationPanel.GetSelectedPart(ShipPart.eShipPartType.body); saveFile.selectedTurret = ShipCustomizationPanel.GetSelectedPart(ShipPart.eShipPartType.turret); string jsonSaveFile = JsonUtility.ToJson(saveFile, true); File.WriteAllText(filePath, jsonSaveFile); #if DEBUG_VerboseConsoleLogging Debug.Log("SaveGameManager:Save() – Path: " + filePath); Debug.Log("SaveGameManager:Save() – JSON: " + jsonSaveFile); #endif }