Ejemplo n.º 1
0
        public static BoundMaterialColour[] GetRawBoundMaterialColourArray(XmlNode node)
        {
            if (node == null)
            {
                return(null);
            }
            byte r, g, b, a;
            var  items = new List <BoundMaterialColour>();
            var  split = node.InnerText.Split('\n');// Regex.Split(node.InnerText, @"[\s\r\n\t]");

            for (int i = 0; i < split.Length; i++)
            {
                var s = split[i]?.Trim();
                if (string.IsNullOrEmpty(s))
                {
                    continue;
                }
                var split2 = s.Split(',');// Regex.Split(s, @"[\s\t]");
                int c      = 0;
                r = 0; g = 0; b = 0; a = 0;
                for (int n = 0; n < split2.Length; n++)
                {
                    var ts = split2[n]?.Trim();
                    if (string.IsNullOrEmpty(ts))
                    {
                        continue;
                    }
                    byte v = 0;
                    byte.TryParse(ts, out v);
                    switch (c)
                    {
                    case 0: r = v; break;

                    case 1: g = v; break;

                    case 2: b = v; break;

                    case 3: a = v; break;
                    }
                    c++;
                }
                if (c >= 2)
                {
                    var val = new BoundMaterialColour();
                    val.R = r;
                    val.G = g;
                    val.B = b;
                    val.A = a;
                    items.Add(val);
                }
            }

            return((items.Count > 0) ? items.ToArray() : null);
        }
Ejemplo n.º 2
0
 public static string FormatBoundMaterialColour(BoundMaterialColour c) //for use with WriteItemArray
 {
     return(c.R.ToString() + ", " + c.G.ToString() + ", " + c.B.ToString() + ", " + c.A.ToString());
 }