Exemple #1
0
 public override void Write(StreamWriter writer)
 {
     writer.WriteLine("      <array>");
     writer.WriteLine("        <vec3>{0} {1} 0</vec3>", LevelConverter.ToPixels(x), LevelConverter.ToPixels(y));
     writer.WriteLine("        <int>{0}</int>", id);
     writer.WriteLine("        <dict>");
     writer.WriteLine("          <bool name=\"cast-shadows\">f</bool>");
     writer.WriteLine("          <vec4 name=\"color\">{0} {1} {2} 0</vec4>", transform(m_r), transform(m_g), transform(m_b));
     writer.WriteLine("          <float name=\"size\">{0}</float>", m_size * 16.0f * 0.8f);
     writer.WriteLine("        </dict>");
     writer.WriteLine("      </array>");
 }
Exemple #2
0
 public override void Write(StreamWriter writer)
 {
     writer.WriteLine("      <array>");
     writer.WriteLine("        <vec3>{0} {1} 0</vec3>", LevelConverter.ToPixels(x), LevelConverter.ToPixels(y));
     writer.WriteLine("        <int>{0}</int>", id);
     writer.WriteLine("        <dict>");
     writer.WriteLine("          <bool name=\"sensor\">t</bool>");
     writer.WriteLine("          <bool name=\"shoot-through\">t</bool>");
     writer.WriteLine("          <vec2 name=\"size\">{0} {1}</vec2>", m_w * 16.0f, m_h * 16.0f);
     writer.WriteLine("        </dict>");
     writer.WriteLine("      </array>");
 }
Exemple #3
0
 public override void Write(StreamWriter writer)
 {
     writer.WriteLine("      <array>");
     writer.WriteLine("        <vec3>{0} {1} 0</vec3>", LevelConverter.ToPixels(x), LevelConverter.ToPixels(y));
     writer.WriteLine("        <int>{0}</int>", id);
     writer.WriteLine("        <dict>");
     writer.WriteLine("          <bool name=\"sensor\">t</bool>");
     writer.WriteLine("          <bool name=\"shoot-through\">t</bool>");
     writer.WriteLine("          <float name=\"radius\">{0}</float>", (m_diameter / 2.0f) * 16.0f);
     writer.WriteLine("        </dict>");
     writer.WriteLine("      </array>");
 }
Exemple #4
0
 public virtual void Write(StreamWriter writer)
 {
     if (!layer.HasValue)
     {
         writer.WriteLine("      <vec3>{0} {1} 0</vec3>", LevelConverter.ToPixels(x), LevelConverter.ToPixels(y));
         writer.WriteLine("      <int>{0}</int>", id);
     }
     else
     {
         writer.WriteLine("      <array>");
         writer.WriteLine("          <vec3>{0} {1} 0</vec3>", LevelConverter.ToPixels(x), LevelConverter.ToPixels(y));
         writer.WriteLine("          <int>{0}</int>", id);
         writer.WriteLine("          <dict><int name=\"layer\">{0}</int></dict>", layer.Value);
         writer.WriteLine("      </array>");
     }
 }
Exemple #5
0
        public override void Write(StreamWriter writer)
        {
            writer.WriteLine("    <array>");
            writer.WriteLine("      <string>{0}</string>", m_type);
            writer.WriteLine("      <int>{0}</int>", id);
            writer.WriteLine("      <vec3>{0} {1} 0</vec3>", LevelConverter.ToPixels(x), LevelConverter.ToPixels(y));
            writer.WriteLine("      <bool>{0}</bool>", m_enabled ? "t" : "f");
            writer.WriteLine("      <int>{0}</int>", m_triggerTimes);
            writer.WriteLine("      <bool>{0}</bool>", m_executeOnStart ? "t" : "f");

            if (m_params.Count > 0)
            {
                writer.WriteLine("      <dict>");
                foreach (var param in m_params)
                {
                    string paramType = "string";
                    string paramName = param.Key;

                    if (param.Value is Array)
                    {
                        writer.WriteLine("        <array name=\"{0}\">", paramName);
                        foreach (var o in (param.Value as Array))
                        {
                            var obj = o;
                            if (obj is int)
                            {
                                paramType = "int";
                            }
                            else if (obj is float)
                            {
                                paramType = "float";
                            }
                            else if (obj is OldUnitID)
                            {
                                paramType = "int";
                            }
                            else if (obj is bool)
                            {
                                paramType = "bool";
                                obj       = ((bool)obj ? "t" : "f");
                            }
                            else if (!(param.Value is string))
                            {
                                Debug.Assert(false);
                            }
                            writer.WriteLine("          <{0}>{1}</{0}>", paramType, obj);
                            //NOTE: The reason we can hack around this is because there are only 2 dynamic unit feeds in Hammerwatch! :)
                            if (paramName[0] == '#')
                            {
                                writer.WriteLine("          <string>LastSpawned</string>");
                            }
                        }
                        writer.WriteLine("        </array>");
                    }
                    else
                    {
                        string paramValue = param.Value.ToString();

                        if (param.Value is int)
                        {
                            paramType = "int";
                        }
                        else if (param.Value is float)
                        {
                            paramType = "float";
                        }
                        else if (param.Value is OldUnitID)
                        {
                            paramType = "int";
                        }
                        else if (param.Value is bool)
                        {
                            paramType  = "bool";
                            paramValue = ((bool)param.Value ? "t" : "f");
                        }
                        else if (!(param.Value is string))
                        {
                            Debug.Assert(false);
                        }

                        writer.WriteLine("        <{0} name=\"{1}\">{2}</{0}>", paramType, paramName, paramValue);
                    }
                }
                writer.WriteLine("      </dict>");
            }

            if (m_connections.Count > 0)
            {
                writer.WriteLine("      <array>");
                foreach (var conn in m_connections)
                {
                    int id    = conn.Item1;
                    int delay = conn.Item2;
                    writer.WriteLine("        <int>{0}</int><int>{1}</int>", id, delay);
                }
                writer.WriteLine("      </array>");
            }

            writer.WriteLine("    </array>");
        }