예제 #1
0
 public void AddObject(string oid, int x, int y, float probability, string[] variations)
 {
     if (x < this.Width && x >= 0 && y < this.Height && y >= 0)
     {
         var obj = new BlockObject {
             ID = oid, X = x, Y = y, Probability = probability, Variations = variations
         };
         this.objects.Add(obj);
     }
 }
예제 #2
0
 public void PlaceBlock(ConstructionBlock block, int x, int y)
 {
     for (int j = 0; j < block.Height; j++)
     {
         for (int i = 0; i < block.Width; i++)
         {
             //if (i + x >= 0 && i + x < maxX && j + y >= 0 && j + y < maxY && this.IsUsed [i + x, j + y] == false) {
             if (this.IsValid(i + x, j + y) && this.IsUsed [i + x, j + y] == false)
             {
                 this.Data [i + x, j + y]   = block.GetTile(i, j);
                 this.IsUsed [i + x, j + y] = true;
                 this.UsedArea++;
             }
         }
     }
     foreach (var exit in block.Exits)
     {
         var i = exit.X + x;
         var j = exit.Y + y;
         if (this.IsOpenExit(i, j, exit.Direction))
         {
             var nexit = new BlockExit {
                 X = i, Y = j, Direction = exit.Direction, CanBeClosed = exit.CanBeClosed
             };
             this.exits.Add(nexit);
         }
     }
     foreach (var obj in block.Objects)
     {
         var nobj = new BlockObject();
         nobj.ID          = obj.ID;
         nobj.Probability = obj.Probability;
         nobj.X           = obj.X + x;
         nobj.Y           = obj.Y + y;
         this.Objects.Add(nobj);
     }
     if (block.StartPoint != null)
     {
         this.StartCell.X = block.StartPoint.X + x;
         this.StartCell.Y = block.StartPoint.Y + y;
     }
     if (block.EndPoint != null)
     {
         this.EndCell.X = block.EndPoint.X + x;
         this.EndCell.Y = block.EndPoint.Y + y;
     }
     this.blockCount++;
     minX = (x < minX) ? (x > 0) ? x : 0 : minX;
     minY = (y < minY) ? (y > 0) ? y : 0 : minY;
     maxX = (x + block.Width > maxX) ? x + block.Width : maxX;
     maxY = (y + block.Height > maxY) ? y + block.Height : maxY;
 }