Beispiel #1
0
    //Post process the grid
    public void ProcessGrid(BuildGraph builder)
    {
        //Make a list of nodes to flag as unwalkable
        //we can't immediately update them or the
        //whole thing would go horribly wrong as it
        //scanned its own output!
        var unwalkable = new List <BuildGraph.GridPosition>();

        //Run through the grid
        for (var x = 0; x < builder.width; x++)
        {
            for (var y = 0; y < builder.height; y++)
            {
                //Get a current position
                var currentPosition = new BuildGraph.GridPosition {
                    x = x, y = y
                };
                //Get all of the neighbours within 2 grid units and see if any
                //of them are not walkable
                if (builder.GetNeighbours(currentPosition, 2).Select(cell => builder.GetCell(cell)).Any(gc => !gc.walkable))
                {
                    //If so add this cell to the unwalkable
                    //list
                    unwalkable.Add(currentPosition);
                }
            }
        }
        //Update the map
        foreach (var unwalk in unwalkable)
        {
            builder.GetCell(unwalk).walkable = false;
        }
    }
Beispiel #2
0
        public int GetCoverScore(BuildGraph.GridPosition position)
        {
            var result = CountBits(lowCover[position.x, position.y]) +
                         CountBits(highCover[position.x, position.y]) * 2;

            return(24 - result);
        }
 //Post process the grid
 public void ProcessGrid(BuildGraph builder)
 {
     //Make a list of nodes to flag as unwalkable
     //we can't immediately update them or the
     //whole thing would go horribly wrong as it
     //scanned its own output!
     var unwalkable = new List<BuildGraph.GridPosition>();
     //Run through the grid
     for(var x = 0; x < builder.width; x ++)
     {
         for(var y = 0; y < builder.height; y++)
         {
             //Get a current position
             var currentPosition = new BuildGraph.GridPosition { x = x, y = y };
             //Get all of the neighbours within 2 grid units and see if any
             //of them are not walkable
             if(builder.GetNeighbours(currentPosition, 2).Select(cell=>builder.GetCell(cell)).Any(gc=>!gc.walkable))
             {
                 //If so add this cell to the unwalkable
                 //list
                 unwalkable.Add(currentPosition);
             }
         }
     }
     //Update the map
     foreach(var unwalk in unwalkable)
     {
         builder.GetCell(unwalk).walkable = false;
     }
 }
Beispiel #4
0
 public void Visualize(BuildGraph builder, BuildGraph.GridPosition position)
 {
     if (grid == null)
     {
         grid = builder.cells.Get <PinchPointGrid>();
     }
     if (grid.pinchPoints.Contains(position))
     {
         Gizmos.color = Color.blue;
         Gizmos.DrawCube(builder.GetWorldPosition(position) + Vector3.up * 2.5f, Vector3.one * Mathf.Lerp(0.5f, 1f, grid.cells[position.x, position.y] / grid.cells[grid.pinchPoints[0].x, grid.pinchPoints[0].y]));
     }
 }
Beispiel #5
0
        public int GetCoverScore(BuildGraph.GridPosition position, Vector3 fromDirection)
        {
            var result = 0;
            var dir    = Cover.GetDirection(fromDirection);

            if (((CoverDirection)lowCover[position.x, position.y] & dir) != 0)
            {
                result++;
            }
            if (((CoverDirection)highCover[position.x, position.y] & dir) != 0)
            {
                result += 2;
            }
            return(3 - result);
        }