Example #1
0
        private object extractValue(IAttributeLoader attributeLoader, XmlNode node)
        {
            switch (node.Name)
            {
            case "bool":
                bool b = bool.Parse(node.InnerText);
                return(b);

            case "string":
                return(node.InnerText);

            case "int":
                int i = int.Parse(node.InnerText);
                return(i);

            case "float":
                float f = float.Parse(node.InnerText, NumberStyles.Number,
                                      CultureInfo.InvariantCulture.NumberFormat);
                return(f);

            case "double":
                double d = double.Parse(node.InnerText, NumberStyles.Number,
                                        CultureInfo.InvariantCulture.NumberFormat);
                return(d);

            default:
                return(attributeLoader.Load(node));
            }
        }
Example #2
0
        internal void Load(IAttributeLoader attributeLoader, string xmlFile)
        {
            XmlDocument xml = new XmlDocument();

            xml.Load(xmlFile);

            XmlNode behaviorNode = xml.GetElementsByTagName("behaviors")[0];

            foreach (XmlNode node in behaviorNode.ChildNodes)
            {
                Type      t     = System.Type.GetType(typeof(IBehavior).Namespace + "." + node.Name);
                object[]  param = new object[] { this };
                IBehavior b     = Activator.CreateInstance(t, param) as IBehavior;

                AddBehavior(b);
            }

            XmlNode attributeNode = xml.GetElementsByTagName("attributes")[0];

            foreach (XmlNode node in attributeNode.ChildNodes)
            {
                if (node.Attributes != null) // used to handle comment nodes
                {
                    if (!HasAttribute(node.Attributes["key"].Value))
                    {
                        continue;
                    }

                    dynamic value = extractValue(attributeLoader, node);
                    this[node.Attributes["key"].Value] = value;
                }
            }
        }
Example #3
0
 public CollectionLoader(ICollectionRepo collectionRepo, ICollectionRelationshipRepo collectionRelationshipRepo, IAttributeLoader attributeLoader, IImageLoader imageLoader, IItemLoader itemLoader)
 {
     _collectionRelationshipRepo = collectionRelationshipRepo;
     _collectionRepo             = collectionRepo;
     _attributeLoader            = attributeLoader;
     _imageLoader = imageLoader;
     _itemLoader  = itemLoader;
 }
Example #4
0
 private void AddLoader(IAttributeLoader loader, LoadMode mode)
 {
     if (loader.SupportsMode(mode))
     {
         m_attributeLoaders.Add(loader.AppliesTo, loader);
         loader.GameLoader = this;
     }
 }
Example #5
0
 private void AddLoader(IAttributeLoader loader, LoadMode mode)
 {
     if (loader.SupportsMode(mode))
     {
         m_attributeLoaders.Add(loader.AppliesTo, loader);
         loader.GameLoader = this;
     }
 }
 public EntityFactory(GameLogic game)
 {
     this.game         = game;
     this.eventManager = game.EventManager;
     attributeLoader   = new DefaultAttributeLoader(game.ResourceManager);
 }
Example #7
0
 private void AddLoader(IAttributeLoader loader)
 {
     m_attributeLoaders.Add(loader.AppliesTo, loader);
     loader.GameLoader = this;
 }
Example #8
0
 public DependencyLoader(IAttributeLoader attributeLoader)
 {
     AttributeLoader = attributeLoader;
 }
Example #9
0
 public ItemLoader(IItemRepo repo, IAttributeLoader attributeLoader, IImageLoader imageLoader)
 {
     _itemRepo        = repo;
     _attributeLoader = attributeLoader;
     _imageLoader     = imageLoader;
 }
Example #10
0
 private void AddLoader(IAttributeLoader loader)
 {
     m_attributeLoaders.Add(loader.AppliesTo, loader);
     loader.GameLoader = this;
 }