Esempio n. 1
0
 public void WriteSelfTo(GenericBuffer <bool> buffer)
 {
     for (int x = 0; x < MapData.Width; x++)
     {
         for (int y = 0; y < MapData.Height; y++)
         {
             Position pos = new Position(x, y);
             bool     dat = MapData.Get(pos);
             if (dat == true)
             {
                 buffer.Set(Position + pos, true);
             }
         }
     }
 }
Esempio n. 2
0
        public virtual bool GenerateSelf(List <MapData> mapDatas, GenericBuffer <bool> buffer, int depth, Random random)
        {
            try {
                for (int x = 0; x < MapData.Width; x++)
                {
                    for (int y = 0; y < MapData.Height; y++)
                    {
                        if (0 < x && x < Math.Max(MapData.Width - 1, 0) &&
                            0 < y && y < Math.Max(MapData.Height - 1, 0))
                        {
                            Position pos  = new Position(x, y);
                            bool     dat1 = MapData.Get(pos);
                            bool     dat2 = buffer.Get(Position + pos);
                            if (dat1 == true && dat2 == true)
                            {
                                return(false);
                            }
                        }
                    }
                }

                for (int x = 0; x < MapData.Width; x++)
                {
                    for (int y = 0; y < MapData.Height; y++)
                    {
                        Position pos = new Position(x, y);
                        bool     dat = MapData.Get(pos);
                        if (dat == true)
                        {
                            buffer.Set(Position + pos, true);
                        }
                    }
                }

                return(true);
            }

            catch (GenericBufferPositionOutOfRangeException) {            // out of ranged
                return(false);
            }
        }