Exemplo n.º 1
0
 public SpaceState(Area a, PGISlotItem it)
 {
     item  = null;
     index = -1;
     area  = a;
     item  = it;
 }
Exemplo n.º 2
0
 public SpaceState(int i, PGISlotItem it)
 {
     item  = null;
     index = i;
     area  = new Area(-1, -1, -1, -1);
     item  = it;
 }
Exemplo n.º 3
0
 bool Push(Area area, PGISlotItem item)
 {
     if (!HasSpaceAt(area))
     {
         return(false);
     }
     History.Push(new SpaceState(area, item));
     Set(area, true);
     return(true);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Sets the state for a given area in the simulation grid.
        /// Remember that <c>true</c> means 'occupied' and <c>false</c>
        /// means 'empty'.
        /// </summary>
        /// <param name="area"></param>
        /// <param name="state"></param>
        public void Set(Area area, bool state)
        {
            int startX = area.x;
            int startY = area.y;

            for (int y = startY; y < startY + area.height; y++)
            {
                for (int x = startX; x < startX + area.width; x++)
                {
                    Grid[x, y] = state;
                }
            }
        }
Exemplo n.º 5
0
        SpaceState FindFirstAvailableGridLocation(PGISlotItem item)
        {
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    Area a = new Area(x, y, item.CellWidth, item.CellHeight);
                    if (HasSpaceAt(a))
                    {
                        return(new SpaceState(a, item));
                    }
                }
            }

            return(SpaceState.Invalid);
        }
Exemplo n.º 6
0
        bool HasSpaceAt(Area area)
        {
            int startX = area.x;
            int startY = area.y;

            for (int y = startY; y < startY + area.height; y++)
            {
                for (int x = startX; x < startX + area.width; x++)
                {
                    if (Grid[x, y])
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }