Exemplo n.º 1
0
    void SpawnExit()
    {
        Vector3Int player1Coords = player1.GetCoords();
        Vector3Int player2Coords = player2.GetCoords();
        int        x;
        int        z;
        int        player1Distance;
        int        player2Distance;
        Square     square;

        do
        {
            x               = Random.Range(0, grid.gridWidth);
            z               = Random.Range(0, grid.gridHeight);
            square          = grid.GetSquare(x, z);
            player1Distance = Mathf.Abs(player1Coords.x - x) + Mathf.Abs(player1Coords.z - z);
            player2Distance = Mathf.Abs(player2Coords.x - x) + Mathf.Abs(player2Coords.z - z);
        }while (player1Distance < minDistance || player2Distance < minDistance || grid.HasBuilding(square));

        grid.SetSquareSurface(x, z, exitSurfacePrefab);
        exitSpawned = true;
    }