Update the vacuum projectile logic

This commit is contained in:
Michal Pikulski
2025-12-16 19:42:48 +01:00
parent c5f37a5df4
commit aaaeef19d7
4 changed files with 41 additions and 29 deletions

View File

@@ -126,6 +126,10 @@ namespace Minigames.FortFight.Core
[AppleHills.Core.Settings.Layer]
[SerializeField] private int projectileLayer = 9;
[Tooltip("Layer for ground/floor - vacuum projectile activates sliding when hitting this layer (Default: Layer 0 'Default')")]
[AppleHills.Core.Settings.Layer]
[SerializeField] private int groundLayer = 0;
[Header("Visual Settings")]
[Tooltip("Color tint applied to damaged blocks")]
[SerializeField] private Color damageColorTint = new Color(0.5f, 0.5f, 0.5f);
@@ -152,6 +156,7 @@ namespace Minigames.FortFight.Core
public int FortBlockLayer => fortBlockLayer;
public int ProjectileLayer => projectileLayer;
public int GroundLayer => groundLayer;
public Color DamageColorTint => damageColorTint;

View File

@@ -6,7 +6,8 @@ namespace Minigames.FortFight.Projectiles
{
/// <summary>
/// Vacuum projectile - high mass, slides along ground after landing.
/// On floor/block impact: applies constant force to the right and destroys blocks.
/// Maintains normal physics until it hits the ground layer, then activates sliding mode.
/// While sliding, destroys blocks it encounters.
/// </summary>
public class VacuumProjectile : ProjectileBase
{
@@ -17,7 +18,10 @@ namespace Minigames.FortFight.Projectiles
protected override void OnHit(Collision2D collision)
{
// If already sliding, count block destruction
// Get settings once for all checks
var settings = GameManager.GetSettingsObject<IFortFightSettings>();
// If already sliding, handle block destruction
if (isSliding)
{
var block = collision.gameObject.GetComponent<Fort.FortBlock>();
@@ -27,7 +31,6 @@ namespace Minigames.FortFight.Projectiles
SpawnImpactEffect(collision.contacts[0].point);
// Get damage from settings
var settings = GameManager.GetSettingsObject<IFortFightSettings>();
float blockDamage = settings?.VacuumBlockDamage ?? 999f;
// Deal high damage to destroy block instantly
@@ -46,15 +49,36 @@ namespace Minigames.FortFight.Projectiles
return;
}
// First hit - spawn impact effect and start sliding
SpawnImpactEffect(collision.contacts[0].point);
Logging.Debug("[VacuumProjectile] Hit surface - starting slide");
StartSliding();
// Don't destroy - keep sliding!
// Check if we hit the ground layer to activate sliding
int groundLayer = settings?.GroundLayer ?? 0;
if (collision.gameObject.layer == groundLayer)
{
// Hit ground - start sliding behavior
SpawnImpactEffect(collision.contacts[0].point);
Logging.Debug($"[VacuumProjectile] Hit ground (layer {groundLayer}) - starting slide");
StartSliding();
// Don't destroy - keep sliding
return;
}
// Hit something else (fort block, etc.) while not sliding - use normal projectile behavior
Logging.Debug($"[VacuumProjectile] Hit {collision.gameObject.name} (layer {collision.gameObject.layer}) - normal impact");
// Deal damage if it's a fort block
var hitBlock = collision.gameObject.GetComponent<Fort.FortBlock>();
if (hitBlock != null)
{
hitBlock.TakeDamage(Damage);
SpawnImpactEffect(collision.contacts[0].point);
}
// Normal projectile destruction
DestroyProjectile();
}
/// <summary>
/// Start sliding behavior after hitting surface
/// Start sliding behavior after hitting ground surface
/// </summary>
private void StartSliding()
{