139 lines
5.4 KiB
C#
139 lines
5.4 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace GazeLab.Data
|
|
{
|
|
public enum FiringPattern
|
|
{
|
|
SimultaneousVolley,
|
|
AlternatingSequential,
|
|
BurstRipple,
|
|
SpreadCone
|
|
}
|
|
|
|
public enum TurretTargetPriority
|
|
{
|
|
NearestThreat,
|
|
HighestHealthOrBoss,
|
|
ShieldedEnemies,
|
|
AsteroidsAndLoot
|
|
}
|
|
|
|
[Serializable]
|
|
public struct ResourceCost
|
|
{
|
|
public int scrap;
|
|
public int gold;
|
|
public int uranium;
|
|
|
|
public ResourceCost(int scrap, int gold, int uranium)
|
|
{
|
|
this.scrap = scrap;
|
|
this.gold = gold;
|
|
this.uranium = uranium;
|
|
}
|
|
}
|
|
|
|
[CreateAssetMenu(fileName = "WeaponDefinition", menuName = "GazeLab/Combat/Weapon Definition", order = 1)]
|
|
public sealed class WeaponDefinition : ScriptableObject
|
|
{
|
|
[Header("Identity & Tech Tree")]
|
|
public string weaponId = "wep_physical_lvl1";
|
|
public string displayName = "Light Autocannon Mk.I";
|
|
[TextArea(2, 3)] public string description = "Standard rapid-fire kinetic turret effective against hull and asteroids.";
|
|
public WeaponFamily family = WeaponFamily.Physical;
|
|
[Range(1, 6)] public int tierLevel = 1;
|
|
[Range(1, 8)] public int requiredStationLevel = 1;
|
|
public ResourceCost purchaseOrUpgradeCost = new ResourceCost(25, 0, 0);
|
|
public WeaponDefinition[] nextUpgradeBranches;
|
|
|
|
[Header("Sprite & Scale Normalization")]
|
|
[Tooltip("Weapon sprite (drawn facing +X Right).")]
|
|
public Sprite weaponSprite;
|
|
[Tooltip("Base scale applied on a hardpoint. Higher-tier weapon sprites can be normalized here so they fit proportionally on upgraded stations.")]
|
|
[Range(0.08f, 1.5f)] public float baseVisualScale = 0.28f;
|
|
public Color spriteTint = Color.white;
|
|
|
|
[Header("Mount Pivot & Multi-Barrel Muzzle Configuration")]
|
|
[Tooltip("Local offset (in unscaled sprite units) from the sprite's geometric center to the circular turret base center of rotation.")]
|
|
public Vector2 mountPivotOffset = new Vector2(-1.15f, 0f);
|
|
|
|
[Tooltip("Number of barrels on this weapon (1, 2, 3, 4, etc.).")]
|
|
[Range(1, 6)] public int barrelCount = 1;
|
|
|
|
[Tooltip("Forward distance from the Mount Pivot to the barrel tips used by Auto-Distribute Barrels.")]
|
|
[Range(0.2f, 8.0f)] public float autoBarrelForwardLength = 3.2f;
|
|
|
|
[Tooltip("Total vertical spacing across all barrels used by Auto-Distribute Barrels.")]
|
|
[Range(0f, 4.0f)] public float autoBarrelTotalSpreadY = 0.9f;
|
|
|
|
[Tooltip("Local positions of each barrel muzzle relative to the Mount Pivot (draggable in Scene/Inspector Preview).")]
|
|
public Vector2[] muzzleOffsets = new Vector2[] { new Vector2(3.2f, 0f) };
|
|
|
|
[Header("Firing Pattern & Rate")]
|
|
public FiringPattern firingPattern = FiringPattern.AlternatingSequential;
|
|
[Min(0.1f)] public float shotsPerSecond = 2.5f;
|
|
[Range(1, 12)] public int burstCount = 3;
|
|
[Range(0.03f, 0.5f)] public float burstInterval = 0.08f;
|
|
[Range(0f, 90f)] public float spreadAngleDeg = 8f;
|
|
[Min(1f)] public float maxRange = 9.5f;
|
|
|
|
[Header("Turret Rotation & Recoil")]
|
|
[Range(30f, 1080f)] public float rotationSpeedDegPerSec = 260f;
|
|
[Tooltip("360 = full rotation; smaller values restrict turret to a forward cone.")]
|
|
[Range(15f, 360f)] public float firingArcDegrees = 360f;
|
|
[Range(0f, 0.8f)] public float recoilKickbackDistance = 0.14f;
|
|
[Range(2f, 35f)] public float recoilRecoverySpeed = 14f;
|
|
[Range(0f, 25f)] public float idleSwayAmplitudeDeg = 6f;
|
|
[Range(0.2f, 5f)] public float idleSwaySpeed = 1.2f;
|
|
|
|
[Header("Ammunition & Muzzle VFX")]
|
|
public ProjectileDefinition projectile;
|
|
public Color muzzleFlashColor = new Color(1f, 0.85f, 0.4f, 0.9f);
|
|
[Range(0.05f, 1.5f)] public float muzzleFlashScale = 0.32f;
|
|
public AudioClip fireSfx;
|
|
|
|
public void AutoDistributeMuzzleOffsets()
|
|
{
|
|
int count = Mathf.Clamp(barrelCount, 1, 6);
|
|
if (muzzleOffsets == null || muzzleOffsets.Length != count)
|
|
muzzleOffsets = new Vector2[count];
|
|
|
|
if (count == 1)
|
|
{
|
|
muzzleOffsets[0] = new Vector2(autoBarrelForwardLength, 0f);
|
|
return;
|
|
}
|
|
|
|
float halfSpread = autoBarrelTotalSpreadY * 0.5f;
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
float t = count > 1 ? (float)i / (count - 1) : 0.5f;
|
|
float y = Mathf.Lerp(halfSpread, -halfSpread, t);
|
|
muzzleOffsets[i] = new Vector2(autoBarrelForwardLength, y);
|
|
}
|
|
}
|
|
|
|
private void OnValidate()
|
|
{
|
|
int count = Mathf.Clamp(barrelCount, 1, 6);
|
|
if (muzzleOffsets == null || muzzleOffsets.Length == 0)
|
|
{
|
|
AutoDistributeMuzzleOffsets();
|
|
}
|
|
else if (muzzleOffsets.Length != count)
|
|
{
|
|
Vector2[] resized = new Vector2[count];
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
resized[i] = i < muzzleOffsets.Length
|
|
? muzzleOffsets[i]
|
|
: new Vector2(autoBarrelForwardLength, 0f);
|
|
}
|
|
muzzleOffsets = resized;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|