Example #1
0
        public Map()
        {
            Definitions = new SegmentDefinition[512];
            Segments = new MapSegment[3, 64];
            Grid = new int[20, 20];
            Ledges = EnumerableHelper.Array<Ledge>(16);

            ReadDefinitions();
        }
Example #2
0
        public Map()
        {
            Definitions = new SegmentDefinition[512];
            Segments    = new MapSegment[3, 64];
            Grid        = new int[20, 20];
            Ledges      = EnumerableHelper.Array <Ledge>(16);

            ReadDefinitions();
        }
Example #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="layer"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public int AddSegment(int layer, int index)
        {
            for (int i = 0; i < 64; i++) {
                if (mapSegments[layer, i] == null) {
                    mapSegments[layer, i] = new MapSegment();
                    mapSegments[layer, i].Index = index;
                    return i;
                }
            }

            return -1;
        }
Example #4
0
        public void Read()
        {
            var file = new BinaryReader(File.Open(@"data/" + Path + ".zmx", FileMode.Open));

            for (var i = 0; i < Ledges.Length; i++)
            {
                Ledges[i] = new Ledge {
                    TotalNodes = file.ReadInt32()
                };
                for (var n = 0; n < Ledges[i].TotalNodes; n++)
                {
                    Ledges[i].Nodes[n] = new Vector2(file.ReadSingle(), file.ReadSingle());
                }
                Ledges[i].Flags = file.ReadInt32();
            }

            for (var l = 0; l < 3; l++)
            {
                for (var i = 0; i < 64; i++)
                {
                    var t = file.ReadInt32();

                    if (t == -1)
                    {
                        Segments[l, i] = null;
                    }
                    else
                    {
                        Segments[l, i] = new MapSegment
                        {
                            Index    = t,
                            Location = new Vector2(file.ReadSingle(), file.ReadSingle())
                        };
                    }
                }
            }

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

            for (var i = 0; i < Scripts.Length; i++)
            {
                Scripts[i] = file.ReadString();
            }

            file.Close();
        }
Example #5
0
 public int AddSeg(int layer, int index)
 {
     // 64 is the max size of mapSegment array. 3 Layers with 64 segments per map
     for (int i = 0; i < 64; i++)
     {
         if (mapSegment[layer, i] == null)
         {
             mapSegment[layer, i] = new MapSegment();
             mapSegment[layer, i].Index = index;
             return i;
         }
     }
     return -1;
 }
Example #6
0
        public int AddSeg(int layer, int index)
        {
            for (var i = 0; i < 64; i++)
            {
                if (Segments[layer, i] == null)
                {
                    Segments[layer, i] = new MapSegment { Index = index };

                    return i;
                }
            }

            return -1;
        }
Example #7
0
        public int AddSeg(int layer, int index)
        {
            for (var i = 0; i < 64; i++)
            {
                if (Segments[layer, i] == null)
                {
                    Segments[layer, i] = new MapSegment {
                        Index = index
                    };

                    return(i);
                }
            }

            return(-1);
        }
Example #8
0
        public int AddSegment(int layer, int index)
        {
            for (var i = 0; i <= MaxSegmentsDimension1Index; i++)
            {
                if (_segments[layer, i] != null)
                {
                    continue;
                }

                _segments[layer, i] = new MapSegment {
                    Index = index
                };
                return(i);
            }

            return(-1);
        }
Example #9
0
        public Map()
        {
            SegmentDefinitions = new SegmentDefinition[512];
            Segments = new MapSegment[3, 64];
            Grid = new int[20, 20];
            Scripts = new String[128];
            Path = "map";

            Ledges = new Ledge[16];

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

            ReadSegmentDefinitions();

            for (var i = 0; i < Scripts.Length; i++)
                Scripts[i] = "";
        }
Example #10
0
        public Map()
        {
            SegmentDefinitions = new SegmentDefinition[512];
            Segments           = new MapSegment[3, 64];
            Grid    = new int[20, 20];
            Scripts = new String[128];
            Path    = "map";

            Ledges = new Ledge[16];

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

            ReadSegmentDefinitions();

            for (var i = 0; i < Scripts.Length; i++)
            {
                Scripts[i] = "";
            }
        }
Example #11
0
        public int AddSegment(int layer, int index)
        {
            for (var i = 0; i <= MaxSegmentsDimension1Index; i++)
            {
                if (_segments[layer, i] != null) continue;

                _segments[layer, i] = new MapSegment { Index = index };
                return i;
            }

            return -1;
        }
Example #12
0
        public void Read()
        {
            BinaryReader file = new BinaryReader(File.Open(@"Content/data/maps/" + path + ".dat", FileMode.Open));

            // read ledge information first
            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].isHardLedge = file.ReadInt32();
            }
            // read layer / segment information
            for (int l = 0; l < 3; l++)
            {
                for (int i = 0; i < 64; i++)
                {
                    int t = file.ReadInt32();
                    if (t == -1)
                        mapSegment[l, i] = null;
                    else
                    {
                        mapSegment[l, i] = new MapSegment();
                        mapSegment[l, i].Index = t;
                        mapSegment[l, i].location = new Vector2(
                        file.ReadSingle(),
                        file.ReadSingle());
                    }
                }
            }
            // read collision grid information
            for (int x = 0; x < 20; x++)
            {
                for (int y = 0; y < 20; y++)
                {
                    colisionGrid[x, y] = file.ReadInt32();
                }
            }
            // read script information
            for (int i = 0; i < Scripts.Length; i++)
                Scripts[i] = file.ReadString();

            file.Close();
        }
Example #13
0
        public void Read()
        {
            var file = new BinaryReader(File.Open(@"data/" + Path + ".zmx", FileMode.Open));

            for (var i = 0; i < Ledges.Length; i++)
            {
                Ledges[i] = new Ledge { TotalNodes = file.ReadInt32() };
                for (var n = 0; n < Ledges[i].TotalNodes; n++)
                {
                    Ledges[i].Nodes[n] = new Vector2(file.ReadSingle(), file.ReadSingle());
                }
                Ledges[i].Flags = file.ReadInt32();
            }

            for (var l = 0; l < 3; l++)
            {
                for (var i = 0; i < 64; i++)
                {
                    var t = file.ReadInt32();

                    if (t == -1)
                        Segments[l, i] = null;
                    else
                    {
                        Segments[l, i] = new MapSegment
                        {
                            Index = t,
                            Location = new Vector2(file.ReadSingle(), file.ReadSingle())
                        };
                    }
                }
            }

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

            for (var i = 0; i < Scripts.Length; i++)
                Scripts[i] = file.ReadString();

            file.Close();
        }