Пример #1
0
        public void Load()
        {
            var file = new BinaryReader(File.Open(@"data/" + Path + ".zmx", FileMode.Open));

            for (int i = 0; i < Ledges.Length; i++)
            {
                Ledges[i]            = new Ledge();
                Ledges[i].TotalNodes = file.ReadInt32();

                for (int n = 0; n < Ledges[i].TotalNodes; n++)
                {
                    Ledges[i].Nodes[n] = new Vector2(file.ReadSingle(), file.ReadSingle());
                }

                Ledges[i].Flags = file.ReadInt32();
            }

            var keyCount = file.ReadInt32();

            for (int i = 0; i < keyCount; i++)
            {
                var key          = file.ReadInt32();
                var segmentCount = file.ReadInt32();

                if (!MapSegments.ContainsKey(key))
                {
                    MapSegments[key] = new List <MapSegment>();
                }

                for (int index = 0; index < segmentCount; index++)
                {
                    var mapSegment = new MapSegment();
                    mapSegment.Index    = index;
                    mapSegment.Layer    = key;
                    mapSegment.Location = new Vector2(file.ReadSingle(), file.ReadSingle());
                    MapSegments[key].Add(mapSegment);
                }
            }

            for (int x = 0; x < 20; x++)
            {
                for (int y = 0; y < 20; y++)
                {
                    Grid[x, y] = file.ReadInt32();
                }
            }

            file.Close();

            Console.WriteLine("Read");
        }
Пример #2
0
        public Map()
        {
            MapSegments        = new Dictionary <int, List <MapSegment> >();
            SegmentDefinitions = new List <SegmentDefinition>();
            Grid   = new int [GridSizeX, GridSizeY];
            Ledges = new Ledge[16];

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

            ReadSegmentDefinitions();

            var Content = GameServices.GetService <ContentManager>();

            nullTexture = Content.Load <Texture2D>(@"gfx/1x1");
        }