void Start() { nav = GetComponent <SceneNavigation>(); allNodes = GetComponentsInChildren <LevelNode>(); var nodes = (from node in allNodes group node by node.Name into grp select new { Name = grp.Key, Node = grp.First() }).ToDictionary(g => g.Name, g => g.Node); foreach (var sector in GameSession.CompletedSectors) { LevelNode node = null; if (nodes.TryGetValue(sector, out node)) { node.Complete(false); } } if (string.IsNullOrEmpty(GameSession.LastCompletedSector)) { var firstSector = GameSession.SECTOR_DEPENDENCIES.ElementAt(0).Key; LevelNode node = null; if (nodes.TryGetValue(firstSector, out node)) { node.Unlock(null); } } else { LevelNode node = null; if (nodes.TryGetValue(GameSession.LastCompletedSector, out node)) { node.Complete(true); } } }
private void LevelComplete(LevelNode node) { node.Complete(); }