// Use this for initialization public void Start() { Load_Spells_from_ID.SpellsZero.Clear(); Load_Spells_from_ID.SpellsOne.Clear(); Load_Spells_from_ID.SpellsTwo.Clear(); Load_Spells_from_ID.SpellsThree.Clear(); Load_Spells_from_ID.SpellsFour.Clear(); Load_Spells_from_ID.SpellsFive.Clear(); Load_Spells_from_ID.SpellsSix.Clear(); Load_Spells_from_ID.SpellsSeven.Clear(); Load_Spells_from_ID.SpellsEight.Clear(); Load_Spells_from_ID.SpellsNine.Clear(); SpellParentButtonDefault = SpellParentButton; SpellParentRectDefault = SpellParentButtonDefault.GetComponent<RectTransform>(); ParentRectHeight = SpellParentRectDefault.rect.height; ParentRect = SpellParentRectDefault; ScrollBar = SpellScrollView.gameObject.transform.GetChild(1).GetComponent<Scrollbar>(); XML_Loader xmlLoader = ScriptableObject.CreateInstance<XML_Loader> ();//load xml List<string> XmlResult = new List<string> (); if (Settings_Screen.is_online == true) { XmlResult = xmlLoader.LoadInnerXml("https://raw.githubusercontent.com/theslimreaper/DnD/master/XML%20Files/Spells/spells.xml", "spell"); } else { XmlResult = xmlLoader.LoadInnerXmlFromFile("..\\XML Files/Spells/spells.xml", "spell"); } List<string> IDList = new List<string> (); foreach (var item in Character_Info.characterSpells) { IDList.Add(item); } string IDContained = ""; foreach(var item in XmlResult)//loop through the spell list and sort the spells based off of spell level (if character class is correct) { foreach (var IDItem in IDList) { IDContained = IDItem; idLine = item.Substring(item.IndexOf("<id>") + 4,(item.IndexOf("</id>")-item.IndexOf("<id>")) - 4); if (idLine.Contains(IDContained)) { Spell_Class SpellsSet = new Spell_Class(); SpellsSet.spellName = item.Substring((item.IndexOf("<name>") + 6),((item.IndexOf("</name>")-item.IndexOf("<name>")) - 6)); SpellsSet.spellLevel = item.Substring(item.IndexOf("<level>") + 7,(item.IndexOf("</level>")-item.IndexOf("<level>")) - 7); SpellsSet.spellCast = item.Substring(item.IndexOf("<time>") + 6,(item.IndexOf("</time>")-item.IndexOf("<time>")) - 6); SpellsSet.spellClasses = item.Substring(item.IndexOf("<classes>") + 9,(item.IndexOf("</classes>")-item.IndexOf("<classes>")) - 9); SpellsSet.spellComponents = item.Substring(item.IndexOf("<components>") + 12,(item.IndexOf("</components>")-item.IndexOf("<components>")) - 12); SpellsSet.spellDuration = item.Substring(item.IndexOf("<duration>") + 10,(item.IndexOf("</duration>")-item.IndexOf("<duration>")) - 10); //SpellsSet.spellRitual = item.Substring(item.IndexOf("<ritual>") + 8,(item.IndexOf("</ritual>")-item.IndexOf("<ritual>")) - 8); SpellsSet.spellSchool = item.Substring(item.IndexOf("<school>") + 8,(item.IndexOf("</school>")-item.IndexOf("<school>")) - 8); if (item.IndexOf("<roll>") != -1) { SpellsSet.spellRoll = item.Substring(item.IndexOf("<roll>") + 6,(item.IndexOf("</roll>")-item.IndexOf("<roll>")) - 6); } SpellsSet.spellRange = item.Substring(item.IndexOf("<range>") + 7,(item.IndexOf("</range>")-item.IndexOf("<range>")) - 7); if (item.IndexOf("<id>") != -1) { SpellsSet.spellID = item.Substring(item.IndexOf("<id>") + 4,(item.IndexOf("</id>")-item.IndexOf("<id>")) - 4); } SpellsSet.spellDescription = item.Substring(item.IndexOf("<text>") + 6,(item.IndexOf("</text>")-item.IndexOf("<text>")) - 6); levelLine = item.Substring(item.IndexOf("<level>"),(item.IndexOf("</level>")-item.IndexOf("<level>"))); nameLine = item.Substring(item.IndexOf("<name>"),(item.IndexOf("</name>")-item.IndexOf("<name>"))); if (levelLine.Contains("0")) { bool newspell = true; foreach (var spell in Load_Spells_from_ID.SpellsZero) { if (spell.spellID == IDContained) { newspell = false; } } if (newspell == true) { Load_Spells_from_ID.SpellsZero.Add (SpellsSet); } } else if (levelLine.Contains("1")) { bool newspell = true; foreach (var spell in Load_Spells_from_ID.SpellsOne) { if (spell.spellID == IDContained) { newspell = false; } } if (newspell == true) { Load_Spells_from_ID.SpellsOne.Add (SpellsSet); } } else if (levelLine.Contains("2")) { bool newspell = true; foreach (var spell in Load_Spells_from_ID.SpellsTwo) { if (spell.spellID == IDContained) { newspell = false; } } if (newspell == true) { Load_Spells_from_ID.SpellsTwo.Add (SpellsSet); } } else if (levelLine.Contains("3")) { bool newspell = true; foreach (var spell in Load_Spells_from_ID.SpellsThree) { if (spell.spellID == IDContained) { newspell = false; } } if (newspell == true) { Load_Spells_from_ID.SpellsThree.Add (SpellsSet); } } else if (levelLine.Contains("4")) { bool newspell = true; foreach (var spell in Load_Spells_from_ID.SpellsFour) { if (spell.spellID == IDContained) { newspell = false; } } if (newspell == true) { Load_Spells_from_ID.SpellsFour.Add (SpellsSet); } } else if (levelLine.Contains("5")) { bool newspell = true; foreach (var spell in Load_Spells_from_ID.SpellsFive) { if (spell.spellID == IDContained) { newspell = false; } } if (newspell == true) { Load_Spells_from_ID.SpellsFive.Add (SpellsSet); } } else if (levelLine.Contains("6")) { bool newspell = true; foreach (var spell in Load_Spells_from_ID.SpellsSix) { if (spell.spellID == IDContained) { newspell = false; } } if (newspell == true) { Load_Spells_from_ID.SpellsSix.Add (SpellsSet); } } else if (levelLine.Contains("7")) { bool newspell = true; foreach (var spell in Load_Spells_from_ID.SpellsSeven) { if (spell.spellID == IDContained) { newspell = false; } } if (newspell == true) { Load_Spells_from_ID.SpellsSeven.Add (SpellsSet); } } else if (levelLine.Contains("8")) { bool newspell = true; foreach (var spell in Load_Spells_from_ID.SpellsEight) { if (spell.spellID == IDContained) { newspell = false; } } if (newspell == true) { Load_Spells_from_ID.SpellsEight.Add (SpellsSet); } } else if (levelLine.Contains("9")) { bool newspell = true; foreach (var spell in Load_Spells_from_ID.SpellsNine) { if (spell.spellID == IDContained) { newspell = false; } } if (newspell == true) { Load_Spells_from_ID.SpellsNine.Add (SpellsSet); } } } } } foreach (var item in Load_Spells_from_XML.SpellsZero) { //print (item.spellName); } MakeButtons(); }