/// <summary> /// Loads spell entries from provided file into provided dictionary /// </summary> /// <param id="dict">Dictionary the entries will be loaded into</param> /// <param id="xmlFile">File the entries are loaded from</param> public static void LoadEffects(SortedDictionary<string, EffectDb> dict, XDocument xmlFile, Dictionary<string, SpellEntry> code) { var effectsXml = xmlFile.Descendants("Effect"); foreach (var effectXml in effectsXml) { EffectDb effectEntry = new EffectDb(); foreach (XNode en in effectXml.Nodes()) { XElement e = en as XElement; if (e == null) continue; switch (e.Name.LocalName.ToLower()) { case "id": effectEntry.Id = e.Value; break; case "name": effectEntry.Name = e.Value; break; case "tier": effectEntry.Tier = int.Parse(e.Value); break; case "texture": if (!UI.Instance.HaveTexture(e.Value)) { throw new Exception("Entry: " + effectEntry.Id + " - texture " + e.Value + " not found"); } effectEntry.Texture = UI.Instance.GetTexture(e.Value); break; case "spellcodeid": SpellEntry spellEntry; if (!code.TryGetValue(e.Value, out spellEntry)) { throw new Exception("Entry: " + effectEntry.Id + " - spell code " + e.Value + " not found"); } effectEntry.Spell = spellEntry; break; case "duration": effectEntry.Duration = int.Parse(e.Value); break; case "speed": effectEntry.Speed = int.Parse(e.Value); break; case "castrange": effectEntry.CastRange = int.Parse(e.Value); break; case "autorepeat": effectEntry.AutoRepeat = bool.Parse(e.Value); break; case "cooldown": effectEntry.Cooldown = int.Parse(e.Value); break; case "unlockedby": effectEntry.UnlockedByUR = e.Value; break; } } dict.Add(effectEntry.Id, effectEntry); } }
/// <summary> /// Constructor for scripted GameEffect /// </summary> /// <param id="effect">The effect database entry</param> /// <param id="caster">The caster of the spell</param> /// <param id="target">Target game entity for the effect</param> public GameEffect(EffectDb effect, IScriptUnit caster, IScriptGameEntity target) { this.targetEntity = target; this.Entry = effect; this.caster = caster; LocalData = new List<object>(); Active = true; Time = 0; Graphical = false; GraphicalOverlay = false; }