From 51501e46d34c385428a2134e4039be508842a1fb Mon Sep 17 00:00:00 2001 From: Hazim Bin Ijaz Date: Fri, 14 Feb 2025 21:24:49 +0500 Subject: [PATCH] Update Platform.cs --- Assets/Scripts/Gameplay/Platform.cs | 31 ++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Gameplay/Platform.cs b/Assets/Scripts/Gameplay/Platform.cs index 4effc9d..cd4ff36 100644 --- a/Assets/Scripts/Gameplay/Platform.cs +++ b/Assets/Scripts/Gameplay/Platform.cs @@ -152,14 +152,39 @@ namespace Unity.Multiplayer.Samples.BossRoom return; } - int multiplier = (int)Vector3.Distance(platformA.transform.position, platformB.transform.position); + // Define distance ranges and their corresponding multipliers + float distance = Vector3.Distance(platformA.transform.position, platformB.transform.position); + Debug.Log($"the distance is: {distance}"); + float multiplier = 1.0f; + + if (distance < 5f) + { + multiplier = 1.1f; // Small distance + } + else if (distance < 10f) + { + multiplier = 1.2f; // Medium distance + } + else if (distance < 20f) + { + multiplier = 1.5f; // Large distance + } + else + { + multiplier = 2.0f; // Max multiplier cap + } + Debug.Log($"[Occupy] Distance multiplier: {multiplier} (from {platformA.PlatformID.Value} to {platformB.PlatformID.Value})"); - int score = (player.TargetPlatformId.HasValue && player.TargetPlatformId.Value == PlatformID.Value) ? 10 : 20; - score *= multiplier; + // Base score calculation + int baseScore = (player.TargetPlatformId.HasValue && player.TargetPlatformId.Value == PlatformID.Value) ? 10 : 20; + int score = Mathf.RoundToInt(baseScore * multiplier); + Debug.Log($"[Occupy] Calculated score for player {player.OwnerClientId}: {score}"); + // Add the calculated score ScoreManager.Instance.AddPlayerScore(player.OwnerClientId, score); + } Debug.Log($"[Occupy] Player {player.OwnerClientId} successfully occupied platform {PlatformID.Value}. Starting penalty coroutine.");