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); }