コード例 #1
0
 /// <summary>
 /// Creates the parameter of an object
 /// </summary>
 /// <param name="xml">xml target</param>
 /// <param name="target">current node</param>
 /// <param name="flat">current prototype</param>
 /// <param name="dict">reference dictionary</param>
 void CreateParameter(XmlDocument xml, XmlNode target, FlatPrototype flat, Dict dict)
 {
     if (flat.Parameter.Count == 0)
     {
         return;
     }
     target = target.AppendChild(xml.CreateElement("Parameter"));
     foreach (var param in flat.Parameter)
     {
         XmlNode node;
         if (param.Value.Name == "Math")
         {
             node = CreateMathParameter(xml, target, param.Value, dict);
             node.Attributes.Append(xml.CreateAttribute("name")).Value = param.Key;
         }
         else
         {
             var ptype = param.Value.GetType().FullName;
             var name  = PrototypeLoader.ParameterTypes.ToList().Find((p) => p.Value.FullName == ptype).Key;
             node = target.AppendChild(xml.CreateElement(name));
             node.Attributes.Append(xml.CreateAttribute("name")).Value = param.Key;
             var value = GetParamValue(param.Value, dict, false);
             if (value != null)
             {
                 node.Attributes.Append(xml.CreateAttribute("value")).Value = value;
             }
         }
         if (dict.ValueWrapper.ContainsKey(param.Value))
         {
             node.Attributes.Append(xml.CreateAttribute("id")).Value = dict.ValueWrapper[param.Value].ToString();
         }
     }
 }
コード例 #2
0
 /// <summary>
 /// Creates the animations of an object
 /// </summary>
 /// <param name="xml">xml target</param>
 /// <param name="target">current node</param>
 /// <param name="flat">current prototype</param>
 /// <param name="dict">reference dictionary</param>
 void CreateAnimations(XmlDocument xml, XmlNode target, FlatPrototype flat, Dict dict)
 {
     if (flat.Animations.Count == 0)
     {
         return;
     }
     target = target.AppendChild(xml.CreateElement("Animation"));
     foreach (var group in flat.Animations)
     {
         var node = target.AppendChild(xml.CreateElement("Group"));
         //node.Attributes.Append(xml.CreateAttribute("name")).Value = group.Name;
         node.Attributes.Append(xml.CreateAttribute("id")).Value = "#" + dict.Groups[group].ToString();
         if (group.Activations.Count > 0)
         {
             var sub = node.AppendChild(xml.CreateElement("Activation"));
             foreach (var effect in group.Activations)
             {
                 sub.AppendChild(effect.ToXml(xml, dict));
             }
         }
         if (group.Effects.Count > 0)
         {
             var sub = node.AppendChild(xml.CreateElement("Effects"));
             sub.Attributes.Append(xml.CreateAttribute("timing")).Value = GetParamValue(group.EffectTiming, dict);
             foreach (var effect in group.Effects)
             {
                 sub.AppendChild(effect.ToXml(xml, dict));
             }
         }
     }
 }
コード例 #3
0
 /// <summary>
 /// lookup for all referencing stuff in the prototype
 /// </summary>
 /// <param name="flat">current prototype</param>
 /// <param name="dict">reference dictionary for values</param>
 /// <param name="d">reference dictionary</param>
 void CreateLookup(FlatPrototype flat, Dictionary <IValueWrapper, Counter> dict, Dict d)
 {
     foreach (var sub in flat.Container)
     {
         CreateLookup(sub, dict, d);
     }
     foreach (var param in flat.Parameter)
     {
         LookupParam(param.Value, dict, d);
     }
     foreach (var group in flat.Animations)
     {
         d.Groups.Add(group, d.Counter++);
         LookupParam(group.EffectTiming, dict, d);
         foreach (var act in group.Activations)
         {
             foreach (var p in act.GetValueWrapper())
             {
                 LookupParam(p, dict, d);
             }
         }
         foreach (var eff in group.Effects)
         {
             foreach (var p in eff.GetValueWrapper())
             {
                 LookupParam(p, dict, d);
             }
         }
     }
 }
コード例 #4
0
        /// <summary>
        /// Create the object node
        /// </summary>
        /// <param name="xml">xml target</param>
        /// <param name="flat">current prototype</param>
        /// <param name="dict">reference dictionary</param>
        /// <returns></returns>
        XmlNode CreateObjectNode(XmlDocument xml, FlatPrototype flat, Dict dict)
        {
            var node = xml.CreateElement(flat.RenderName);

            CreateContainer(xml, node, flat, dict);
            CreateAnimations(xml, node, flat, dict);
            CreateParameter(xml, node, flat, dict);

            return(node);
        }
コード例 #5
0
 /// <summary>
 /// Find all used types if renderer in the prototype
 /// </summary>
 /// <param name="flat">prototype</param>
 /// <param name="types">current list to extend</param>
 void FindTypes(FlatPrototype flat, List <string> types)
 {
     if (!types.Contains(flat.RenderName))
     {
         types.Add(flat.RenderName);
     }
     foreach (var s in flat.Container)
     {
         FindTypes(s, types);
     }
 }
コード例 #6
0
        /// <summary>
        /// Create the container of an object
        /// </summary>
        /// <param name="xml">xml target</param>
        /// <param name="target">current node</param>
        /// <param name="flat">current prototype</param>
        /// <param name="dict">reference dictionary</param>
        void CreateContainer(XmlDocument xml, XmlNode target, FlatPrototype flat, Dict dict)
        {
            if (flat.Container.Count == 0)
            {
                return;
            }
            var node = target.AppendChild(xml.CreateElement("Container"));

            foreach (var sub in flat.Container)
            {
                node.AppendChild(CreateObjectNode(xml, sub, dict));
            }
        }