示例#1
0
文件: Template.cs 项目: kamilion/WISP
 public Template()
 {
     Properties = new PropertyBag();
     Stats = new StatBag();
     Scripts = new List<uint>();
     GameObjectType = GOT.None;
 }
示例#2
0
 public Template()
 {
     Properties     = new PropertyBag();
     Stats          = new StatBag();
     Scripts        = new List <uint>();
     GameObjectType = GOT.None;
 }
示例#3
0
        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;
        }
示例#4
0
 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]);
     }
 }
示例#5
0
        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   = "";
        }
示例#6
0
        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 = "";
        }
示例#7
0
        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;
        }
示例#8
0
 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);
     }
 }
示例#9
0
        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);
        }
示例#10
0
        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);
        }
示例#11
0
        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);
        }
示例#12
0
        /// <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);
        }
示例#13
0
 public CharacterInfo()
 {
     Properties = new PropertyBag();
     Stats      = new StatBag();
 }
示例#14
0
        /// <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;
        }
示例#15
0
 public void RemoveStats(StatBag statsToRemove)
 {
     RemoveStats(statsToRemove.AllStats);
 }
示例#16
0
        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;
        }
示例#17
0
 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]);
     }
 }
示例#18
0
文件: StatBag.cs 项目: kamilion/WISP
 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);
     }
 }
示例#19
0
文件: StatBag.cs 项目: kamilion/WISP
 public void RemoveStats(StatBag statsToRemove)
 {
     RemoveStats(statsToRemove.AllStats);
 }
示例#20
0
 public StatManager()
 {
     AllStats = new StatBag();
 }
示例#21
0
        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;
        }
示例#22
0
 public StatManager()
 {
     AllStats = new StatBag();
 }
示例#23
0
 public CharacterInfo()
 {
     Properties = new PropertyBag();
     Stats = new StatBag();
 }