Example #1
0
 public static RoadStructureHelper CheckIf4WaysFits(int neighboursStatus, RoadStructureHelper roadToReturn, StructureBaseSO structureData)
 {
     if (neighboursStatus == ((int)Direction.Up | (int)Direction.Right | (int)Direction.Down | (int)Direction.Left))
     {
         roadToReturn = new RoadStructureHelper(((RoadStructureSO)structureData).fourWayPrefab, RotationValue.R0);
     }
     return(roadToReturn);
 }
Example #2
0
 public static RoadStructureHelper CheckIfStraightRoadFits(int neighboursStatus, RoadStructureHelper roadToReturn, StructureBaseSO structureData)
 {
     if (neighboursStatus == ((int)Direction.Up | (int)Direction.Down) || neighboursStatus == (int)Direction.Up || neighboursStatus == (int)Direction.Down)
     {
         roadToReturn = new RoadStructureHelper(((RoadStructureSO)structureData).prefab, RotationValue.R90);
     }
     else if (neighboursStatus == ((int)Direction.Right | (int)Direction.Left) || neighboursStatus == (int)Direction.Right ||
              neighboursStatus == (int)Direction.Left || neighboursStatus == 0)
     {
         roadToReturn = new RoadStructureHelper(((RoadStructureSO)structureData).prefab, RotationValue.R0);
     }
     return(roadToReturn);
 }
    public static RoadStructureHelper GetCorrectRoadPrefab(Vector3 gridPosition, StructureBaseSO structureDat, Dictionary<Vector3Int, GameObject> structuresToBeModified, GridStructure grid)
    {
        var neighborStatus = RoadManager.GetRoadNeighborStatus(gridPosition, grid, structuresToBeModified);
        RoadStructureHelper roadToReturn = null;
        roadToReturn = RoadManager.CheckIfStraightRoadFits(neighborStatus, roadToReturn, structureDat);
        if (roadToReturn != null)
            return roadToReturn;
        roadToReturn = RoadManager.CheckIfCornerRoadFits(neighborStatus, roadToReturn, structureDat);
        if (roadToReturn != null)
            return roadToReturn;
        roadToReturn = RoadManager.CheckIfThreewayRoadFits(neighborStatus, roadToReturn, structureDat);
        if (roadToReturn != null)
            return roadToReturn;
        roadToReturn = RoadManager.CheckIfFourwayRoadFits(neighborStatus, roadToReturn, structureDat);
        if (roadToReturn != null)
            return roadToReturn;

        return roadToReturn;
    }
Example #4
0
 public static RoadStructureHelper CheckIfCornerFits(int neighboursStatus, RoadStructureHelper roadToReturn, StructureBaseSO structureData)
 {
     if (neighboursStatus == ((int)Direction.Up | (int)Direction.Right))
     {
         roadToReturn = new RoadStructureHelper(((RoadStructureSO)structureData).cornerPrefab, RotationValue.R0);
     }
     else if (neighboursStatus == ((int)Direction.Down | (int)Direction.Right))
     {
         roadToReturn = new RoadStructureHelper(((RoadStructureSO)structureData).cornerPrefab, RotationValue.R90);
     }
     else if (neighboursStatus == ((int)Direction.Down | (int)Direction.Left))
     {
         roadToReturn = new RoadStructureHelper(((RoadStructureSO)structureData).cornerPrefab, RotationValue.R180);
     }
     else if (neighboursStatus == ((int)Direction.Up | (int)Direction.Left))
     {
         roadToReturn = new RoadStructureHelper(((RoadStructureSO)structureData).cornerPrefab, RotationValue.R270);
     }
     return(roadToReturn);
 }
    public static RoadStructureHelper CheckIfThreewayRoadFits(int neighborStatus, RoadStructureHelper roadToReturn, StructureBaseSO structureData)
    {
        if (neighborStatus == ((int)Direction.Up | (int)Direction.Right | (int)Direction.Down))
        {
            roadToReturn = new RoadStructureHelper(((RoadStructureSO)structureData).threeWayPrefab, RotationValue.R0);
        }
        else if (neighborStatus == ((int)Direction.Left | (int)Direction.Up | (int)Direction.Right))
        {
            roadToReturn = new RoadStructureHelper(((RoadStructureSO)structureData).threeWayPrefab, RotationValue.R270);
        }
        else if (neighborStatus == ((int)Direction.Down | (int)Direction.Left | (int)Direction.Up))
        {
            roadToReturn = new RoadStructureHelper(((RoadStructureSO)structureData).threeWayPrefab, RotationValue.R180);
        }
        else if (neighborStatus == ((int)Direction.Right | (int)Direction.Down | (int)Direction.Left))
        {
            roadToReturn = new RoadStructureHelper(((RoadStructureSO)structureData).threeWayPrefab, RotationValue.R90);
        }

        return roadToReturn;
    }
Example #6
0
    public static RoadStructureHelper GetCorrectRoadPrefab(Vector3 gridPosition, StructureBaseSO structureData, Dictionary <Vector3Int, GameObject> structuresToBeModified, GridStructure grid)
    {
        var neighboursStatus             = RoadManager.GetRoadNeighboursStatus(gridPosition, grid, structuresToBeModified);
        RoadStructureHelper roadToReturn = null;

        roadToReturn = RoadManager.CheckIfStraightRoadFits(neighboursStatus, roadToReturn, structureData);
        if (roadToReturn != null)
        {
            return(roadToReturn);
        }
        roadToReturn = RoadManager.CheckIfCornerFits(neighboursStatus, roadToReturn, structureData);
        if (roadToReturn != null)
        {
            return(roadToReturn);
        }
        roadToReturn = RoadManager.CheckIf3WayFits(neighboursStatus, roadToReturn, structureData);
        if (roadToReturn != null)
        {
            return(roadToReturn);
        }
        roadToReturn = RoadManager.CheckIf4WaysFits(neighboursStatus, roadToReturn, structureData);
        return(roadToReturn);
    }
 private void PlaceNewRoadAt(RoadStructureHelper roadStructure, Vector3 gridPosition, Vector3Int gridPositionInt)
 {
     _structuresToBeModified.Add(gridPositionInt, _placementManager.CreateGhostStructure(gridPosition, roadStructure.RoadPrefab, roadStructure.RoadPrefabRotation));
 }