Exemplo n.º 1
0
        //
        #region Utility
        private void SavingPropertiesList(XmlDocument doc, XmlElement root, PropertiesList list)
        {
            foreach (var i in list)
            {
                // Type convert
                string text = null;
                if (i.GetType().IsSubclassOf(typeof(IntPropertiesBase)))
                {
                    text = ((IntPropertiesBase)i).int_value.ToString();
                }
                else if (i.GetType().IsSubclassOf(typeof(FloatPropertiesBase)))
                {
                    text = ((FloatPropertiesBase)i).float_value.ToString();
                }
                else if (i.GetType().IsSubclassOf(typeof(BoolPropertiesBase)))
                {
                    text = ((BoolPropertiesBase)i).bool_value.ToString();
                }
                else if (i.GetType().IsSubclassOf(typeof(StringPropertiesBase)))
                {
                    text = ((StringPropertiesBase)i).string_value;
                }

                XmlElement element = doc.CreateElement(i.GetType().Name);
                element.InnerText = text;
                root.AppendChild(element);
            }
        }
Exemplo n.º 2
0
        //
        #region Utility
        private PropertiesList LoadPropertiesList(XmlNode root)
        {
            PropertiesList result = new PropertiesList();

            // Check all the properties this player have
            foreach (var i in root.ChildNodes)
            {
                // Loop the properties exist list and get the type full name
                XmlNode content = ((XmlNode)i);
                propertiesBuffer.ForEach(x =>
                {
                    // If the type full name equal the xml node name
                    // This mean it is the properties we want to create new for
                    if (x.Item2 == content.Name)
                    {
                        // Properties type initialize arg
                        object arg = null;

                        // Type convert
                        if (x.Item1.IsSubclassOf(typeof(IntPropertiesBase)))
                        {
                            arg = Convert.ToInt32(content.InnerText);
                        }
                        else if (x.Item1.IsSubclassOf(typeof(FloatPropertiesBase)))
                        {
                            arg = Convert.ToSingle(content.InnerText);
                        }
                        else if (x.Item1.IsSubclassOf(typeof(BoolPropertiesBase)))
                        {
                            arg = Convert.ToBoolean(content.InnerText);
                        }
                        else if (x.Item1.IsSubclassOf(typeof(StringPropertiesBase)))
                        {
                            arg = content.InnerText;
                        }

                        // Create properties instance
                        PropertiesBase propertyInstance = (PropertiesBase)ass.CreateInstance(x.Item1.FullName,
                                                                                             false,
                                                                                             BindingFlags.Public | BindingFlags.Instance,
                                                                                             null,
                                                                                             new object[] { arg },
                                                                                             null,
                                                                                             null);

                        // Adding to the list
                        result.Add(propertyInstance);
                    }
                });
            }
            return(result);
        }
Exemplo n.º 3
0
 public PropertiesList Calculate(PropertiesList obj)
 {
     foreach (var i in this)
     {
         foreach (var j in obj)
         {
             if (i.TypeCheck(j.GetType()))
             {
                 j.value = i.Calculate(j.value);
                 break;
             }
         }
     }
     return(obj);
 }
Exemplo n.º 4
0
 protected CreatureBase()
 {
     Properties  = new PropertiesList();
     Effects     = new EffectList(this);
     MapPosition = new CreaturePosition();
 }