// Use this for initialization void Start() { this.ProgressManager = GameObject.Find("Progress"); ProgressObject progress = ProgressManager.GetComponent <ProgressObject>(); EntryTextDisplay.text = String.Empty; foreach (EncyclopediaEntry entry in EncyclopediaEntries) { if (entry.UnlockPath.ChapterNum == 0 || progress.ProgressPaths.progressPaths.Any(i => i.ChapterNum == entry.UnlockPath.ChapterNum && i.SectionNum == entry.UnlockPath.SectionNum)) { GameObject newEntry = Instantiate(EncyclopediaItemPrefab) as GameObject; TopicPanelProperties properties = newEntry.GetComponent <TopicPanelProperties>(); properties.Name.text = entry.Title; properties.TopicTag = entry.TopicTag; properties.TopicText = entry.EntryText; properties.BackgroundImage = entry.BackgroundImage; properties.EntryTextDisplay = this.EntryTextDisplay; FillTopicList fillTopic = newEntry.GetComponent <FillTopicList>(); fillTopic.ImagePanel = this.ImagePanel; fillTopic.ProgressManager = this.ProgressManager; fillTopic.SubTopicPanel = this.SubTopicPanel; newEntry.transform.SetParent(ContentPanel.transform, false); } } }
public void UpdateContents(string topicTag) { foreach (EncyclopediaSubEntry entry in entries) { if (entry.MatchTag == topicTag) { foreach (EncyclopediaEntry subEntry in entry.SubEntries) { GameObject newEntry = Instantiate(EncyclopediaItemPrefab) as GameObject; TopicPanelProperties properties = newEntry.GetComponent <TopicPanelProperties>(); properties.Name.text = subEntry.Title; properties.TopicTag = subEntry.TopicTag; properties.MatchTag = subEntry.MatchTag; properties.TopicText = subEntry.EntryText; properties.EntryTextDisplay = EntryTextDisplay; newEntry.transform.SetParent(ContentPanel.transform, false); FillTopicList fillTopic = newEntry.GetComponent <FillTopicList>(); fillTopic.ImagePanel = this.ImagePanel; fillTopic.ProgressManager = this.ProgressManager; if (this.SubTopicPanel != null) { fillTopic.SubTopicPanel = this.SubTopicPanel; } panels.Add(newEntry); } } } }
public void OnPointerClick(PointerEventData pointerEventData) { properties = GetComponent <TopicPanelProperties>(); #region SetSubTopics if (this.SubTopicPanel != null) { SubListController subList = SubTopicPanel.GetComponent <SubListController>(); subList.DestroyPanels(); subList.UpdateContents(properties.TopicTag); } #endregion #region SetImageandText Image entryImage = ImagePanel.GetComponent <Image>(); entryImage.sprite = properties.BackgroundImage; ProgressObject progress = ProgressManager.GetComponent <ProgressObject>(); properties.EntryTextDisplay.text = String.Empty; foreach (EncyclopediaEntryText entry in properties.TopicText) { if (entry.UnlockPath.ChapterNum == 0 || progress.ProgressPaths.progressPaths.Any(i => i.ChapterNum == entry.UnlockPath.ChapterNum && i.SectionNum == entry.UnlockPath.SectionNum)) { try { if (String.IsNullOrEmpty(properties.EntryTextDisplay.text)) { properties.EntryTextDisplay.text = entry.EntryText.text; } else { properties.EntryTextDisplay.text += "\n\n" + entry.EntryText.text; } } catch (NullReferenceException) { properties.EntryTextDisplay.text = "Entry text is not set. Cannot be displayed."; } } } #endregion }