public static void ReportExceptionToUser(string additionalMessage, Exception e) { string arg = MakeFullErrorMessage(additionalMessage, e); Log.Error($"{arg}\n{e.StackTrace}"); AnalyticsManager.LogError(additionalMessage, e); }
public static void Initialize() { LastLaunchedVersion = SettingsManager.LastLaunchedVersion; SettingsManager.LastLaunchedVersion = Version; if (Version != LastLaunchedVersion) { AnalyticsManager.LogEvent("[VersionsManager] Upgrade game", new AnalyticsParameter("LastVersion", LastLaunchedVersion), new AnalyticsParameter("CurrentVersion", Version)); } }
public static void Initialize() { Log.Information($"Survivalcraft starting up at {DateTime.Now}, Version={VersionsManager.Version}, BuildConfiguration={VersionsManager.BuildConfiguration}, Platform={VersionsManager.Platform}, DeviceModel={DeviceManager.DeviceModel}, OSVersion={DeviceManager.OperatingSystemVersion}, Storage.AvailableFreeSpace={Storage.FreeSpace / 1024 / 1024}MB, ApproximateScreenDpi={ScreenResolutionManager.ApproximateScreenDpi:0.0}, ApproxScreenInches={ScreenResolutionManager.ApproximateScreenInches:0.0}, ScreenResolution={Window.Size}, ProcessorsCount={Environment.ProcessorCount}, RAM={Utilities.GetTotalAvailableMemory() / 1024 / 1024}MB, 64bit={Marshal.SizeOf<IntPtr>() == 8}"); MarketplaceManager.Initialize(); SettingsManager.Initialize(); AnalyticsManager.Initialize(); VersionsManager.Initialize(); ExternalContentManager.Initialize(); ContentManager.Initialize(); ScreensManager.Initialize(); }
public override void Update() { if (Children.Find <ButtonWidget>("Buy").IsClicked) { AnalyticsManager.LogEvent("[NagScreen] Clicked buy button"); MarketplaceManager.ShowMarketplace(); ScreensManager.SwitchScreen("MainMenu"); } if (Children.Find <ButtonWidget>("Quit").IsClicked || base.Input.Back) { AnalyticsManager.LogEvent("[NagScreen] Clicked quit button"); Window.Close(); } }
public override void Update() { Keyboard.BackButtonQuitsApp = !MarketplaceManager.IsTrialMode; if (string.IsNullOrEmpty(m_versionString) || MarketplaceManager.IsTrialMode != m_versionStringTrial) { m_versionString = string.Format("Version {0}{1}", VersionsManager.Version, MarketplaceManager.IsTrialMode ? " (Day One)" : string.Empty); m_versionStringTrial = MarketplaceManager.IsTrialMode; } Children.Find("Buy").IsVisible = MarketplaceManager.IsTrialMode; Children.Find <LabelWidget>("Version").Text = m_versionString; RectangleWidget rectangleWidget = Children.Find <RectangleWidget>("Logo"); float num = 1f + 0.02f * MathUtils.Sin(1.5f * (float)MathUtils.Remainder(Time.FrameStartTime, 10000.0)); rectangleWidget.RenderTransform = Matrix.CreateTranslation((0f - rectangleWidget.ActualSize.X) / 2f, (0f - rectangleWidget.ActualSize.Y) / 2f, 0f) * Matrix.CreateScale(num, num, 1f) * Matrix.CreateTranslation(rectangleWidget.ActualSize.X / 2f, rectangleWidget.ActualSize.Y / 2f, 0f); if (Children.Find <ButtonWidget>("Play").IsClicked) { ScreensManager.SwitchScreen("Play"); } if (Children.Find <ButtonWidget>("Help").IsClicked) { ScreensManager.SwitchScreen("Help"); } if (Children.Find <ButtonWidget>("Content").IsClicked) { ScreensManager.SwitchScreen("Content"); } if (Children.Find <ButtonWidget>("Settings").IsClicked) { ScreensManager.SwitchScreen("Settings"); } if (Children.Find <ButtonWidget>("Buy").IsClicked) { AnalyticsManager.LogEvent("[MainMenuScreen] Clicked buy button"); MarketplaceManager.ShowMarketplace(); } if ((base.Input.Back && !Keyboard.BackButtonQuitsApp) || base.Input.IsKeyDownOnce(Key.Escape)) { if (MarketplaceManager.IsTrialMode) { ScreensManager.SwitchScreen("Nag"); } else { Window.Close(); } } }
public static void LaunchBrowser(string url) { AnalyticsManager.LogEvent("[WebBrowserManager] Launching browser", new AnalyticsParameter("Url", url)); if (!url.Contains("://")) { url = "http://" + url; } try { Android.Net.Uri uri = Android.Net.Uri.Parse(url); Intent intent = new Intent("android.intent.action.VIEW", uri); Window.Activity.StartActivity(intent); } catch (Exception ex) { Log.Error($"Error launching web browser with URL \"{url}\". Reason: {ex.Message}"); } }
public static void Download(string address, string name, ExternalContentType type, string userId, CancellableProgress progress, Action success, Action <Exception> failure) { progress = (progress ?? new CancellableProgress()); if (!WebManager.IsInternetConnectionAvailable()) { failure(new InvalidOperationException("Internet connection is unavailable.")); } else { WebManager.Get(address, null, null, progress, delegate(byte[] data) { string hash = CalculateContentHashString(data); ExternalContentManager.ImportExternalContent(new MemoryStream(data), type, name, delegate(string downloadedName) { m_idToAddressMap[MakeContentIdString(type, downloadedName)] = address; Feedback(address, "Success", null, hash, data.Length, userId, progress, delegate { }, delegate { }); AnalyticsManager.LogEvent("[CommunityContentManager] Download Success", new AnalyticsParameter("Name", name)); success(); }, delegate(Exception error) { Feedback(address, "ImportFailure", null, hash, data.Length, userId, null, delegate { }, delegate { }); AnalyticsManager.LogEvent("[CommunityContentManager] Import Failure", new AnalyticsParameter("Name", name), new AnalyticsParameter("Error", error.Message.ToString())); failure(error); }); }, delegate(Exception error) { Feedback(address, "DownloadFailure", null, null, 0L, userId, null, delegate { }, delegate { }); AnalyticsManager.LogEvent("[CommunityContentManager] Download Failure", new AnalyticsParameter("Name", name), new AnalyticsParameter("Error", error.Message.ToString())); failure(error); }); } }
public static void Update() { if (Time.PeriodicEvent(1.0, 0.0)) { TimeSpan t = TimeSpan.FromHours(SettingsManager.MotdUpdatePeriodHours); DateTime now = DateTime.Now; if (now >= SettingsManager.MotdLastUpdateTime + t) { SettingsManager.MotdLastUpdateTime = now; Log.Information("Downloading MOTD"); AnalyticsManager.LogEvent("[MotdManager] Downloading MOTD", new AnalyticsParameter("Time", DateTime.Now.ToString("HH:mm:ss.fff"))); string url = GetMotdUrl(); WebManager.Get(url, null, null, null, delegate(byte[] result) { try { string motdLastDownloadedData = UnpackMotd(result); MessageOfTheDay = null; SettingsManager.MotdLastDownloadedData = motdLastDownloadedData; Log.Information("Downloaded MOTD"); AnalyticsManager.LogEvent("[MotdManager] Downloaded MOTD", new AnalyticsParameter("Time", DateTime.Now.ToString("HH:mm:ss.fff")), new AnalyticsParameter("Url", url)); SettingsManager.MotdUseBackupUrl = false; } catch (Exception ex) { Log.Error("Failed processing MOTD string. Reason: " + ex.Message); SettingsManager.MotdUseBackupUrl = !SettingsManager.MotdUseBackupUrl; } }, delegate(Exception error) { Log.Error("Failed downloading MOTD. Reason: {0}", error.Message); SettingsManager.MotdUseBackupUrl = !SettingsManager.MotdUseBackupUrl; }); } } if (MessageOfTheDay == null && !string.IsNullOrEmpty(SettingsManager.MotdLastDownloadedData)) { MessageOfTheDay = ParseMotd(SettingsManager.MotdLastDownloadedData); if (MessageOfTheDay == null) { SettingsManager.MotdLastDownloadedData = string.Empty; } } }
public override void Update() { if (m_buyButton != null && m_buyButton.IsClicked) { AnalyticsManager.LogEvent("[TrialEndedScreen] Clicked buy button"); MarketplaceManager.ShowMarketplace(); ScreensManager.SwitchScreen("MainMenu"); } if ((m_quitButton != null && m_quitButton.IsClicked) || base.Input.Back) { AnalyticsManager.LogEvent("[TrialEndedScreen] Clicked quit button"); ScreensManager.SwitchScreen("MainMenu"); } if (m_newWorldButton != null && m_newWorldButton.IsClicked) { AnalyticsManager.LogEvent("[TrialEndedScreen] Clicked newworld button"); ScreensManager.SwitchScreen("NewWorld"); } }
public static void MigrateDataFromIsolatedStorageWithDialog() { try { if (Storage.DirectoryExists("data:/.config/.isolated-storage")) { Log.Information("1.26 data found, starting migration to 1.27."); BusyDialog dialog = new BusyDialog("Please wait", "Migrating 1.26 data to 1.27 format..."); DialogsManager.ShowDialog(null, dialog); Task.Run(delegate { string empty = string.Empty; string empty2 = string.Empty; try { int num = MigrateFolder("data:/.config/.isolated-storage", "data:"); empty = "Migration Successful"; empty2 = $"{num} file(s) were migrated from 1.26 to 1.27."; AnalyticsManager.LogEvent("[Migration to 1.27]", new AnalyticsParameter("Details", empty2)); } catch (Exception ex2) { empty = "Migration Failed"; empty2 = ex2.Message; Log.Error("Migration to 1.27 failed, reason: {0}", ex2.Message); AnalyticsManager.LogError("Migration to 1.27 failed", ex2); } DialogsManager.HideDialog(dialog); DialogsManager.ShowDialog(null, new MessageDialog(empty, empty2, LanguageControl.Get("Usual", "ok"), null, null)); Dispatcher.Dispatch(delegate { SettingsManager.LoadSettings(); }); }); } } catch (Exception ex) { Log.Error("Failed to migrate data. Reason: {0}", ex.Message); AnalyticsManager.LogError("Migration to 1.27 failed", ex); } }
public static void UpgradeWorld(string directoryName) { WorldInfo worldInfo = WorldsManager.GetWorldInfo(directoryName); if (worldInfo == null) { throw new InvalidOperationException($"Cannot determine version of world at \"{directoryName}\""); } if (worldInfo.SerializationVersion != SerializationVersion) { ProgressManager.UpdateProgress($"Upgrading World To {SerializationVersion}", 0f); foreach (VersionConverter item in FindTransform(worldInfo.SerializationVersion, SerializationVersion, m_versionConverters, 0) ?? throw new InvalidOperationException($"Cannot find conversion path from version \"{worldInfo.SerializationVersion}\" to version \"{SerializationVersion}\"")) { Log.Information($"Upgrading world version \"{item.SourceVersion}\" to \"{item.TargetVersion}\"."); item.ConvertWorld(directoryName); } WorldInfo worldInfo2 = WorldsManager.GetWorldInfo(directoryName); if (worldInfo2.SerializationVersion != SerializationVersion) { throw new InvalidOperationException($"Upgrade produced invalid project version. Expected \"{SerializationVersion}\", found \"{worldInfo2.SerializationVersion}\"."); } AnalyticsManager.LogEvent("[VersionConverter] Upgrade world", new AnalyticsParameter("SourceVersion", worldInfo.SerializationVersion), new AnalyticsParameter("TargetVersion", SerializationVersion)); } }
public static void LoadProject(WorldInfo worldInfo, ContainerWidget gamesWidget) { DisposeProject(); WorldsManager.RepairWorldIfNeeded(worldInfo.DirectoryName); VersionsManager.UpgradeWorld(worldInfo.DirectoryName); using (Stream stream = Storage.OpenFile(Storage.CombinePaths(worldInfo.DirectoryName, "Project.xml"), OpenFileMode.Read)) { ValuesDictionary valuesDictionary = new ValuesDictionary(); ValuesDictionary valuesDictionary2 = new ValuesDictionary(); valuesDictionary.SetValue("GameInfo", valuesDictionary2); valuesDictionary2.SetValue("WorldDirectoryName", worldInfo.DirectoryName); ValuesDictionary valuesDictionary3 = new ValuesDictionary(); valuesDictionary.SetValue("Views", valuesDictionary3); valuesDictionary3.SetValue("GamesWidget", gamesWidget); XElement projectNode = XmlUtils.LoadXmlFromStream(stream, null, throwOnError: true); ProjectData projectData = new ProjectData(DatabaseManager.GameDatabase, projectNode, valuesDictionary, ignoreInvalidEntities: true); m_project = new Project(DatabaseManager.GameDatabase, projectData); m_subsystemUpdate = m_project.FindSubsystem <SubsystemUpdate>(throwOnError: true); } m_worldInfo = worldInfo; Log.Information("Loaded world, GameMode={0}, StartingPosition={1}, WorldName={2}, VisibilityRange={3}, Resolution={4}", worldInfo.WorldSettings.GameMode, worldInfo.WorldSettings.StartingPositionMode, worldInfo.WorldSettings.Name, SettingsManager.VisibilityRange.ToString(), SettingsManager.ResolutionMode.ToString()); AnalyticsManager.LogEvent("[GameManager] Loaded world", new AnalyticsParameter("GameMode", worldInfo.WorldSettings.GameMode.ToString()), new AnalyticsParameter("EnvironmentBehaviorMode", worldInfo.WorldSettings.EnvironmentBehaviorMode.ToString()), new AnalyticsParameter("TerrainGenerationMode", worldInfo.WorldSettings.TerrainGenerationMode.ToString()), new AnalyticsParameter("WorldDirectory", worldInfo.DirectoryName), new AnalyticsParameter("WorldName", worldInfo.WorldSettings.Name), new AnalyticsParameter("WorldSeedString", worldInfo.WorldSettings.Seed), new AnalyticsParameter("VisibilityRange", SettingsManager.VisibilityRange.ToString()), new AnalyticsParameter("Resolution", SettingsManager.ResolutionMode.ToString())); GC.Collect(); }
public GameMenuDialog(ComponentPlayer componentPlayer) { XElement node = ContentManager.Get <XElement>("Dialogs/GameMenuDialog"); LoadContents(this, node); m_statsPanel = Children.Find <StackPanelWidget>("StatsPanel"); m_componentPlayer = componentPlayer; m_adventureRestartExists = WorldsManager.SnapshotExists(GameManager.WorldInfo.DirectoryName, "AdventureRestart"); if (!m_increaseDetailDialogShown && PerformanceManager.LongTermAverageFrameTime.HasValue && PerformanceManager.LongTermAverageFrameTime.Value * 1000f < 25f && (SettingsManager.VisibilityRange <= 64 || SettingsManager.ResolutionMode == ResolutionMode.Low)) { m_increaseDetailDialogShown = true; DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog(LanguageControl.Get(fName, 1), LanguageControl.Get(fName, 2), LanguageControl.Get("Usual", "ok"), null, null)); AnalyticsManager.LogEvent("[GameMenuScreen] IncreaseDetailDialog Shown"); } if (!m_decreaseDetailDialogShown && PerformanceManager.LongTermAverageFrameTime.HasValue && PerformanceManager.LongTermAverageFrameTime.Value * 1000f > 50f && (SettingsManager.VisibilityRange >= 64 || SettingsManager.ResolutionMode == ResolutionMode.High)) { m_decreaseDetailDialogShown = true; DialogsManager.ShowDialog(base.ParentWidget, new MessageDialog(LanguageControl.Get(fName, 3), LanguageControl.Get(fName, 4), LanguageControl.Get("Usual", "ok"), null, null)); AnalyticsManager.LogEvent("[GameMenuScreen] DecreaseDetailDialog Shown"); } m_statsPanel.Children.Clear(); Project project = componentPlayer.Project; PlayerData playerData = componentPlayer.PlayerData; PlayerStats playerStats = componentPlayer.PlayerStats; SubsystemGameInfo subsystemGameInfo = project.FindSubsystem <SubsystemGameInfo>(throwOnError: true); SubsystemFurnitureBlockBehavior subsystemFurnitureBlockBehavior = project.FindSubsystem <SubsystemFurnitureBlockBehavior>(throwOnError: true); BitmapFont font = ContentManager.Get <BitmapFont>("Fonts/Pericles"); BitmapFont font2 = ContentManager.Get <BitmapFont>("Fonts/Pericles"); Color white = Color.White; StackPanelWidget stackPanelWidget = new StackPanelWidget { Direction = LayoutDirection.Vertical, HorizontalAlignment = WidgetAlignment.Center }; m_statsPanel.Children.Add(stackPanelWidget); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 5), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 6), LanguageControl.Get("GameMode", subsystemGameInfo.WorldSettings.GameMode.ToString()) + ", " + LanguageControl.Get("EnvironmentBehaviorMode", subsystemGameInfo.WorldSettings.EnvironmentBehaviorMode.ToString())); AddStat(stackPanelWidget, LanguageControl.Get(fName, 7), StringsManager.GetString("TerrainGenerationMode." + subsystemGameInfo.WorldSettings.TerrainGenerationMode.ToString() + ".Name")); string seed = subsystemGameInfo.WorldSettings.Seed; AddStat(stackPanelWidget, LanguageControl.Get(fName, 8), (!string.IsNullOrEmpty(seed)) ? seed : LanguageControl.Get(fName, 9)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 10), WorldOptionsScreen.FormatOffset(subsystemGameInfo.WorldSettings.SeaLevelOffset)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 11), WorldOptionsScreen.FormatOffset(subsystemGameInfo.WorldSettings.TemperatureOffset)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 12), WorldOptionsScreen.FormatOffset(subsystemGameInfo.WorldSettings.HumidityOffset)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 13), subsystemGameInfo.WorldSettings.BiomeSize.ToString() + "x"); int num = 0; for (int i = 0; i < ComponentFurnitureInventory.maxDesign; i++) { if (subsystemFurnitureBlockBehavior.GetDesign(i) != null) { num++; } } AddStat(stackPanelWidget, LanguageControl.Get(fName, 14), $"{num}/{ComponentFurnitureInventory.maxDesign}"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 15), string.IsNullOrEmpty(subsystemGameInfo.WorldSettings.OriginalSerializationVersion) ? LanguageControl.Get(fName, 16) : subsystemGameInfo.WorldSettings.OriginalSerializationVersion); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 17), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 18), playerData.Name); AddStat(stackPanelWidget, LanguageControl.Get(fName, 19), playerData.PlayerClass.ToString()); string value = (playerData.FirstSpawnTime >= 0.0) ? (((subsystemGameInfo.TotalElapsedGameTime - playerData.FirstSpawnTime) / 1200.0).ToString("N1") + LanguageControl.Get(fName, 20)) : LanguageControl.Get(fName, 21); AddStat(stackPanelWidget, LanguageControl.Get(fName, 22), value); string value2 = (playerData.LastSpawnTime >= 0.0) ? (((subsystemGameInfo.TotalElapsedGameTime - playerData.LastSpawnTime) / 1200.0).ToString("N1") + LanguageControl.Get(fName, 23)) : LanguageControl.Get(fName, 24); AddStat(stackPanelWidget, LanguageControl.Get(fName, 25), value2); AddStat(stackPanelWidget, LanguageControl.Get(fName, 26), MathUtils.Max(playerData.SpawnsCount - 1, 0).ToString("N0") + LanguageControl.Get(fName, 27)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 28), string.Format(LanguageControl.Get(fName, 29), ((int)MathUtils.Floor(playerStats.HighestLevel)).ToString("N0"))); if (componentPlayer != null) { Vector3 position = componentPlayer.ComponentBody.Position; if (subsystemGameInfo.WorldSettings.GameMode == GameMode.Creative) { AddStat(stackPanelWidget, LanguageControl.Get(fName, 30), string.Format(LanguageControl.Get(fName, 31), $"{position.X:0}", $"{position.Z:0}", $"{position.Y:0}")); } else { AddStat(stackPanelWidget, LanguageControl.Get(fName, 30), string.Format(LanguageControl.Get(fName, 32), LanguageControl.Get("GameMode", subsystemGameInfo.WorldSettings.GameMode.ToString()))); } } if (string.CompareOrdinal(subsystemGameInfo.WorldSettings.OriginalSerializationVersion, "1.29") > 0) { stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 33), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 34), playerStats.PlayerKills.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 35), playerStats.LandCreatureKills.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 36), playerStats.WaterCreatureKills.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 37), playerStats.AirCreatureKills.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 38), playerStats.MeleeAttacks.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 39), playerStats.MeleeHits.ToString("N0"), $"({((playerStats.MeleeHits == 0L) ? 0.0 : ((double)playerStats.MeleeHits / (double)playerStats.MeleeAttacks * 100.0)):0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 40), playerStats.RangedAttacks.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 41), playerStats.RangedHits.ToString("N0"), $"({((playerStats.RangedHits == 0L) ? 0.0 : ((double)playerStats.RangedHits / (double)playerStats.RangedAttacks * 100.0)):0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 42), playerStats.HitsReceived.ToString("N0")); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 43), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 44), playerStats.BlocksDug.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 45), playerStats.BlocksPlaced.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 46), playerStats.BlocksInteracted.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 47), playerStats.ItemsCrafted.ToString("N0")); AddStat(stackPanelWidget, LanguageControl.Get(fName, 48), playerStats.FurnitureItemsMade.ToString("N0")); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 49), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 50), FormatDistance(playerStats.DistanceTravelled)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 51), FormatDistance(playerStats.DistanceWalked), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceWalked / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 52), FormatDistance(playerStats.DistanceFallen), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceFallen / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 53), FormatDistance(playerStats.DistanceClimbed), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceClimbed / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 54), FormatDistance(playerStats.DistanceFlown), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceFlown / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 55), FormatDistance(playerStats.DistanceSwam), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceSwam / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 56), FormatDistance(playerStats.DistanceRidden), $"({((playerStats.DistanceTravelled > 0.0) ? (playerStats.DistanceRidden / playerStats.DistanceTravelled * 100.0) : 0.0):0.0}%)"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 57), FormatDistance(playerStats.LowestAltitude)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 58), FormatDistance(playerStats.HighestAltitude)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 59), playerStats.DeepestDive.ToString("N1") + "m"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 60), playerStats.Jumps.ToString("N0")); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 61), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 62), (playerStats.TotalHealthLost * 100.0).ToString("N0") + "%"); AddStat(stackPanelWidget, LanguageControl.Get(fName, 63), playerStats.FoodItemsEaten.ToString("N0") + LanguageControl.Get(fName, 64)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 65), playerStats.TimesWentToSleep.ToString("N0") + LanguageControl.Get(fName, 66)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 67), (playerStats.TimeSlept / 1200.0).ToString("N1") + LanguageControl.Get(fName, 68)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 69), playerStats.TimesWasSick.ToString("N0") + LanguageControl.Get(fName, 66)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 70), playerStats.TimesPuked.ToString("N0") + LanguageControl.Get(fName, 66)); AddStat(stackPanelWidget, LanguageControl.Get(fName, 71), playerStats.TimesHadFlu.ToString("N0") + LanguageControl.Get(fName, 66)); stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 72), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); AddStat(stackPanelWidget, LanguageControl.Get(fName, 73), playerStats.StruckByLightning.ToString("N0") + LanguageControl.Get(fName, 66)); GameMode easiestModeUsed = playerStats.EasiestModeUsed; AddStat(stackPanelWidget, LanguageControl.Get(fName, 74), LanguageControl.Get("GameMode", easiestModeUsed.ToString())); if (playerStats.DeathRecords.Count > 0) { stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 75), Font = font, HorizontalAlignment = WidgetAlignment.Center, Margin = new Vector2(0f, 10f), Color = white }); foreach (PlayerStats.DeathRecord deathRecord in playerStats.DeathRecords) { float num2 = (float)MathUtils.Remainder(deathRecord.Day, 1.0); string arg = (!(num2 < 0.2f) && !(num2 >= 0.8f)) ? ((!(num2 >= 0.7f)) ? ((!(num2 >= 0.5f)) ? LanguageControl.Get(fName, 76) : LanguageControl.Get(fName, 77)) : LanguageControl.Get(fName, 78)) : LanguageControl.Get(fName, 79); AddStat(stackPanelWidget, string.Format(LanguageControl.Get(fName, 80), MathUtils.Floor(deathRecord.Day) + 1.0, arg), "", deathRecord.Cause); } } } else { stackPanelWidget.Children.Add(new LabelWidget { Text = LanguageControl.Get(fName, 81), WordWrap = true, Font = font2, HorizontalAlignment = WidgetAlignment.Center, TextAnchor = TextAnchor.HorizontalCenter, Margin = new Vector2(20f, 10f), Color = white }); } }
public static void Publish(string address, string name, ExternalContentType type, string userId, CancellableProgress progress, Action success, Action <Exception> failure) { progress = (progress ?? new CancellableProgress()); if (MarketplaceManager.IsTrialMode) { failure(new InvalidOperationException("Cannot publish links in trial mode.")); } else if (!WebManager.IsInternetConnectionAvailable()) { failure(new InvalidOperationException("Internet connection is unavailable.")); } else { VerifyLinkContent(address, name, type, progress, delegate(byte[] data) { string value = CalculateContentHashString(data); WebManager.Post(m_scResDirAddress, null, null, WebManager.UrlParametersToStream(new Dictionary <string, string> { { "Action", "publish" }, { "UserId", userId }, { "Name", name }, { "Url", address }, { "Type", type.ToString() }, { "Hash", value }, { "Size", data.Length.ToString(CultureInfo.InvariantCulture) }, { "Platform", VersionsManager.Platform.ToString() }, { "Version", VersionsManager.Version } }), progress, delegate { success(); AnalyticsManager.LogEvent("[CommunityContentManager] Publish Success", new AnalyticsParameter("Name", name), new AnalyticsParameter("Type", type.ToString()), new AnalyticsParameter("Size", data.Length.ToString()), new AnalyticsParameter("User", userId)); }, delegate(Exception error) { failure(error); AnalyticsManager.LogEvent("[CommunityContentManager] Publish Failure", new AnalyticsParameter("Name", name), new AnalyticsParameter("Type", type.ToString()), new AnalyticsParameter("Size", data.Length.ToString()), new AnalyticsParameter("User", userId), new AnalyticsParameter("Error", error.Message.ToString())); }); }, failure); } }
static PerformanceManager() { m_primitivesRenderer = new PrimitivesRenderer2D(); m_averageFrameTime = new RunningAverage(1f); m_averageCpuFrameTime = new RunningAverage(1f); m_stateMachine = new StateMachine(); m_statsString = string.Empty; m_stateMachine.AddState("PreMeasure", delegate { m_totalGameTime = 0.0; }, delegate { if (GameManager.Project != null) { m_totalGameTime += Time.FrameDuration; if (m_totalGameTime > 60.0) { m_stateMachine.TransitionTo("Measuring"); } } }, null); m_stateMachine.AddState("Measuring", delegate { m_totalFrameTime = 0.0; m_totalCpuFrameTime = 0.0; m_frameCount = 0; }, delegate { if (GameManager.Project != null) { if (ScreensManager.CurrentScreen != null && ScreensManager.CurrentScreen.GetType() == typeof(GameScreen)) { float lastFrameTime = Program.LastFrameTime; float lastCpuFrameTime = Program.LastCpuFrameTime; if (lastFrameTime > 0f && lastFrameTime < 1f && lastCpuFrameTime > 0f && lastCpuFrameTime < 1f) { m_totalFrameTime += lastFrameTime; m_totalCpuFrameTime += lastCpuFrameTime; m_frameCount++; } if (m_totalFrameTime > 180.0) { m_stateMachine.TransitionTo("PostMeasure"); } } } else { m_stateMachine.TransitionTo("PreMeasure"); } }, null); m_stateMachine.AddState("PostMeasure", delegate { if (m_frameCount > 0) { m_longTermAverageFrameTime = (float)(m_totalFrameTime / (double)m_frameCount); float num = (int)MathUtils.Round(MathUtils.Round(m_totalFrameTime / (double)m_frameCount / 0.004999999888241291) * 0.004999999888241291 * 1000.0); float num2 = (int)MathUtils.Round(MathUtils.Round(m_totalCpuFrameTime / (double)m_frameCount / 0.004999999888241291) * 0.004999999888241291 * 1000.0); AnalyticsManager.LogEvent("[PerformanceManager] Measurement", new AnalyticsParameter("FrameCount", m_frameCount.ToString()), new AnalyticsParameter("AverageFrameTime", num.ToString() + "ms"), new AnalyticsParameter("AverageFrameCpuTime", num2.ToString() + "ms")); Log.Information($"PerformanceManager Measurement: frames={m_frameCount.ToString()}, avgFrameTime={num.ToString()}ms, avgFrameCpuTime={num2.ToString()}ms"); } }, delegate { if (GameManager.Project == null) { m_stateMachine.TransitionTo("PreMeasure"); } }, null); m_stateMachine.TransitionTo("PreMeasure"); }
public static void ShowMarketplace() { AnalyticsManager.LogEvent("[MarketplaceManager] Show marketplace"); WebBrowserManager.LaunchBrowser("http://play.google.com/store/apps/details?id=com.candyrufusgames.survivalcraft2"); }