Files
AppleHillsProduction/Assets/Scripts/Minigames/FortFight/Data/ProjectileConfig.cs

95 lines
2.7 KiB
C#
Raw Normal View History

using System;
using UnityEngine;
namespace Minigames.FortFight.Data
{
/// <summary>
/// Configuration data for a projectile type.
/// Stored centrally in FortFightSettings instead of individual ScriptableObject assets.
/// </summary>
[Serializable]
public class ProjectileConfig
{
[Header("Identity")]
[Tooltip("Type of projectile this config represents")]
public ProjectileType projectileType;
[Tooltip("Unique string identifier (auto-generated from type)")]
public string projectileId;
[Header("Prefab")]
[Tooltip("Prefab for this projectile (should have ProjectileBase component)")]
public GameObject prefab;
[Header("Ammunition System")]
[Tooltip("Cooldown in turns after use")]
public int cooldownTurns = 2;
[Header("UI")]
[Tooltip("Icon sprite for ammunition UI")]
public Sprite icon;
[Tooltip("Display name for this projectile type")]
public string displayName;
[Tooltip("Description of projectile behavior")]
[TextArea(2, 4)]
public string description;
[Header("Combat Stats")]
[Tooltip("Damage dealt on impact")]
public float damage = 20f;
[Header("Physics")]
[Tooltip("Mass for physics simulation (affects trajectory and force)")]
public float mass = 1f;
/// <summary>
/// Get the ProjectileBase component from the prefab
/// </summary>
public Projectiles.ProjectileBase GetProjectileComponent()
{
if (prefab == null) return null;
return prefab.GetComponent<Projectiles.ProjectileBase>();
}
/// <summary>
/// Get damage value from config
/// </summary>
public float GetDamage()
{
return damage;
}
/// <summary>
/// Get mass value from config
/// </summary>
public float GetMass()
{
return mass;
}
/// <summary>
/// Validate and auto-generate projectileId from type
/// </summary>
public void Validate()
{
if (string.IsNullOrEmpty(projectileId))
{
projectileId = GenerateIdFromType(projectileType);
}
if (string.IsNullOrEmpty(displayName))
{
displayName = projectileType.ToString();
}
}
private string GenerateIdFromType(ProjectileType type)
{
return type.ToString().ToLower();
}
}
}