private void OnGetLevelBaseData(LevelRes res) { }
public void SetData(LevelRes res) { LocalDataList = ClientData.LoadLevelData(); LevelBuyRules = res.LevelBuyRules; CommentRule = res.CommentRules; CardNumRules = res.CardNumRules; InfoRule = res.InfoRules; PlotRule = res.PlotRules; LevelDict = new Dictionary <int, LevelVo>(); ChapterList = new List <ChapterVo>(); ChapterVo chapter = null; Dictionary <int, ChapterVo> chapterDict = new Dictionary <int, ChapterVo>(); for (int i = 0; i < res.Levels.Count; i++) { var level = new LevelVo(); level.SetData(res.Levels[i], PlotRule, InfoRule, LocalDataList); LevelDict.Add(level.LevelId, level); if (chapterDict.ContainsKey(level.ChapterGroup) == false) { chapter = new ChapterVo(); chapterDict[level.ChapterGroup] = chapter; chapter.LevelList = new List <LevelVo>(); chapter.HardLevelList = new List <LevelVo>(); chapter.ChapterId = level.ChapterGroup; for (int j = 0; j < InfoRule.Count; j++) { var info = InfoRule[j]; if (info.InfoType == 1 && info.InfoId == level.ChapterGroup) { chapter.ChapterName = info.LevelName; chapter.ChapterDesc = info.LevelDesc; break; } } } if (level.Hardness == GameTypePB.Difficult) { chapterDict[level.ChapterGroup].HardLevelList.Add(level); } else { chapterDict[level.ChapterGroup].LevelList.Add(level); } } // var prevPos = GetPrevChapterPos(); // var nextPos = GetNextChapterPos(); foreach (var chapterVo in chapterDict) { ChapterList.Add(chapterVo.Value); // if (nextPos.Length >= chapterVo.Value.ChapterId) // { // chapterVo.Value.NextPos = nextPos[chapterVo.Value.ChapterId - 1]; // chapterVo.Value.PrevPos = prevPos[chapterVo.Value.ChapterId - 1]; if (chapterDict.ContainsKey(chapterVo.Value.ChapterId + 1)) { chapterVo.Value.NextChapterVo = chapterDict[chapterVo.Value.ChapterId + 1]; } if (chapterDict.ContainsKey(chapterVo.Value.ChapterId - 1)) { chapterVo.Value.PrevChapterVo = chapterDict[chapterVo.Value.ChapterId - 1]; } // } } }