/// <summary> /// Parse Xml configuration /// </summary> /// <param name="element">Stat node from Xml configuration</param> /// <returns>Stat instance</returns> public Stat ParseTalentStat(XElement element) { if (element == null) throw new ArgumentNullException("element"); var dependencyType = StatDependencyEnum.None; var dependencyElement = element.Element("dependency"); if (dependencyElement != null && !string.IsNullOrEmpty(dependencyElement.Value)) dependencyType = (StatDependencyEnum)Enum.Parse(typeof(StatDependencyEnum), dependencyElement.Value, true); switch (dependencyType) { case StatDependencyEnum.None: case StatDependencyEnum.Time: case StatDependencyEnum.Score: { var stat = new Stat(); FillStat(element, stat); if (dependencyType != StatDependencyEnum.None) FillDependency(element, stat); return stat; } case StatDependencyEnum.Terrain: { var stat = new StatTerrain(); FillStat(element, stat); FillDependency(element, stat); FillStatTerrain(element, stat); return stat; } default: throw new NotSupportedException(string.Format("{0} is not supported!", dependencyType.ToString())); } }
/// <summary> /// Fill stat terrain data /// </summary> /// <param name="element">Stat node from Xml configuration</param> /// <param name="stat">Stat instance</param> protected void FillStatTerrain(XElement element, StatTerrain stat) { if (element == null) throw new ArgumentNullException("element"); if (stat == null) throw new ArgumentNullException("stat"); var value = element.Element("dependency").Value; stat.Dependency = (StatDependencyEnum)Enum.Parse(typeof(StatDependencyEnum), value, true); }