public bool LearnSpell(SpellBuilder spell, int percentageOfSuccess) { if (spell.SatisfyRequisite(this)) { //if(this.Spellbook.Contains(spell)) // TO BE TESTED if (this.Spellbook.Where(spellKnown => spell.GetType() == spellKnown.GetType()).Count() > 0) { NotifyListeners(String.Format("{0} already known", spell.Name)); return(false); } var chance = Dice.Throws(new Dice(nFaces: 100)); // Every +1 in modifiers for a d20 is 5% chance -= this.Stats[StatsType.Mental].ModifierOfStat() * 5; if (percentageOfSuccess == 100 || chance < percentageOfSuccess) { this.Spellbook.Add(spell); NotifyListeners(String.Format("{0} learnt", spell.Name)); return(true); } else { NotifyListeners(String.Format("Ritual has gone wrong!!", spell.Name)); return(true); } } else { NotifyListeners(String.Format("Can't satisfy prerequisites to learn {0}", spell.Name)); return(false); } }
private void MakeSpell() { List <SpellEffectInfo> spEfInf = new List <SpellEffectInfo>(); int currentIndex = _indexesOfDamagedSpells[_numOfCreatedSpells]; if (_numOfCreatedSpells + 1 == _indexesOfDamagedSpells.Count) { for (int i = _numOfCreatedSpells; i < _spellInfo.spellEffectInfos.Count; i++) { spEfInf.Add(_spellInfo.spellEffectInfos[i]); //Because now all other effects are sequential } } else { spEfInf.Add(_spellInfo.spellEffectInfos[currentIndex]); } SpellInfo spIn = new SpellInfo( _spellInfo.charSpellsIndex, _spellInfo.isInstant, _spellInfo.dontShowToUser, _spellInfo.needTargetToComeNear, _spellInfo.spellName, _spellInfo.cost, _spell.name, _spellInfo.spellType, _spellInfo.damageType, _spellInfo.spellImpact, spEfInf ); spIn.owner = _spellInfo.owner; SpellCastTransData transData = new SpellCastTransData(); SpellCastHelper_MultiSpell helper_multiCast = gameObject.GetComponent <SpellCastHelper_MultiSpell>(); if (helper_multiCast != null) { transData = helper_multiCast.FindProperCastingPos(spIn.owner, _spellInfo.spellEffectInfos[currentIndex].targetCharacter); } else { transData.position = transform.position; transData.rotationAmount = 0; transData.scale = transform.localScale; } Spell temp = SpellBuilder.Build(spIn, transData); temp.Event_SpellWillDestroy += OnSpellDestroy; _createdSpells.Add(temp); _numOfCreatedSpells++; }
// Use this for initialization void Start() { //For DEV: comment the following line to reset the preferences //PlayerPrefs.DeleteAll (); //PlayerPrefs.SetString ("test", "hello world"); //var testVal = PlayerPrefs.GetString ("test"); spellBuilder = GameObject.Find("SpellBuilder").GetComponent <SpellBuilder> (); spellBuilder.OnSpellComplete += SaveSpellResult; }
// Use this for initialization void Start () { //For DEV: comment the following line to reset the preferences //PlayerPrefs.DeleteAll (); //PlayerPrefs.SetString ("test", "hello world"); //var testVal = PlayerPrefs.GetString ("test"); spellBuilder = GameObject.Find("SpellBuilder").GetComponent<SpellBuilder> (); spellBuilder.OnSpellComplete += SaveSpellResult; }
public PrayerBook(SpellBuilder spell, int percOfSuccess = 100, Coord position = new Coord(), int cost = 0, int weight = 2, int uses = 1) : base("Prayer Book", "=", System.Drawing.Color.Brown, description: "A heavy book of ancient prayers", position: position, cost: cost, weight: weight, uses: uses) { this.spell = spell; this.percOfSuccess = percOfSuccess; }
private void OnCharVisualSpellCast(SpellInfo spellInfo) { if (_currentSpell == null) { _currentSpell = SpellBuilder.Build(spellInfo, _charVisual.GetSpellTransData()); _currentSpell.Event_SpellWillDestroy += OnCurrentSpellDestroy; if (Event_SpellCast != null) { Event_SpellCast(_currentSpell); } } else { _currentSpell.HappenedAgain(); } }
void OnEnable() { if (instance == null) { instance = this; } else { Destroy(this); } if (SpellDataBase.GetSpellDB() == null) { Debug.Log("Hi"); spellDB = new SpellDataBase(); } else { spellDB = SpellDataBase.GetSpellDB(); } minSize = new Vector2(500, 100); guiStyle = new GUIStyle(); guiStyle.richText = true; spellDB.SetSpellData(); serObjSpellDB = new SerializedObject(spellDB as object as Object); incompProp = serObjSpellDB.FindProperty("incomplete"); incompSpells = new ReorderableList(serObjSpellDB, incompProp, true, true, true, true); incompSpells.drawHeaderCallback = (rect) => EditorGUI.LabelField(new Rect(5, 10, 100, 20), "<size=12><color=orange><b>In Progress</b></color></size>", guiStyle); incompSpells.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { rect.y += 2; SerializedProperty spell = incompSpells.serializedProperty.GetArrayElementAtIndex(index); EditorGUI.PropertyField(new Rect(rect.x, rect.y, 100, EditorGUIUtility.singleLineHeight), spell.FindPropertyRelative("spellName"), GUIContent.none); }; }
public PrayerBook(SerializationInfo info, StreamingContext context) : base(info, context) { this.spell = (SpellBuilder)info.GetValue(spellSerializableName, typeof(SpellBuilder)); this.percOfSuccess = (int)info.GetValue(percOfSuccessSerializableName, typeof(int)); }
static void CreateWindow() { instance = GetWindow <SpellBuilder>(); }
public void ForgetSpell(SpellBuilder spell) { this.Spellbook.Remove(spell); }
// Use this for initialization void Start () { var spellBuilder = new SpellBuilder (); }
// Use this for initialization void Start() { var spellBuilder = new SpellBuilder(); }
public void NotifyAdd(SpellBuilder[] spellsInSpellbook) { descriptionList.Items = spellsInSpellbook.ToList(); }