public GameObject CreateHub(StairProfile stairProfile) { GameObject hub = new GameObject(); if (stairProfile.Direction != DirectionHub.Null) { GameObject firstStair = Instantiate(stairProfile.Stair, hub.transform); GameObject secondStair = Instantiate(stairProfile.Stair, hub.transform); if (stairProfile.Direction == DirectionHub.Inside) { secondStair.transform.Rotate(0, 180, 0); secondStair.transform.position = new Vector3(0, 0, GetWidth(stairProfile.WidthStair)); } else { firstStair.transform.Rotate(0, 180, 0); firstStair.transform.position = new Vector3(GetLength(stairProfile.LengthStair), 0, GetWidth(stairProfile.WidthStair)); secondStair.transform.position = new Vector3(-GetLength(stairProfile.LengthStair), 0, 0); } } else { GameObject soloStair = Instantiate(stairProfile.Stair, hub.transform); soloStair.transform.position = new Vector3(-GetLength(stairProfile.LengthStair) / 2f, 0, 0); } return(hub); }
public List <ObstructedLocation> LoadStairs(List <ObstructedLocation> obstructedLocations, float wealthLevel) { WidthStair choosenWidth = ChooseWidthStair(wealthLevel); // EdgeCase bool isLongCanBeIntegrated = !((obstructedLocations.Contains(ObstructedLocation.Short) && obstructedLocations.Contains(ObstructedLocation.Long)) || obstructedLocations.Contains(ObstructedLocation.Corner)); LengthStair choosenLength = ChooseLengthStair(wealthLevel, isLongCanBeIntegrated); WealthStair choosenWealth = ChooseWealthStair(wealthLevel); var idLength = GetIdLength(choosenLength); var idWealth = (choosenWealth == WealthStair.Poor) ? 0 : 1; var choosenObstructedStair = lengthStairs[idLength]; var choosenStair = (choosenWidth == WidthStair.Simple) ? choosenObstructedStair.simpleStairs[idWealth] : choosenObstructedStair.doubleStairs[idWealth]; var choosenObstructedPattern = ChooseObstructedPattern(obstructedLocations, choosenObstructedStair, wealthLevel); bool isHub = false; if (!((choosenLength == LengthStair.Long && obstructedLocations.Contains(ObstructedLocation.Short)) || choosenObstructedPattern.positionStair == PositionStair.Corner)) { isHub = ChooseIfHub(wealthLevel); } DirectionHub choosenDirectionHub = ChooseDirectionHub(isHub, wealthLevel); var profile = new StairProfile() { Stair = choosenStair, ObstructedPattern = choosenObstructedPattern, LengthStair = choosenLength, WidthStair = choosenWidth, Direction = choosenDirectionHub, }; LoadStair(profile); obstructedLocations = obstructedLocations.Union(choosenObstructedPattern.obstructedLocations).ToList(); return(obstructedLocations); }
public ParametersStairProfile GetParameters(StairProfile stairProfile) { var xAxis = 0f; var zAxis = 0f; var deltaHubsLength = 0f; var rotation = 0; switch (stairProfile.ObstructedPattern.positionStair) { case PositionStair.Long: xAxis = 0f; zAxis = 63f; deltaHubsLength = 46.5f; rotation = 0; break; case PositionStair.Short: xAxis = 93f; zAxis = 0f; deltaHubsLength = 31.5f; rotation = 90; break; default: // Position.Corner deltaHubsLength = GetLength(stairProfile.LengthStair) / 2; xAxis = 93f; zAxis = 63f; break; } var parameters = new ParametersStairProfile { XAxis = xAxis, ZAxis = zAxis, DeltaHubsLength = deltaHubsLength, Rotation = rotation }; return(parameters); }
public void LoadStair(StairProfile stairProfile) { GameObject hub = CreateHub(stairProfile); ParametersStairProfile parameters = GetParameters(stairProfile); if (stairProfile.ObstructedPattern.numberStairs == 1 && stairProfile.ObstructedPattern.positionStair == PositionStair.Corner) { DuplicateAndPut(hub, new Vector3(-parameters.XAxis + parameters.DeltaHubsLength, 0, -parameters.ZAxis), parameters.Rotation); DuplicateAndPut(hub, new Vector3(parameters.XAxis - parameters.DeltaHubsLength, 0, parameters.ZAxis), parameters.Rotation + 180); DuplicateAndPut(hub, new Vector3(parameters.XAxis - parameters.DeltaHubsLength, 0, -parameters.ZAxis + GetWidth(stairProfile.WidthStair)), parameters.Rotation + 180); DuplicateAndPut(hub, new Vector3(-parameters.XAxis + parameters.DeltaHubsLength, 0, parameters.ZAxis - GetWidth(stairProfile.WidthStair)), parameters.Rotation); } else if (stairProfile.ObstructedPattern.numberStairs == 1 && stairProfile.ObstructedPattern.positionStair != PositionStair.Corner) { DuplicateAndPut(hub, new Vector3(-parameters.XAxis, 0, -parameters.ZAxis), parameters.Rotation); DuplicateAndPut(hub, new Vector3(parameters.XAxis, 0, parameters.ZAxis), parameters.Rotation + 180); } else { var xDeltaToPut = (stairProfile.ObstructedPattern.positionStair == PositionStair.Long)? parameters.DeltaHubsLength: 0f; var yDeltaToPut = (stairProfile.ObstructedPattern.positionStair == PositionStair.Long)? 0f : parameters.DeltaHubsLength; DuplicateAndPut(hub, new Vector3(-parameters.XAxis + xDeltaToPut, 0, -parameters.ZAxis + yDeltaToPut), parameters.Rotation); DuplicateAndPut(hub, new Vector3(parameters.XAxis + xDeltaToPut, 0, parameters.ZAxis + yDeltaToPut), parameters.Rotation + 180); DuplicateAndPut(hub, new Vector3(-parameters.XAxis - xDeltaToPut, 0, -parameters.ZAxis - yDeltaToPut), parameters.Rotation); DuplicateAndPut(hub, new Vector3(parameters.XAxis - xDeltaToPut, 0, parameters.ZAxis - yDeltaToPut), parameters.Rotation + 180); if (stairProfile.ObstructedPattern.numberStairs == 3) { DuplicateAndPut(hub, new Vector3(-parameters.XAxis, 0, -parameters.ZAxis), parameters.Rotation); DuplicateAndPut(hub, new Vector3(parameters.XAxis, 0, parameters.ZAxis), parameters.Rotation + 180); } } Destroy(hub); }