public Template() { Properties = new PropertyBag(); Stats = new StatBag(); Scripts = new List<uint>(); GameObjectType = GOT.None; }
public Template() { Properties = new PropertyBag(); Stats = new StatBag(); Scripts = new List <uint>(); GameObjectType = GOT.None; }
public static StatBag GetStaticStats(this DB db) { StatBag rslt = new StatBag(); SqlConnection con = new SqlConnection(DB.GameDataConnectionString); SqlCommand cmd = DB.GetCommand(con, "GetStaticStats", true); try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Stat s = (Stat)Enum.Parse(typeof(Stat), reader["StatName"] as string); Stat stat = StatManager.Instance[s.StatID]; rslt.AddStat(new Stat(stat.StatID, stat.DisplayName, stat.Description, reader["StatGroup"] as string, (int)reader["StatValue"], stat.MinValue, stat.MaxValue)); } } catch (Exception e) { int x = 0; } finally { if (con != null) { con.Close(); con.Dispose(); con = null; } } return rslt; }
public static void AddStatBag(ref byte[] dat, Pointer curPointer, StatBag bag) { Stat[] stats = bag.AllStats; AddString(ref dat, curPointer, bag.Name); AddString(ref dat, curPointer, bag.ID.ToString()); AddInt(ref dat, curPointer, stats.Length); for (int i = 0; i < stats.Length; i++) { AddStat(ref dat, curPointer, stats[i]); } }
public GenericGameObject() : base() { Scripts = new ObjectScriptManager(this); Effects = new EffectManager(this); m_UID = Guid.NewGuid(); CreatedOn = DateTime.Now; ItemTemplate = ""; Stats = new StatBag(); Properties = new PropertyBag(); ObjectName = ""; }
private static StatBag DeserializeFromXML() { StatBag bag = new StatBag(); StatManager mgr = null; List<Stat> stats = new List<Stat>(); XMLHelper.Stats_LoadDefinitions("\\Config\\Stats.xml", stats); foreach (Stat s in stats) { bag.AddStat(s); } return bag; }
public void UpdateWithValues(StatBag statsToUpdate) { if (statsToUpdate == null) { return; } Stat[] stats = statsToUpdate.AllStats; for (int i = 0; i < stats.Length; i++) { Stat cloneStat = new Stat(stats[i].StatID, stats[i].DisplayName, stats[i].Description, stats[i].Group, stats[i].CurrentValue, stats[i].MinValue, stats[i].MaxValue); cloneStat.Owner = this; AddStat(cloneStat); } }
private static StatBag DeserializeFromXML() { StatBag bag = new StatBag(); StatManager mgr = null; List <Stat> stats = new List <Stat>(); XMLHelper.Stats_LoadDefinitions("\\Config\\Stats.xml", stats); foreach (Stat s in stats) { bag.AddStat(s); } return(bag); }
public static StatBag GetStatBag(byte[] data, Pointer p) { StatBag bag = new StatBag(); bag.Name = GetString(data, p); bag.ID = new Guid(GetString(data, p)); int num = GetInt(data, p); for (int i = 0; i < num; i++) { bag.AddStat(GetStat(data, p, true, bag)); } return(bag); }
public static Stat GetStat(byte[] dat, Pointer p, bool withInfoText, StatBag bag) { Stat s = new Stat(); s.StatID = GetInt(dat, p); float curVal = GetSingle(dat, p); s.MinValue = GetSingle(dat, p); s.MaxValue = GetSingle(dat, p); s.ForceValue(curVal); s.Owner = bag; if (withInfoText) { s.DisplayName = GetString(dat, p); s.Description = GetString(dat, p); s.Group = GetString(dat, p); } return(s); }
/// <summary> /// Reads the character.xml file and returns a list of properties that that character should have /// </summary> /// <param name="filePath"></param> /// <returns></returns> public static bool Character_GetPropertyTypesFromTemplate(string filePath, ref PropertyBag props, ref StatBag stats) { XPathDocument doc = LoadDocument(filePath, true); XPathNavigator nav = null; string[] sections = new string[] { "StringProperties", "IntProperties", "LongProperties", "FloatProperties" }; try { if (doc == null) { return(false); } nav = doc.CreateNavigator(); for (int i = 0; i < sections.Length; i++) { XPathNodeIterator iter = nav.Select(@"./Template/Character/PropertyBag/" + sections[i] + "/Property"); while (iter.MoveNext()) { string id = iter.Current.GetAttribute("ID", ""); if (id == null || id.Length < 1) { Log.LogMsg("Error reading ID attribute in node " + iter.Current.InnerXml); continue; } string name = iter.Current.GetAttribute("Name", ""); if (name == null) { name = ""; } int propertyTypeID = int.Parse(id); if (sections[i] == "IntProperties") { int value = int.Parse(iter.Current.Value); props.SetProperty(name, propertyTypeID, value); } else if (sections[i] == "StringProperties") { props.SetProperty(name, propertyTypeID, iter.Current.Value); } else if (sections[i] == "FloatProperties") { float value = float.Parse(iter.Current.Value); props.SetProperty(name, propertyTypeID, value); } else if (sections[i] == "LongProperties") { long value = long.Parse(iter.Current.Value); props.SetProperty(name, propertyTypeID, value); } } } // Stats XPathNodeIterator statIter = nav.Select(@"./Template/Character/StatBag/Stat"); while (statIter.MoveNext()) { int id = int.Parse(statIter.Current.GetAttribute("StatID", "")); Stat proto = StatManager.Instance[id]; if (proto == null) { Log.LogMsg("Error reading character template. Stat id [" + id + "] was specified but was not loaded from the Stats.xml configuration file. Stat not added to character."); continue; } float currentValue = float.Parse(statIter.Current.Value); Stat s = new Stat(id, proto.DisplayName, proto.Description, proto.Group, currentValue, proto.MinValue, proto.MaxValue); stats.AddStat(s); } } catch (Exception e) { Log.LogMsg("Failed to load character properties from template."); //Log.LogMsg("Exception thrown reading Character template. " + e.Message); return(false); } return(true); }
public CharacterInfo() { Properties = new PropertyBag(); Stats = new StatBag(); }
/// <summary> /// Reads the character.xml file and returns a list of properties that that character should have /// </summary> /// <param name="filePath"></param> /// <returns></returns> public static bool Character_GetPropertyTypesFromTemplate(string filePath, ref PropertyBag props, ref StatBag stats) { XPathDocument doc = LoadDocument(filePath, true); XPathNavigator nav = null; string[] sections = new string[] { "StringProperties", "IntProperties", "LongProperties", "FloatProperties" }; try { if (doc == null) { return false; } nav = doc.CreateNavigator(); for (int i = 0; i < sections.Length; i++) { XPathNodeIterator iter = nav.Select(@"./Template/Character/PropertyBag/" + sections[i] + "/Property"); while (iter.MoveNext()) { string id = iter.Current.GetAttribute("ID", ""); if (id == null || id.Length < 1) { Log.LogMsg("Error reading ID attribute in node " + iter.Current.InnerXml); continue; } string name = iter.Current.GetAttribute("Name", ""); if (name == null) { name = ""; } int propertyTypeID = int.Parse(id); if (sections[i] == "IntProperties") { int value = int.Parse(iter.Current.Value); props.SetProperty(name, propertyTypeID, value); } else if (sections[i] == "StringProperties") { props.SetProperty(name, propertyTypeID, iter.Current.Value); } else if (sections[i] == "FloatProperties") { float value = float.Parse(iter.Current.Value); props.SetProperty(name, propertyTypeID, value); } else if (sections[i] == "LongProperties") { long value = long.Parse(iter.Current.Value); props.SetProperty(name, propertyTypeID, value); } } } // Stats XPathNodeIterator statIter = nav.Select(@"./Template/Character/StatBag/Stat"); while (statIter.MoveNext()) { int id = int.Parse(statIter.Current.GetAttribute("StatID", "")); Stat proto = StatManager.Instance[id]; if (proto == null) { Log.LogMsg("Error reading character template. Stat id [" + id + "] was specified but was not loaded from the Stats.xml configuration file. Stat not added to character."); continue; } float currentValue = float.Parse(statIter.Current.Value); Stat s = new Stat(id, proto.DisplayName, proto.Description, proto.Group, currentValue,proto.MinValue, proto.MaxValue); stats.AddStat(s); } } catch (Exception e) { Log.LogMsg("Failed to load character properties from template."); //Log.LogMsg("Exception thrown reading Character template. " + e.Message); return false; } return true; }
public void RemoveStats(StatBag statsToRemove) { RemoveStats(statsToRemove.AllStats); }
public static StatBag GetStatBag(byte[] data, Pointer p) { StatBag bag = new StatBag(); bag.Name = GetString(data, p); bag.ID = new Guid(GetString(data, p)); int num = GetInt(data, p); for (int i = 0; i < num; i++) { bag.AddStat(GetStat(data, p, true, bag)); } return bag; }
public StatManager() { AllStats = new StatBag(); }
public static Stat GetStat(byte[] dat, Pointer p, bool withInfoText, StatBag bag) { Stat s = new Stat(); s.StatID = GetInt(dat, p); float curVal = GetSingle(dat, p); s.MinValue = GetSingle(dat, p); s.MaxValue = GetSingle(dat, p); s.ForceValue(curVal); s.Owner = bag; if (withInfoText) { s.DisplayName = GetString(dat, p); s.Description = GetString(dat, p); s.Group = GetString(dat, p); } return s; }