protected void EnhancedLevelsScreen_OnOptionCreated(Vector4 pos, bool selected, string optionDisplayText, uint index, int page, ButtonHolder holder) { if (holder == null) { return; } MissionType mt; bool enhancedOnly; List <Achievement> allAchievements; LevelInfo info = (LevelInfo)availableOptions.ToArray()[index]; Level.PeekMissionDetails(info.Filename, out mt, out enhancedOnly, out allAchievements); enhancedMissionsMap[holder] = enhancedOnly; levelInfoMap[holder] = info; CompletedLevelsInfo completedLevelsInfo = LoadGameUtil.Singleton.CompletedLevelsInfo; List <Achievement> achievementsDone = LoadGameUtil.Singleton.GetCompletedAchievementsForLevel(info); if (allAchievements != null) { LoadGameUtil.MergeAchievements(achievementsDone, allAchievements); } string filename = Level.GetMissionTypeTextureFile(mt); if (filename != null) { guiWindow.createStaticImage(new Vector4(Viewport.ActualWidth / 2 - GetTextVSpacing(), pos.y, GetTextVSpacing(), GetTextVSpacing()), filename, (ushort)(1000 + index)); } if (enhancedOnly) { guiWindow.createStaticImage(new Vector4(Viewport.ActualWidth / 2 - 5.0f * GetTextVSpacing(), pos.y, GetTextVSpacing(), GetTextVSpacing()), "pin.png", (ushort)(1100 + index)); } int i = 1; if (allAchievements == null) { return; } foreach (Achievement a in allAchievements) { i++; string image; image = a.IsFulfilled() ? a.GetFulfilledImageFilename() : a.GetUnFulfilledImageFilename(); guiWindow.createStaticImage(new Vector4((Viewport.ActualWidth / 2) - i * GetTextVSpacing(), pos.y, GetTextVSpacing(), GetTextVSpacing()), image, (ushort)(2000 + index)); } }
public static CompletedLevelsInfo GetCompletedLevels() { CompletedLevelsInfo completedLevels = new CompletedLevelsInfo(); completedLevels.CompletedLevels = new SerializableDictionary <LevelInfo, List <Achievement> >(); List <Achievement> emptyAchievements = new List <Achievement>(); if (!File.Exists(EngineConfig.C_COMPLETED_LEVELS_FILE)) { completedLevels = CompletedLevelsInfo.GetDefaultCompletedLevelsInfo(); return(completedLevels); } else { try { string levelsRaw = File.ReadAllText(EngineConfig.C_COMPLETED_LEVELS_FILE); string levelsString = RijndaelSimple.Decrypt(levelsRaw); using (Stream stream = GenerateStreamFromString(levelsString)) { XmlSerializer serializer = new XmlSerializer(typeof(CompletedLevelsInfo)); ; var levels = ( CompletedLevelsInfo)serializer.Deserialize(stream); return(levels as CompletedLevelsInfo); } } catch (Exception ex) { completedLevels.CompletedLevels.Clear(); completedLevels.CompletedLevels.Add(new LevelInfo(XmlLevelParser.GetLevelFileName(1), false), emptyAchievements); Console.WriteLine(ex); } return(completedLevels); } }
public static CompletedLevelsInfo NewLevelCompleted(LevelInfo levelInfo, List <Achievement> achievements) { CompletedLevelsInfo completedLevels = Singleton.CompletedLevelsInfo; completedLevels.CompletedLevels[levelInfo] = achievements; MemoryStream stream = new MemoryStream(); XmlSerializer serializer = new XmlSerializer(typeof(CompletedLevelsInfo)); serializer.Serialize(stream, completedLevels); stream.Position = 0; var sr = new StreamReader(stream); var levelsRaw = sr.ReadToEnd(); stream.Close(); File.WriteAllText(EngineConfig.C_COMPLETED_LEVELS_FILE, RijndaelSimple.Encrypt(levelsRaw)); Singleton.UpdateCompletedLevelsInfo(completedLevels); return(completedLevels); }
private LoadGameUtil() { this.completedLevelsInfo = GetCompletedLevels(); }
protected void UpdateCompletedLevelsInfo(CompletedLevelsInfo completedLevelsInfo) { this.completedLevelsInfo = completedLevelsInfo; }