public void addSpellBookEntry(string name, SpellInit spell) { GameObject newEntry = Instantiate(templateEntry); newEntry.GetComponent <SpellBookEntry>().setText(name); newEntry.GetComponent <SpellBookEntry>().setSprite(spell.Aliases[0]); newEntry.transform.SetParent(gameObject.transform, false); entries.Add(name, newEntry); }
public void addSpell(SpellInit sp) { string name = sp.Aliases[0]; if (randomise) { name = sp.Aliases[rand.Next(sp.Aliases.Length)]; } spellbook.Add(name, sp); if (newSpellBookPanel != null) { newSpellBookPanel.GetComponent <SpellBookLogic>().addSpellBookEntry(name, sp); } }
// Update is called once per frame void Update() { if (!isLocalPlayer) { return; } string inputText = currentText.text.ToLower().Trim(); string candidateSpellName = null, candidateModName = null; bool typo = false; if (inputText.Length > 0) { candidateSpellName = spellCreateComponent.SearchSpell(inputText); if (candidateSpellName == null) { string[] inputParts = inputText.Split(delimiters, 2); candidateModName = spellCreateComponent.SearchMod(inputParts[0]); if (inputParts.Length > 1) { candidateSpellName = spellCreateComponent.SearchSpell(inputParts[1]); if (candidateSpellName == null) { typo = true; } } if (candidateModName == null) { typo = true; } } if (currentText.text.Trim().Length >= 3 && candidateSpellName != null) { SpellInit hintS = spellCreateComponent.getSpellIfExists(candidateSpellName); if (hintS != null && hintS is SpellHintReaction) { ((SpellHintReaction)hintS).onHintRequest(); } hintLogic.ShowSpellDescription(candidateSpellName, hintS); } } if (typo) { spellCheck.Alert(); } else { spellCheck.Unalert(); } if (Input.GetButtonDown("Submit") && Input.GetButton("Shift")) { spellCreateComponent.castSpell(inputText); print("Searching spell: " + inputText + ".\n"); currentText.text = ""; } else if (Input.GetKeyDown(KeyCode.Backspace) && currentText.text.Length > 0) { currentText.text = currentText.text.Substring(0, currentText.text.Length - 1); } else if (!Input.GetKeyDown(KeyCode.Return) && currentText.text.Length < 30 && Input.inputString.Length == 1) { char ch = Input.inputString[0]; if (ch == ' ' || Char.IsDigit(ch) || (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')) { currentText.text += ch; } } }
// show description public void ShowSpellDescription(string name, SpellInit si) { SetInfo(name, si.Description); }
public void addSpell(string name, SpellInit sp) { spellbook.Add(name, sp); }