purchase buffs menu works
This commit is contained in:
parent
3737ad517c
commit
79cd331141
6 changed files with 222 additions and 7 deletions
|
|
@ -149,6 +149,14 @@ namespace TD.Gameplay
|
|||
// Right-click. Suppressed entirely during a modal mode (placement/paint
|
||||
// controllers handle right-click as cancel there) and when over HUD.
|
||||
if (isModal) return;
|
||||
|
||||
// B: toggle buff menu.
|
||||
if (keyboard != null && keyboard.bKey.wasPressedThisFrame
|
||||
&& !HUDController.IsTextInputActive)
|
||||
{
|
||||
HUDController.Instance?.ToggleBuffMenu();
|
||||
}
|
||||
|
||||
if (pointerOverHud) return;
|
||||
if (!mouse.rightButton.wasPressedThisFrame) return;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// Assets/_Project/Scripts/Gameplay/PlayerBuffManager.cs
|
||||
using System.Collections.Generic;
|
||||
using Unity.Collections;
|
||||
using Unity.Netcode;
|
||||
using UnityEngine;
|
||||
|
|
@ -27,6 +28,31 @@ namespace TD.Gameplay
|
|||
/// </remarks>
|
||||
public class PlayerBuffManager : NetworkBehaviour
|
||||
{
|
||||
// ----- Static registry (mirrors PlayerGoldManager pattern) -----------
|
||||
|
||||
private static readonly Dictionary<ulong, PlayerBuffManager> s_byClientId
|
||||
= new Dictionary<ulong, PlayerBuffManager>();
|
||||
|
||||
/// <summary>Returns the PlayerBuffManager owned by the given client, or null.</summary>
|
||||
public static PlayerBuffManager GetForClient(ulong clientId)
|
||||
{
|
||||
s_byClientId.TryGetValue(clientId, out var mgr);
|
||||
return mgr;
|
||||
}
|
||||
|
||||
/// <summary>Convenience: the local client's own buff manager.</summary>
|
||||
public static PlayerBuffManager Local
|
||||
{
|
||||
get
|
||||
{
|
||||
var nm = NetworkManager.Singleton;
|
||||
if (nm == null) return null;
|
||||
return GetForClient(nm.LocalClientId);
|
||||
}
|
||||
}
|
||||
|
||||
// ----- Inspector ------------------------------------------------------
|
||||
|
||||
[Tooltip("Purchasable buff categories shown in the buff menu. Index in this " +
|
||||
"array is the categoryIndex passed to RequestPurchaseBuffRpc.")]
|
||||
[SerializeField] private BuffCategory[] categories;
|
||||
|
|
@ -38,6 +64,19 @@ namespace TD.Gameplay
|
|||
buffs = new NetworkList<ActiveBuff>();
|
||||
}
|
||||
|
||||
// ----- NGO lifecycle ----------------------------------------------
|
||||
|
||||
public override void OnNetworkSpawn()
|
||||
{
|
||||
s_byClientId[OwnerClientId] = this;
|
||||
}
|
||||
|
||||
public override void OnNetworkDespawn()
|
||||
{
|
||||
if (s_byClientId.TryGetValue(OwnerClientId, out var registered) && registered == this)
|
||||
s_byClientId.Remove(OwnerClientId);
|
||||
}
|
||||
|
||||
// ----- Public API -------------------------------------------------
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue