Exemplo n.º 1
0
        internal override void ParseSection(System.IO.FileStream file)
        {
            base.ParseSection(file);

            List<ZoneDescriptor> zoneDescriptors = new List<ZoneDescriptor>();

            using (MemoryStream ms = new MemoryStream(RawData))
            {
                while (ms.Position < ms.Length)
                {
                    var zone = new ZoneDescriptor(ms, this);
                    zoneDescriptors.Add(zone);
                }
            }

            for (int i = 0; i < 128; i++)
            {
                for (int j = 0; j < 128; j++)
                {
                    Zone[i, 127 - j] = zoneDescriptors[i * 128 + j];
                }
            }

            //
            // For each zone we want to know where its origin tile is to make rendering
            // multi-tile buildings easier.  Iterate over all zone tiles finding "Top-Left"
            // tiles and then fill in all other tiles' origins that are part of that zone.
            //
            for (int i = 0; i < 128; i++)
            {
                for (int j = 0; j < 128; j++)
                {
                    if (Zone[i, j].IsTopLeft() &&
                        !Zone[i, j].IsBottomRight())
                    {
                        int originX = i;
                        int originY = j;

                        int bottomLeftX = -1;
                        int bottomRightY = -1;

                        // Find the top-right
                        for (bottomLeftX = i; bottomLeftX < 128; bottomLeftX++)
                        {
                            if (Zone[bottomLeftX, j].IsBottomLeft())
                            {
                                break;
                            }
                        }

                        // Find the bottom-right
                        for (bottomRightY = j; bottomRightY < 128; bottomRightY++)
                        {
                            if (Zone[bottomLeftX, bottomRightY].IsBottomRight())
                            {
                                break;
                            }
                        }

                        // Now fill in all tiles between
                        for (int i2 = i; i2 <= bottomLeftX; i2++)
                        {
                            for (int j2 = j; j2 <= bottomRightY; j2++)
                            {
                                Zone[i2, j2].IsMultiTile = true;
                                Zone[i2, j2].OriginX = originX;
                                Zone[i2, j2].OriginY = originY;
                                Zone[i2, j2].LengthX = bottomLeftX - originX + 1;
                                Zone[i2, j2].LengthY = bottomRightY - originY + 1;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 internal ZoneSection()
     : base("XZON")
 {
     Zone = new ZoneDescriptor[128, 128];
 }