예제 #1
0
        public static LayerHolder Parse(ref StreamReader stream)
        {
            LayerHolder l = new LayerHolder();

            string[] str1 = stream.ReadLine().Split(',');
            if (str1[0].Contains("empty"))
            {
                return(l);
            }

            l.index = str1[0].Split(':')[0].Replace("Layer", "");
            l.name  = str1[0].Split(':')[1];
            l.begin = str1[1];
            l.end   = str1[2];

            for (int i = 0; i < 5; i++)
            {
                l.numThings[i] = str1[i + 3];
            }

            int num1 = int.Parse(str1[3]);

            for (int i = 0; i < num1; i++)
            {
                l.Content.Add(LayerContent.Parse(stream.ReadLine(), LayerContent.ContentType.Batch));
            }

            num1 = int.Parse(str1[4]);
            for (int i = 0; i < num1; i++)
            {
                l.Content.Add(LayerContent.Parse(stream.ReadLine(), LayerContent.ContentType.Laser));
            }

            num1 = int.Parse(str1[5]);
            for (int i = 0; i < num1; i++)
            {
                l.Content.Add(LayerContent.Parse(stream.ReadLine(), LayerContent.ContentType.Cover));
            }

            num1 = int.Parse(str1[6]);
            for (int i = 0; i < num1; i++)
            {
                l.Content.Add(LayerContent.Parse(stream.ReadLine(), LayerContent.ContentType.Rebound));
            }

            num1 = int.Parse(str1[7]);
            for (int i = 0; i < num1; i++)
            {
                l.Content.Add(LayerContent.Parse(stream.ReadLine(), LayerContent.ContentType.Force));
            }


            l.View = new LayerView(l);
            return(l);
        }
예제 #2
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);
        }