//Inserts spell into spellbook //returns true if success, false if spellbook already contains this keyword //Pre: this.isRegistered(word) has been called public void register(string word, string type, string description) { string add = word; //if (type == "element") // add = word + "-"; //else if (type == "style") // add = "-" + word; //else if (type == "friend") // add = word; //else // add = "-" + word + "-"; if (typeLog.ContainsKey(type)) { SpellbookList l = typeLog[type]; l.Add(new SpellbookEntry(add, description)); wordLog.Add(add, true); l.Sort(); } else { SpellbookList l = new SpellbookList(); l.type = type; data.Add(l); typeLog.Add(type, l); l.Add(new SpellbookEntry(add, description)); wordLog.Add(word, true); l.Sort(); data.Sort(); } updatePage(); Debug.Log(word.ToUpper() + " was registered to the spellbook"); }
//Updates Render Data private bool updatePage() { if (data.Count == 0) { pageTitle.text = titleString + "NO SPELLS"; downArrow.SetActive(false); upArrow.SetActive(false); return(false); } SpellbookList current = data[typeIndex]; pageTitle.text = titleString + current.type.ToUpper() + " " + (pageIndex / pageSize + 1); int j = pageIndex; for (int i = 0; i < pageSize; i++) { if (j < current.Count) { entryNames[i].text = current[j].word.ToUpper(); descritptions[i].text = current[j].description; } else { entryNames[i].text = emptyEntryText; descritptions[i].text = emptyEntryText; } ++j; } downArrow.SetActive(checkNext()); upArrow.SetActive(checkPrev()); return(true); }
public int CompareTo(SpellbookList other) { return(type.CompareTo(other.type)); }