Ejemplo n.º 1
0
    //Add adjacent relations between Square one and two
    //Used in the HallwayMeshGenerator to decide wheter to draw walls or not
    public void AddAdjacentRelation(Square one, Square two)
    {
        GridPosition onePos = grid [one.GridX, one.GridY];
        GridPosition twoPos = grid [two.GridX, two.GridY];

        onePos.AddAdjacent(AdjacentDirection(one, two), twoPos);
        twoPos.AddAdjacent(AdjacentDirection(two, one), onePos);
    }
Ejemplo n.º 2
0
 //Actual adjascents, meaning adjascent positions on the same path, were computed before when creating the paths in the astar algorithm
 //Here the positions of _all_ paths are compared
 private void SearchForIndirectAdjacents(GridPosition gridPosition)
 {
     Vector2[] directions = new Vector2[] { Vector2.up, Vector2.right, Vector2.down, Vector2.left };
     int[]     indices    = new int[] { 0, 1, 1, 0, 0, -1, -1, 0 };
     for (int i = 0; i < 4; i++)
     {
         GridPosition adjacent = grid.Grid [gridPosition.i + indices [i * 2], gridPosition.j + indices [i * 2 + 1]];
         if (adjacent.IsPartOfPath && gridPosition.AdjacentPositions[directions[i]] == null && Vector2.Distance(gridPosition.Position, adjacent.Position) <= DoorDefinition.GlobalSize * 2f)
         {
             gridPosition.AddAdjacent(directions [i], adjacent);
         }
     }
 }
Ejemplo n.º 3
0
    private void CalculateBounds()
    {
        //HandleInsideEdge(adjacent[gridPosition.Direction]);
        Vector2 oppositeDir = gridPosition.Direction * -1;

        //Only modify padding in the direction of the hallway segment
        //The other directions will have their default value (doorSize)
        size[gridPosition.Direction] = GetPaddingForDirection(gridPosition.Direction);
        size[oppositeDir]            = GetPaddingForDirection(oppositeDir);
        //Add an epmty gridPosition in the opposite direction, if the segment is a door
        //This will stop triangles to be created at the beginning of a hallway
        if (gridPosition.IsDoor)
        {
            gridPosition.AddAdjacent(oppositeDir, new GridPosition(0, 0));
        }
    }