start of draft option upgrades
This commit is contained in:
parent
e78ae0cda1
commit
db9c828e63
7 changed files with 235 additions and 2 deletions
|
|
@ -0,0 +1,42 @@
|
|||
// Assets/_Project/Scripts/Gameplay/Draft/BuilderEffectUpgradeDraftOption.cs
|
||||
using UnityEngine;
|
||||
using TD.Core;
|
||||
using TD.Gameplay.BuilderEffects;
|
||||
|
||||
namespace TD.Gameplay.Draft
|
||||
{
|
||||
/// <summary>
|
||||
/// Draft choice — "upgrade a builder effect you already have". Replaces
|
||||
/// <see cref="BaseKind"/> with <see cref="UpgradedKind"/> in the player's
|
||||
/// <see cref="BuilderUpgradeManager"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Mirrors <see cref="BuilderEffectDraftOption"/>, but swaps rather than adds. Only offered
|
||||
/// while the player currently has <see cref="BaseKind"/> granted — once taken,
|
||||
/// <see cref="BaseKind"/> is removed, which automatically makes this option (and any sibling
|
||||
/// upgrade branching off the same base) invalid for future drafts.
|
||||
/// </remarks>
|
||||
[CreateAssetMenu(fileName = "BuilderEffectUpgradeOption",
|
||||
menuName = "TD/Draft/Builder Effect Upgrade Option")]
|
||||
public class BuilderEffectUpgradeDraftOption : DraftOption
|
||||
{
|
||||
[Header("Payload")]
|
||||
[Tooltip("The builder effect this option upgrades from.")]
|
||||
public BuilderEffectKind BaseKind;
|
||||
|
||||
[Tooltip("The builder effect this option upgrades to.")]
|
||||
public BuilderEffectKind UpgradedKind;
|
||||
|
||||
public override bool IsValidFor(ulong clientId)
|
||||
{
|
||||
var upgrades = BuilderUpgradeManager.GetForClient(clientId);
|
||||
return upgrades != null && upgrades.PlayerHasEffect(BaseKind);
|
||||
}
|
||||
|
||||
public override bool ServerApply(ulong clientId)
|
||||
{
|
||||
var upgrades = BuilderUpgradeManager.GetForClient(clientId);
|
||||
return upgrades != null && upgrades.ServerUpgradeEffect(BaseKind, UpgradedKind);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue