draft options working; spells won't cast though
This commit is contained in:
parent
2429efbf6a
commit
7cf15dcaa6
37 changed files with 1340 additions and 0 deletions
|
|
@ -0,0 +1,41 @@
|
|||
// Assets/_Project/Scripts/Gameplay/Draft/BuilderSpellDraftOption.cs
|
||||
using UnityEngine;
|
||||
using TD.Core;
|
||||
using TD.Gameplay.BuilderSpells;
|
||||
|
||||
namespace TD.Gameplay.Draft
|
||||
{
|
||||
/// <summary>
|
||||
/// Draft choice — "gain a builder spell". Grants the player a key-triggered active ability,
|
||||
/// adding it to their <see cref="PlayerSpellLoadout"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Mirrors <see cref="BuilderEffectDraftOption"/>: carries the <see cref="BuilderSpellKind"/>
|
||||
/// directly rather than an asset reference, since the enum value is the stable identifier
|
||||
/// <see cref="PlayerSpellLoadout"/> and <see cref="BuilderSpellPool"/> already key off of.
|
||||
/// <see cref="IsValidFor"/> also checks slot capacity — once
|
||||
/// <see cref="PlayerSpellLoadout.MaxSpellSlots"/> is reached, no further spell options are
|
||||
/// offered.
|
||||
/// </remarks>
|
||||
[CreateAssetMenu(fileName = "BuilderSpellOption", menuName = "TD/Draft/Builder Spell Option")]
|
||||
public class BuilderSpellDraftOption : DraftOption
|
||||
{
|
||||
[Header("Payload")]
|
||||
[Tooltip("The builder spell this option grants.")]
|
||||
public BuilderSpellKind Kind;
|
||||
|
||||
public override bool IsValidFor(ulong clientId)
|
||||
{
|
||||
var loadout = PlayerSpellLoadout.GetForClient(clientId);
|
||||
if (loadout == null) return false;
|
||||
if (loadout.SlotCount >= PlayerSpellLoadout.MaxSpellSlots) return false;
|
||||
return !loadout.PlayerHasSpell(Kind);
|
||||
}
|
||||
|
||||
public override bool ServerApply(ulong clientId)
|
||||
{
|
||||
var loadout = PlayerSpellLoadout.GetForClient(clientId);
|
||||
return loadout != null && loadout.ServerGrantSpell(Kind);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue