public bool Init(string path) { if (!string.IsNullOrEmpty(path) && File.Exists(path)) { savegame = Helpers.FileGetBytes(path, 10000); if (savegame != null && savegame.Length > 0) { Chapters = new List<SMBChapter>(); for (int chapterNumber = 1; chapterNumber <= 7; chapterNumber++) { SMBChapter chapter = new SMBChapter(this, chapterNumber); Chapters.Add(chapter); } TotalDeaths = BitConverter.ToInt32(savegame, TotalDeathsOffset); TotalProgress = Chapters.Sum(x => x.TotalCount); TotalTime = Chapters.Sum(x => x.TotalTime); TotalParTime = Chapters.Sum(x => x.TotalCompletedParTime); TotalLevelsCompleted = Chapters.Sum(x => x.TotalLevelCompleted); TotalLightCompleted = Chapters.Sum(x => x.LightCompleted); TotalDarkCompleted = Chapters.Sum(x => x.DarkCompleted); TotalWarpCompleted = Chapters.Sum(x => x.WarpCompleted); TotalGlitchCompleted = Chapters.Count(x => x.IsGlitchCompleted); TotalBandages = Chapters.Sum(x => x.Bandages); TotalLightGradeA = Chapters.Sum(x => x.TotalLightGradeA); TotalDarkGradeA = Chapters.Sum(x => x.TotalDarkGradeA); LeaderboardScore = (int)(((TotalLevelsCompleted - TotalGlitchCompleted) * 1000000) - (TotalTime * 1000)); MaxTotalProgress = Chapters.Sum(x => x.MaxTotalCount); MaxTotalAllLevels = Chapters.Sum(x => x.MaxTotalLevelCount); MaxTotalLevels = Chapters.Sum(x => x.MaxLevelCount); MaxTotalWarp = Chapters.Sum(x => x.MaxWarpCount); MaxTotalGlitchLevels = 6; MaxTotalBandages = Chapters.Sum(x => x.MaxBandagesCount); LoadCharacters(); LeaderboardScoreText = string.Format("{0:N0}", LeaderboardScore); TotalDeathsText = string.Format("{0}", TotalDeaths); TotalTimeText = string.Format("{0:0.000} / {1:0.000}", TotalTime, TotalParTime); TotalProgressText = string.Format("{0:0.##}% ( {1} / {2} )", Helpers.GetPercentage(TotalProgress - TotalGlitchCompleted, MaxTotalProgress - MaxTotalGlitchLevels) + TotalGlitchCompleted, TotalProgress, MaxTotalProgress); TotalLevelsCompletedText = string.Format("{0:0.##}% ( {1} / {2} )", Helpers.GetPercentage(TotalLevelsCompleted, MaxTotalAllLevels), TotalLevelsCompleted, MaxTotalAllLevels); TotalLightCompletedText = string.Format("{0:0.##}% ( {1} / {2} )", Helpers.GetPercentage(TotalLightCompleted, MaxTotalLevels), TotalLightCompleted, MaxTotalLevels); TotalDarkCompletedText = string.Format("{0:0.##}% ( {1} / {2} )", Helpers.GetPercentage(TotalDarkCompleted, MaxTotalLevels), TotalDarkCompleted, MaxTotalLevels); TotalWarpCompletedText = string.Format("{0:0.##}% ( {1} / {2} )", Helpers.GetPercentage(TotalWarpCompleted, MaxTotalWarp), TotalWarpCompleted, MaxTotalWarp); TotalGlitchCompletedText = string.Format("{0:0.##}% ( {1} / {2} )", Helpers.GetPercentage(TotalGlitchCompleted, MaxTotalGlitchLevels), TotalGlitchCompleted, MaxTotalGlitchLevels); TotalBandagesText = string.Format("{0:0.##}% ( {1} / {2} )", Helpers.GetPercentage(TotalBandages, MaxTotalBandages), TotalBandages, MaxTotalBandages); TotalLightGradeAText = string.Format("{0:0.##}% ( {1} / {2} )", Helpers.GetPercentage(TotalLightGradeA, MaxTotalLevels), TotalLightGradeA, MaxTotalLevels); TotalDarkGradeAText = string.Format("{0:0.##}% ( {1} / {2} )", Helpers.GetPercentage(TotalDarkGradeA, MaxTotalLevels), TotalDarkGradeA, MaxTotalLevels); savegamePath = path; IsLoaded = true; return true; } } IsLoaded = false; return false; }
private string GetLeaderboardName(SMBChapter chapter, int level, LevelType type) { int id = 100 + ((chapter.Number - 1) * 50) + (level - 1); if (type == LevelType.Dark) id += chapter.MaxLevelCount; return "SMB_LEADERBOARD_" + id; }
private string GetChapterInfoText(SMBChapter chapterInfo) { StringBuilder str = new StringBuilder(); str.AppendLine(chapterInfo.ToString()); if (chapterInfo.LightLevels.Count(x => x.IsCompleted) > 0) str.AppendLine(); foreach (SMBLevel levelInfo in chapterInfo.LightLevels) { if (levelInfo != null && levelInfo.IsCompleted) { str.AppendLine(levelInfo.ToString()); } } if (chapterInfo.DarkLevels.Count(x => x.IsCompleted) > 0) str.AppendLine(); foreach (SMBLevel levelInfo in chapterInfo.DarkLevels) { if (levelInfo != null && levelInfo.IsCompleted) { str.AppendLine(levelInfo.ToString()); } } if (chapterInfo.WarpLevels.Count(x => x.IsCompleted) > 0) str.AppendLine(); foreach (SMBLevel levelInfo in chapterInfo.WarpLevels) { if (levelInfo != null && levelInfo.IsCompleted) { str.AppendLine(levelInfo.ToString()); } } return str.ToString(); }