From 9b548f5af67b781aebe948a4e5ed7819328af07e Mon Sep 17 00:00:00 2001 From: Aaron Carter Date: Mon, 10 Mar 2025 13:54:13 -0500 Subject: [PATCH] Fixed logic in `ArrangePlatforms` method. It leads to some errors and the "special condition" (count of 2 platforms) was unreachable. --- Assets/Scripts/Gameplay/PlatformManager.cs | 33 ++++++++++------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/Assets/Scripts/Gameplay/PlatformManager.cs b/Assets/Scripts/Gameplay/PlatformManager.cs index ffe6124a..711ec3b0 100644 --- a/Assets/Scripts/Gameplay/PlatformManager.cs +++ b/Assets/Scripts/Gameplay/PlatformManager.cs @@ -90,23 +90,19 @@ namespace Unity.Multiplayer.Samples.BossRoom SyncPlatformsClientRpc(platformIDs, arrangedPositions.ToArray()); } + List< Vector3 > ArrangePlatforms( List< Platform > activePlatforms ) { + const float startAngle = 90f ; // Start from top - private List ArrangePlatforms(List activePlatforms) - { - int platformCount = activePlatforms.Count; - - if (platformCount == 0) - { + if ( activePlatforms is not { Count: > 1, } ) { Debug.LogError($"[ArrangePlatforms] No active platforms found!"); - return new List(); + return new( ) ; } - float startAngle = 90f; // Start from top - List arrangedPositions = new List(); + int platformCount = activePlatforms.Count ; + List< Vector3 > arrangedPositions = new( ) ; // Special case: If 2 platforms, place them opposite to each other - if (platformCount == 2) - { + if ( platformCount is 2 ) { arrangedPositions.Add(centerPoint.position + new Vector3(shapeRadius, 0, 0)); // Right side arrangedPositions.Add(centerPoint.position + new Vector3(-shapeRadius, 0, 0)); // Left side } @@ -114,19 +110,20 @@ namespace Unity.Multiplayer.Samples.BossRoom { float angleStep = 360f / platformCount; - for (int i = 0; i < platformCount; i++) + for (int i = 0; i < platformCount; ++i) { float angle = startAngle + (i * angleStep); float radians = angle * Mathf.Deg2Rad; - Vector3 newPosition = new Vector3( - centerPoint.position.x + shapeRadius * Mathf.Cos(radians), - centerPoint.position.y, - centerPoint.position.z + shapeRadius * Mathf.Sin(radians) - ); + Vector3 newPosition = new ( + centerPoint.position.x + shapeRadius * Mathf.Cos(radians), + centerPoint.position.y, + centerPoint.position.z + shapeRadius * Mathf.Sin(radians) + ); arrangedPositions.Add(newPosition); - Debug.Log($"[ArrangePlatforms] Assigned position {i}: {newPosition} to Platform ID: {activePlatforms[i].PlatformID.Value}"); + Debug.Log($"[ArrangePlatforms] Assigned position {i}: {newPosition} to Platform ID: " + + $"{activePlatforms[i].PlatformID.Value}"); } }