Example #1
0
        static object LoadShape(MiniYaml yaml)
        {
            IHitShape ret;

            var shapeNode = yaml.Nodes.Find(n => n.Key == "Shape");
            var shape     = shapeNode != null ? shapeNode.Value.Value : string.Empty;

            if (!string.IsNullOrEmpty(shape))
            {
                ret = WarGame.CreateObject <IHitShape>(shape + "Shape");
                try
                {
                    FieldLoader.Load(ret, shapeNode.Value);
                }
                catch (YamlException e)
                {
                    throw new YamlException("HitShape {0}:{1}".F(shape, e.Message));
                }
            }
            else
            {
                ret = new CircleShape();
            }
            ret.Initialize();
            return(ret);
        }