コード例 #1
0
ファイル: MapGenerator.cs プロジェクト: akaAgar/png2wad
        /// <summary>
        /// Creates the sectors on the Doom map.
        /// </summary>
        /// <param name="map">The Doom map</param>
        private void CreateSectors(DoomMap map)
        {
            int x, y;

            map.Sectors.Clear();

            for (x = 0; x < MapSubWidth; x++)
            {
                for (y = 0; y < MapSubHeight; y++)
                {
                    if (Sectors[x, y] != -2)
                    {
                        continue;                      // Cell was already checked
                    }
                    if (SubTiles[x, y] == TileType.Wall)
                    {
                        Sectors[x, y] = -1;
                        continue;
                    }

                    Stack <Point> pixels = new Stack <Point>();
                    Point         pt     = new Point(x, y);
                    pixels.Push(pt);

                    while (pixels.Count > 0)
                    {
                        Point a = pixels.Pop();

                        if (a.X < MapSubWidth && a.X > 0 && a.Y < MapSubHeight && a.Y > 0)
                        {
                            if ((Sectors[a.X, a.Y] == -2) && (SubTiles[a.X, a.Y].Equals(SubTiles[x, y])))
                            {
                                Sectors[a.X, a.Y] = SectorsInfo.Count;
                                pixels.Push(new Point(a.X - 1, a.Y));
                                pixels.Push(new Point(a.X + 1, a.Y));
                                pixels.Push(new Point(a.X, a.Y - 1));
                                pixels.Push(new Point(a.X, a.Y + 1));
                            }
                        }
                    }

                    SectorInfo sectorInfo = new SectorInfo(SubTiles[x, y], Theme, ThemeTextures);
                    SectorsInfo.Add(sectorInfo);

                    map.Sectors.Add(
                        new Sector(
                            sectorInfo.FloorHeight, sectorInfo.CeilingHeight,
                            sectorInfo.FloorTexture, sectorInfo.CeilingTexture,
                            sectorInfo.LightLevel, sectorInfo.SectorSpecial, 0));
                }
            }
        }
コード例 #2
0
ファイル: MapGenerator.cs プロジェクト: akaAgar/png2wad
        /// <summary>
        /// Creates a sidedef from two SectorInfo
        /// </summary>
        /// <param name="sectorID">Sector this sidedef faces</param>
        /// <param name="sector">Info about the sector this sidedef faces</param>
        /// <param name="neighborSector">Info about the sector this sidedef's opposing sector</param>
        private Sidedef CreateTwoSidedSidedef(int sectorID, SectorInfo sector, SectorInfo neighborSector)
        {
            string lowerTexture, upperTexture;

            if (neighborSector.Type == TileType.Door)
            {
                upperTexture = (neighborSector.CeilingHeight < sector.CeilingHeight) ? neighborSector.WallTextureUpper : "-";
                lowerTexture = (neighborSector.FloorHeight > sector.FloorHeight) ? neighborSector.WallTextureLower : "-";
            }
            else
            {
                upperTexture = (neighborSector.CeilingHeight < sector.CeilingHeight) ? sector.WallTexture : "-";
                lowerTexture = (neighborSector.FloorHeight > sector.FloorHeight) ? sector.WallTexture : "-";
            }

            return(new Sidedef(0, 0, upperTexture, lowerTexture, "-", sectorID));
        }