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,52 @@
|
|||
// Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellUpgradeDraftOption.cs
|
||||
using UnityEngine;
|
||||
using TD.Core;
|
||||
using TD.Gameplay.BuilderSpells;
|
||||
|
||||
namespace TD.Gameplay.Draft
|
||||
{
|
||||
/// <summary>
|
||||
/// Draft choice — "upgrade a builder spell you already have". Replaces
|
||||
/// <see cref="BaseKind"/> with <see cref="UpgradedKind"/> in the player's
|
||||
/// <see cref="PlayerSpellLoadout"/>, in place — the upgraded spell keeps the same hotkey
|
||||
/// slot the base spell occupied.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Mirrors <see cref="BuilderSpellDraftOption"/>, but swaps rather than adds (so it doesn't
|
||||
/// consume a slot). 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 = "BuilderSpellUpgradeOption",
|
||||
menuName = "TD/Draft/Builder Spell Upgrade Option")]
|
||||
public class BuilderSpellUpgradeDraftOption : DraftOption
|
||||
{
|
||||
[Header("Payload")]
|
||||
[Tooltip("The builder spell this option upgrades from.")]
|
||||
public BuilderSpellKind BaseKind;
|
||||
|
||||
[Tooltip("The builder spell this option upgrades to.")]
|
||||
public BuilderSpellKind UpgradedKind;
|
||||
|
||||
public override bool IsValidFor(ulong clientId)
|
||||
{
|
||||
var loadout = PlayerSpellLoadout.GetForClient(clientId);
|
||||
return loadout != null && loadout.PlayerHasSpell(BaseKind);
|
||||
}
|
||||
|
||||
public override bool ServerApply(ulong clientId)
|
||||
{
|
||||
var loadout = PlayerSpellLoadout.GetForClient(clientId);
|
||||
return loadout != null && loadout.ServerUpgradeSpell(BaseKind, UpgradedKind);
|
||||
}
|
||||
|
||||
/// <summary>Inherits the upgraded spell's icon (resolved from the pool by
|
||||
/// <see cref="UpgradedKind"/>) unless this option assigns an override.</summary>
|
||||
public override Sprite ResolveIcon()
|
||||
{
|
||||
if (Icon != null) return Icon;
|
||||
var def = BuilderSpellPool.Instance != null ? BuilderSpellPool.Instance.Get(UpgradedKind) : null;
|
||||
return def != null ? def.Icon : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue