Example #1
0
        public static PatternHolder Parse(Stream script)
        {
            PatternHolder p      = new PatternHolder();
            StreamReader  stream = new StreamReader(script);

            if (!stream.ReadLine().Equals("Crazy Storm Data 1.01"))
            {
                throw new Exception("error, invalid script format");
            }

            string str1 = stream.ReadLine();

            if (str1.Contains("Types"))
            {
                for (int i = 0; i < int.Parse(str1.Split(' ')[0]); i++)
                {
                    if (i > 0)
                    {
                        p.Types += "\n";
                    }
                    p.Types += stream.ReadLine(); //bullet type definitions
                }
                p.Types = p.Types.Trim();
                str1    = stream.ReadLine();
            }
            if (str1.Contains("GlobalEvents"))
            {
                for (int i = 0; i < int.Parse(str1.Split(' ')[0]); i++)
                {
                    if (i > 0)
                    {
                        p.Types += "\n";
                    }
                    p.GlobalEvents += stream.ReadLine(); //global event definitions
                }
                str1 = stream.ReadLine();
            }
            if (str1.Contains("Sounds"))
            {
                for (int i = 0; i < int.Parse(str1.Split(' ')[0]); i++)
                {
                    if (i > 0)
                    {
                        p.Types += "\n";
                    }
                    p.Sounds += stream.ReadLine(); //sound definitions
                }
                str1 = stream.ReadLine();
            }
            if (str1.Contains("Center"))
            {
                p.Center += str1.Remove(0, 7);
            }
            p.TotalFrames = int.Parse(stream.ReadLine().Split(':')[1]);
            for (int i = 0; i < p.Layers.Length; i++)
            {
                p.Layers[i] = LayerHolder.Parse(ref stream);
            }
            stream.Close();
            p.View = new PatternView(p);
            return(p);
        }