コード例 #1
0
        private void ReadSegmentDefinitions()
        {
            var s = new StreamReader(@"Content/maps.zdx");

            var currentTex = 0;
            var curDef     = -1;

            var tRect = new Rectangle();

            s.ReadLine();

            while (!s.EndOfStream)
            {
                // ReSharper disable PossibleNullReferenceException
                var t = s.ReadLine();

                string[] split;
                if (t.StartsWith("#"))
                {
                    if (t.StartsWith("#src"))
                    {
                        split = t.Split(' ');
                        if (split.Length > 1)
                        {
                            var n = Convert.ToInt32(split[1]);
                            currentTex = n - 1;
                        }
                    }
                }
                else
                {
                    curDef++;

                    var name = t;

                    t     = s.ReadLine();
                    split = t.Split(' ');

                    if (split.Length > 3)
                    {
                        tRect.X      = Convert.ToInt32(split[0]);
                        tRect.Y      = Convert.ToInt32(split[1]);
                        tRect.Width  = Convert.ToInt32(split[2]) - tRect.X;
                        tRect.Height = Convert.ToInt32(split[3]) - tRect.Y;
                    }
                    else
                    {
                        Console.WriteLine("read fail: " + name);
                    }

                    var tex = currentTex;

                    t = s.ReadLine();
                    var flags = Convert.ToInt32(t);

                    SegmentDefinitions[curDef] = new SegmentDefinition(name, tex, tRect, flags);
                }
                // ReSharper restore PossibleNullReferenceException
            }
        }
コード例 #2
0
ファイル: Map.cs プロジェクト: PawelklosPL/GameDevelopment
        public Map(string path)
        {
            GlobalFlags = new MapFlags(64);
            SegmentDefinitions = new SegmentDefinition[512];
            Segments = new MapSegment[3, 64];
            Grid = new int[XSize, YSize];
            Path = path;

            Ledges = new Ledge[16];

            for (var i = 0; i < 16; i++)
                Ledges[i] = new Ledge();

            ReadSegmentDefinitions();

            Read();
        }
コード例 #3
0
        public Map(string path)
        {
            GlobalFlags        = new MapFlags(64);
            SegmentDefinitions = new SegmentDefinition[512];
            Segments           = new MapSegment[3, 64];
            Grid = new int[XSize, YSize];
            Path = path;

            Ledges = new Ledge[16];

            for (var i = 0; i < 16; i++)
            {
                Ledges[i] = new Ledge();
            }

            ReadSegmentDefinitions();

            Read();
        }
コード例 #4
0
ファイル: Map.cs プロジェクト: PawelklosPL/GameDevelopment
        private void ReadSegmentDefinitions()
        {
            var s = new StreamReader(@"Content/maps.zdx");

            var currentTex = 0;
            var curDef = -1;

            var tRect = new Rectangle();

            s.ReadLine();

            while (!s.EndOfStream)
            {
                // ReSharper disable PossibleNullReferenceException
                var t = s.ReadLine();

                string[] split;
                if (t.StartsWith("#"))
                {
                    if (t.StartsWith("#src"))
                    {
                        split = t.Split(' ');
                        if (split.Length > 1)
                        {
                            var n = Convert.ToInt32(split[1]);
                            currentTex = n - 1;
                        }
                    }
                }
                else
                {
                    curDef++;

                    var name = t;

                    t = s.ReadLine();
                    split = t.Split(' ');

                    if (split.Length > 3)
                    {
                        tRect.X = Convert.ToInt32(split[0]);
                        tRect.Y = Convert.ToInt32(split[1]);
                        tRect.Width = Convert.ToInt32(split[2]) - tRect.X;
                        tRect.Height = Convert.ToInt32(split[3]) - tRect.Y;
                    }
                    else
                        Console.WriteLine("read fail: " + name);

                    var tex = currentTex;

                    t = s.ReadLine();
                    var flags = Convert.ToInt32(t);

                    SegmentDefinitions[curDef] = new SegmentDefinition(name, tex, tRect, flags);
                }
                // ReSharper restore PossibleNullReferenceException
            }
        }