Example #1
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 #2
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();
        }
Example #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();
        }
Example #4
0
        public void Read()
        {
            var file = new BinaryReader(File.Open(@"data/maps/" + 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() * 2, file.ReadSingle() * 2);
                }
                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 < XSize; x++)
            {
                for (var y = 0; y < YSize; y++)
                {
                    Grid[x, y] = file.ReadInt32();
                }
            }

            MapScript = new MapScript(this);

            for (var i = 0; i < MapScript.Lines.Length; i++)
            {
                var s = file.ReadString();
                if (s.Length > 0)
                {
                    MapScript.Lines[i] = new MapScriptLine(s);
                }
                else
                {
                    MapScript.Lines[i] = null;
                }
            }

            file.Close();

            Fog = false;
            if (MapScript.GotoTag("init"))
            {
                MapScript.IsReading = true;
            }
        }
Example #5
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 #6
0
        public void Read()
        {
            var file = new BinaryReader(File.Open(@"data/maps/" + 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() * 2, file.ReadSingle() * 2);
                }
                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 < XSize; x++)
            {
                for (var y = 0; y < YSize; y++)
                {
                    Grid[x, y] = file.ReadInt32();
                }
            }

            MapScript = new MapScript(this);

            for (var i = 0; i < MapScript.Lines.Length; i++)
            {
                var s = file.ReadString();
                if (s.Length > 0)
                    MapScript.Lines[i] = new MapScriptLine(s);
                else
                    MapScript.Lines[i] = null;
            }

            file.Close();

            Fog = false;
            if (MapScript.GotoTag("init"))
                MapScript.IsReading = true;
        }