Example #1
0
 void add(Obstacle o)
 {
     if(willBeValid(o)) {
         blocks.Add(o);
         for(int i = o.Y; i < o.Height + o.Y; i++) {
             for(int j = o.X; j < o.Width + o.X; j++) {
                 usage[j, i] = o;
             }
         }
     }
 }
Example #2
0
 bool willBeValid(Obstacle o)
 {
     for(int i = o.Y; i < o.Height + o.Y; i++) {
         for(int j = o.X; j < o.Width + o.X; j++) {
             if(i > usage.GetUpperBound(1) || j > usage.GetUpperBound(0))
                 return false;
             if(usage[j, i] != null)
                 return false;
         }
     }
     return true;
 }