UnityTowerDefense/Assets/_Project/Scripts/Towers/TowerDefinition.cs
Matt F a63cce53e2 Adding tons of new functionality
Decals, ghost textures, placement functionality, builder stub ins, a new camera system,  and more.
2026-05-04 00:01:30 -07:00

96 lines
No EOL
4.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
namespace TD.Towers
{
/// <summary>
/// Data definition for a single tower type. One asset per tower type; shared across all
/// instances of that tower in a match. Consumed by tower placement, construction, and
/// (eventually) combat systems.
/// </summary>
/// <remarks>
/// TowerDefinitions are authored as ScriptableObject assets and referenced by
/// <see cref="RaceDefinition"/> (tower roster) and <see cref="TowerInstance"/> (which
/// definition this placed tower corresponds to). Clients load the full asset locally
/// from the project's ScriptableObject pool; only the asset reference (not the full data)
/// is replicated over the network.
///
/// Fields marked STUBBED are defined here to lock in the data shape but are not yet
/// consumed by any runtime system. They will be wired in during the sessions noted.
/// </remarks>
[CreateAssetMenu(fileName = "TowerDefinition", menuName = "TD/Tower Definition", order = 2)]
public class TowerDefinition : ScriptableObject
{
// -------------------------------------------------------------------
// Identity
// -------------------------------------------------------------------
[Header("Identity")]
[Tooltip("Human-readable name shown in the HUD tower grid and context panel.")]
public string DisplayName;
[Tooltip("Short description shown in the HUD context panel when this tower is selected.")]
[TextArea(2, 4)]
public string Description;
// -------------------------------------------------------------------
// Placement
// -------------------------------------------------------------------
[Header("Placement")]
[Tooltip("Footprint size in tiles. Default 2×2. The anchor tile is the south-west corner " +
"of the footprint (minimum x, minimum y). Every tile in the footprint must be " +
"Buildable and owned by the placing player for placement to succeed.")]
public Vector2Int FootprintSize = new Vector2Int(2, 2);
[Tooltip("Gold cost to place this tower. Deducted from the placing player's pool on " +
"successful server-side placement validation.")]
public int GoldCost;
// -------------------------------------------------------------------
// Construction
// -------------------------------------------------------------------
[Header("Construction")]
[Tooltip("STUBBED — not consumed until Path D (Builder system). " +
"Time in seconds from construction start to tower becoming active. " +
"A Builder must be within build range for construction to proceed. " +
"Set to 0 for instant construction (placeholder behaviour during Path B testing).")]
public float BuildTime = 0f;
// -------------------------------------------------------------------
// Visuals
// -------------------------------------------------------------------
[Header("Visuals")]
[Tooltip("Prefab instantiated in the world when this tower is placed. Must have a " +
"TowerInstance component at its root. During Path B this is a colored cube; " +
"replace with a real mesh when art is available.")]
public GameObject TowerPrefab;
// -------------------------------------------------------------------
// Combat — STUBBED
// -------------------------------------------------------------------
[Header("Combat (Stubbed — not consumed until combat system is implemented)")]
[Tooltip("STUBBED. Damage dealt per hit to a single target.")]
public float Damage;
[Tooltip("STUBBED. Attack range in world units. Enemies within this radius are targetable.")]
public float Range;
[Tooltip("STUBBED. Attacks per second.")]
public float FireRate;
[Tooltip("STUBBED. Radius of splash damage around the impact point. 0 = single target.")]
public float SplashRadius;
[Tooltip("STUBBED. Fraction by which enemy movement speed is multiplied on hit. " +
"1.0 = no slow. 0.5 = 50% slow.")]
[Range(0f, 1f)]
public float SlowFactor = 1f;
[Tooltip("STUBBED. Projectile prefab fired at targets. Null = hitscan (instant hit, no " +
"projectile travel).")]
public GameObject ProjectilePrefab;
}
}