public bool ChapterIsUnlocked(ChapterViewModel chapter) { foreach (var stage in chapter.Stages) { if (stage.IsLocked == false) return true; } return false; }
private void CreateXML() { var fileNames = new List<string> { "Animal01", "Animal02", "Animal03", "Animal04", "Animal05", "Animal06", "Animal07", "Animal08", "Animal09", "Animal10", "Animal11", "Animal12", "Animal13", "Animal14", "Animal15", "Animal16", "Animal17", "Animal18", "Animal19", "Animal20", "Animal21", "Animal22", "Animal23", "Animal24", "Animal25", "Animal26", "Animal27", "Animal28", "Animal29", "Animal30", "Animal31", "Animal32", "Animal33", "Animal34", "Animal35", "Animal36", "Animal37", "Animal38", "Animal39", "Animal40", "Animal41", "Animal42", "Animal43", "Animal44", "Animal45", "Animal46", "Animal47", "Animal48", "Animal49", "Animal50", "Animal51", "Animal52" }; var cl = new List<ChapterViewModel>(); var lastStageId = Guid.Empty; const int stagesPerChapter = 6; ChapterViewModel currentChapter = null; for (var i = 0; i < fileNames.Count; i++) { if (i % stagesPerChapter == 0) { currentChapter = new ChapterViewModel { Name = "Chapter " + i, Stages = new List<StageViewModel>() }; cl.Add(currentChapter); } if (currentChapter != null) { var stage = new StageViewModel { Name = fileNames[i], GameFile = string.Format("https://photohunt.blob.core.windows.net/animal/{0}.zip", fileNames[i]), StageId = Guid.NewGuid(), Thumbnail = string.Format("https://photohunt.blob.core.windows.net/animal/thumbnails/{0}.jpg", fileNames[i]), GameEffect = Effect.None, Prerequisites = lastStageId }; currentChapter.Stages.Add(stage); lastStageId = stage.StageId; } } var xmlSerializer = new XmlSerializer(typeof(List<ChapterViewModel>)); var textWriter = new StringWriter(); xmlSerializer.Serialize(textWriter, cl); var result = textWriter.ToString(); }
private void CreateSampleData() { var fileNames = new List<string> { "Animal01", "Animal02", "Animal03", "Animal04", "Animal05", "Animal06", "Animal07", "Animal08", "Animal09", "Animal10", "Animal11", "Animal12", "Animal13", "Animal14", "Animal15", "Animal16", "Rio01", "Rio02", "Rio03", "Rio04", "Rio05", "Rio06", "Rio07", "Rio08", "Rio09" }; var cl = new List<ChapterViewModel>(); var lastStageId = Guid.Empty; const int stagesPerChapter = 6; ChapterViewModel currentChapter = null; for (var i = 0; i < fileNames.Count; i++) { if (i%stagesPerChapter == 0) { currentChapter = new ChapterViewModel {Name = "Chapter " + i, Stages = new List<StageViewModel>()}; cl.Add(currentChapter); } if (currentChapter != null) { var stage = new StageViewModel { Name = fileNames[i], GameFile = string.Format("https://appusage.blob.core.windows.net/photohuntinfinity/{0}.zip", fileNames[i]), StageId = Guid.NewGuid(), Thumbnail = "https://appusage.blob.core.windows.net/photohuntav1/Intro%20Video%201_icon.jpg", GameEffect = Effect.None, Prerequisites = lastStageId }; currentChapter.Stages.Add(stage); lastStageId = stage.StageId; } } var xmlSerializer = new XmlSerializer(typeof(List<ChapterViewModel>)); var textWriter = new StringWriter(); xmlSerializer.Serialize(textWriter, cl); var result = textWriter.ToString(); }