diff --git a/Assets/Models/RadiusAbility.mat b/Assets/Models/RadiusAbility.mat index 68b3ae9..d89b114 100644 --- a/Assets/Models/RadiusAbility.mat +++ b/Assets/Models/RadiusAbility.mat @@ -12,21 +12,24 @@ Material: m_Parent: {fileID: 0} m_ModifiedSerializedProperties: 0 m_ValidKeywords: - - _EMISSION + - _ALPHAPREMULTIPLY_ON + - _SURFACE_TYPE_TRANSPARENT m_InvalidKeywords: [] - m_LightmapFlags: 1 + m_LightmapFlags: 4 m_EnableInstancingVariants: 0 m_DoubleSidedGI: 0 - m_CustomRenderQueue: -1 + m_CustomRenderQueue: 3000 stringTagMap: - RenderType: Opaque - disabledShaderPasses: [] + RenderType: Transparent + disabledShaderPasses: + - DepthOnly + - SHADOWCASTER m_LockedProperties: m_SavedProperties: serializedVersion: 3 m_TexEnvs: - _BaseMap: - m_Texture: {fileID: 0} + m_Texture: {fileID: 2800000, guid: 4454263972ac84242b5af0212232f9b6, type: 3} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - _BumpMap: @@ -50,7 +53,7 @@ Material: m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - _MainTex: - m_Texture: {fileID: 0} + m_Texture: {fileID: 2800000, guid: 4454263972ac84242b5af0212232f9b6, type: 3} m_Scale: {x: 1, y: 1} m_Offset: {x: 0, y: 0} - _MetallicGlossMap: @@ -94,8 +97,8 @@ Material: - _Cutoff: 0.5 - _DetailAlbedoMapScale: 1 - _DetailNormalMapScale: 1 - - _DstBlend: 0 - - _DstBlendAlpha: 0 + - _DstBlend: 10 + - _DstBlendAlpha: 10 - _EnvironmentReflections: 1 - _GlossMapScale: 1 - _Glossiness: 0.5 @@ -111,10 +114,10 @@ Material: - _SpecularHighlights: 1 - _SrcBlend: 1 - _SrcBlendAlpha: 1 - - _Surface: 0 + - _Surface: 1 - _UVSec: 0 - _WorkflowMode: 1 - - _ZWrite: 1 + - _ZWrite: 0 m_Colors: - _BaseColor: {r: 0.9063317, g: 0.9063317, b: 0.9063317, a: 1} - _Color: {r: 0.9063317, g: 0.9063317, b: 0.9063317, a: 1} diff --git a/Assets/Scripts/Gameplay/Platform.cs b/Assets/Scripts/Gameplay/Platform.cs index f669df6..69135f6 100644 --- a/Assets/Scripts/Gameplay/Platform.cs +++ b/Assets/Scripts/Gameplay/Platform.cs @@ -1,3 +1,4 @@ +using System.Collections; using Unity.BossRoom.Gameplay.GameplayObjects.Character; using Unity.Netcode; using UnityEngine; @@ -14,7 +15,9 @@ namespace Unity.Multiplayer.Samples.BossRoom private NetworkVariable occupierId = new NetworkVariable(0, NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission.Server); private Collider platformCollider; private Animator animator; - + private float occupationTime = 0f; + private float penaltyInterval = 3f; // Interval for penalty deduction + private Coroutine penaltyCoroutine; private void Awake() { platformCollider = GetComponent(); @@ -108,8 +111,29 @@ namespace Unity.Multiplayer.Samples.BossRoom IsOccupied = true; occupierId.Value = player.OwnerClientId; player.OnArrivalOnPlatform(PlatformID.Value); + penaltyCoroutine = StartCoroutine(HandleOccupationPenalty(player)); } + private IEnumerator HandleOccupationPenalty(ServerCharacter player) + { + occupationTime = 0f; + + while (IsOccupied) + { + occupationTime += Time.deltaTime; + if (occupationTime >= 10f) + { + yield return new WaitForSeconds(penaltyInterval); + + // Deduct points + ScoreManager.Instance.SubtractPlayerScore(player.OwnerClientId, 10); + Debug.Log($"Player {player.OwnerClientId} lost 10 points for occupying the platform too long."); + } + + yield return null; + } + } + public void Vacate(ServerCharacter player) { if (!IsServer || !IsOccupied || occupierId.Value != player.OwnerClientId) @@ -121,6 +145,11 @@ namespace Unity.Multiplayer.Samples.BossRoom IsOccupied = false; occupierId.Value = 0; player.OnLeavingPlatform(PlatformID.Value); + if (penaltyCoroutine != null) + { + StopCoroutine(penaltyCoroutine); + penaltyCoroutine = null; + } } private void OnTriggerEnter(Collider other) @@ -145,114 +174,3 @@ namespace Unity.Multiplayer.Samples.BossRoom } } } - - -//using Unity.BossRoom.Gameplay.GameplayObjects.Character; -//using Unity.Netcode; -//using UnityEngine; -//using DG.Tweening; -//using Unity.Netcode.Components; - -//namespace Unity.Multiplayer.Samples.BossRoom -//{ -// [RequireComponent(typeof(Collider))] -// public class Platform : NetworkBehaviour -// { -// public NetworkVariable PlatformID = new NetworkVariable(0); -// public bool IsOccupied { get; private set; } - -// private NetworkVariable occupierId = new NetworkVariable(0, NetworkVariableReadPermission.Everyone, NetworkVariableWritePermission.Server); -// private Collider platformCollider; -// private Animator animator; -// private void Awake() -// { -// platformCollider = GetComponent(); -// if (!platformCollider.isTrigger) -// platformCollider.isTrigger = true; - -// animator = GetComponent(); -// } -// private void Start() -// { -// Invoke(nameof(ColliderEnabler),2); -// } -// public void AssignID(int id) -// { -// if (IsServer) PlatformID.Value = id; -// } -// void ColliderEnabler() -// { -// platformCollider.enabled = true; -// } -// public void StartRotation() => transform.DOLocalRotate(Vector3.up, 120).SetSpeedBased(true).SetId(PlatformID).SetLoops(-1, LoopType.Incremental); - -// private void PauseRotation() => DOTween.Pause(PlatformID); -// private void ResumeRotation() => DOTween.Play(PlatformID); - -// public void Pause() -// { -// if (IsOwner) -// { -// animator.speed = 0f; -// PauseServerRpc(); -// } -// } - -// public void Resume() -// { -// if (IsOwner) -// { -// animator.speed = 1f; -// ResumeServerRpc(); -// } -// } - -// [ServerRpc] -// private void PauseServerRpc() => PauseClientRpc(); -// [ClientRpc] -// private void PauseClientRpc() => animator.speed = 0f; - -// [ServerRpc] -// private void ResumeServerRpc() => ResumeClientRpc(); -// [ClientRpc] -// private void ResumeClientRpc() => animator.speed = 1f; - -// public void Occupy(ServerCharacter player) -// { -// if (!IsServer || IsOccupied) return; -// Pause(); -// bool giveScore = player.PreviousPlatformId != PlatformID.Value; -// int score = (player.TargetPlatformId == PlatformID.Value) ? 10 : 20; - -// if (giveScore) ScoreManager.Instance.AddPlayerScore(player.OwnerClientId, score); - -// IsOccupied = true; -// occupierId.Value = player.OwnerClientId; -// player.OnArrivalOnPlatform(PlatformID.Value); -// } - -// public void Vacate(ServerCharacter player) -// { -// if (!IsServer || !IsOccupied || occupierId.Value != player.OwnerClientId) return; - -// Resume(); -// IsOccupied = false; -// occupierId.Value = 0; -// player.OnLeavingPlatform(PlatformID.Value); -// } - -// private void OnTriggerEnter(Collider other) -// { -// if (IsServer && other.TryGetComponent(out var player) && !IsOccupied) -// Occupy(player); -// } - -// private void OnTriggerExit(Collider other) -// { -// if (IsServer && other.TryGetComponent(out var player)) -// Vacate(player); -// } - -// public ulong GetOccupierId() => occupierId.Value; -// } -//} diff --git a/Assets/Scripts/Gameplay/ScoreManager.cs b/Assets/Scripts/Gameplay/ScoreManager.cs index c9dd26f..a357f3a 100644 --- a/Assets/Scripts/Gameplay/ScoreManager.cs +++ b/Assets/Scripts/Gameplay/ScoreManager.cs @@ -77,9 +77,8 @@ public class ScoreManager : NetworkBehaviour [ClientRpc] public void UpdatePlayerScoreClientRpc(ulong ownerClientId, int newScore) { - if (playerNames.ContainsKey(ownerClientId)) + if (playerNames.TryGetValue(ownerClientId, out var playerName)) { - string playerName = playerNames[ownerClientId]; Debug.Log($"[ScoreManager] Received score update for Player {ownerClientId} (Name: {playerName}): {newScore}"); Scoreboard.instance.UpdateScoreboard(playerName, newScore); } @@ -101,9 +100,9 @@ public class ScoreManager : NetworkBehaviour public void SubtractPlayerScore(ulong ownerClientId, int scoreToSubtract) { - if (playerScores.ContainsKey(ownerClientId)) + if (playerScores.TryGetValue(ownerClientId, out var score)) { - int newScore = Mathf.Max(0, playerScores[ownerClientId] - scoreToSubtract); + int newScore = Mathf.Max(0, score - scoreToSubtract); UpdatePlayerScore(ownerClientId, newScore); } }