/// <summary>
        /// Saves a shifted copy of an externally constructed cell.
        /// </summary>
        /// <param name="cell"></param>
        /// <param name="newX"></param>
        /// <param name="newY"></param>
        public void SaveExternalCell(MapCellType cell, int newX, int newY)
        {
            Point sp = new Point(newX, newY);
            Copyable <MapCellType> cc = (Copyable <MapCellType>)cell;

            savedCells[sp] = cc.Copy();
        }
示例#2
0
 public Copyable GetCopy(Copyable obj)
 {
     for (int i = objectPool.Count - 1; i >= 0; --i)
     {
         Copyable o = objectPool[i];
         if (o.CopyFrom(obj))
         {
             objectPool.RemoveAt(i);
             return(o);
         }
     }
     return(obj.Copy());
 }
        /// <summary>
        /// Constructs a shifted copy of the specified block, located
        /// at the specified (upper left) corner, and saves the result.
        /// </summary>
        /// <param name="block"></param>
        /// <param name="xmin"></param>
        /// <param name="ymin"></param>
        public void SaveExternalBlock(MapCellType[,] block, int xmin, int ymin)
        {
            int width  = block.GetLength(0);
            int height = block.GetLength(1);

            MapCellType cell;

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    Copyable <MapCellType> copyable = block[x, y];
                    cell = copyable.Copy();

                    Point sp = new Point(x + xmin, y + ymin);
                    savedCells[sp] = cell;
                }
            }
        }