コード例 #1
0
ファイル: Board.cs プロジェクト: DeJaVoo/strips-froniture
        /// <summary>
        /// allocates area on board according to the furniture's rect.
        /// </summary>
        /// <param name="furniture"></param>
        public void AllocateOnBoard(Furniture furniture)
        {
            var rect = furniture.Description;
            int xl = rect.X;
            int yl = rect.Y;
            int xh = xl + rect.Width;
            int yh = yl + rect.Height;

            for (int i = yl; i < yh; i++)
            {
                for (int j = xl; j < xh; j++)
                {
                    instance.Rooms[i, j] = CellType.Allocated;
                }
            }
        }
コード例 #2
0
ファイル: Board.cs プロジェクト: DeJaVoo/strips-froniture
 //Talk with Sheira about this implemenation.
 //My point of view - only create a new furniture than the calling env. will call the allocateOnBoard function.
 /// <summary>
 /// Adds a furniture at the given start and destination descriptions create 
 /// </summary>
 /// <param name="furStart"></param>
 /// <param name="furDest"></param>
 /// <returns>if given params are valid ->creates new furnitre at start position and returns id of the furniture, else -> -1</returns>
 public int CreateFurniture(Rectangle furStart, Rectangle furDest)
 {
     if (Instance.InBounds(furStart) && Instance.InBounds(furDest) && Instance.IsEmpty(furStart) &&
         Instance.IsNotWall(furDest) && IsDestNotOverlapps(furDest) && Instance.IsDestFurValid(furStart, furDest) &&
         Instance.WillPassDoor(furStart, furDest))
     {
         //create new furniture
         var newFurniture = new Furniture(furStart, furnitureDestination.Count + 1);
         //add furniture and its end position to the boards' map
         furnitureDestination.Add(newFurniture, furDest);
         // change the relevant cell type on the board to allocated
         AllocateOnBoard(newFurniture);
         return newFurniture.ID;
     }
     return -1;
 }
コード例 #3
0
ファイル: Board.cs プロジェクト: DeJaVoo/strips-froniture
 public bool IsEmpty(Rectangle rectangle, out Furniture furniture)
 {
     int width = rectangle.Width;
     int height = rectangle.Height;
     for (int x = rectangle.X; x < rectangle.X + width; x++)
     {
         for (int y = rectangle.Y; y < rectangle.Y + height; y++)
         {
             if (Rooms[y, x] != CellType.Empty)
             {
                 if (Rooms[y, x] == CellType.Allocated)
                 {
                     furniture = FindFurnitureInRect(new Rectangle(x, y, 1, 1))[0];
                     return false;
                 }
                 furniture = null;
                 return false;
             }
         }
     }
     furniture = null;
     return true;
 }
コード例 #4
0
ファイル: Move.cs プロジェクト: DeJaVoo/strips-froniture
 /// <summary>
 /// C'tor
 /// </summary>
 /// <param name="currentFurniture"></param>
 public Move(Furniture currentFurniture)
 {
     this.Furniture = currentFurniture;
     HowManyStepsInDirection = 1;
 }