63 lines
1.8 KiB
C#
63 lines
1.8 KiB
C#
using Core;
|
||
using UnityEngine;
|
||
|
||
namespace Minigames.Airplane.Abilities
|
||
{
|
||
/// <summary>
|
||
/// Bobbing Plane Ability: Tap to jump upward and forward.
|
||
/// Instant ability - activates once, then cooldown.
|
||
/// Applies diagonal impulse (forward + upward) to maintain airborne momentum.
|
||
/// Configuration loaded from settings at runtime.
|
||
/// </summary>
|
||
public class BobbingAbility : BaseAirplaneAbility
|
||
{
|
||
#region Configuration
|
||
|
||
private readonly Vector2 bobForce;
|
||
|
||
#endregion
|
||
|
||
#region Constructor
|
||
|
||
/// <summary>
|
||
/// Create bobbing ability with configuration from settings.
|
||
/// </summary>
|
||
public BobbingAbility(string name, Sprite icon, float cooldown, Vector2 force)
|
||
: base(name, icon, cooldown, reusable: true, activeDuration: 0f)
|
||
{
|
||
bobForce = force;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region Override Methods
|
||
|
||
public override void Execute()
|
||
{
|
||
if (!ValidateAirplane()) return;
|
||
if (!CanActivate) return;
|
||
|
||
StartActivation();
|
||
|
||
var rb = currentAirplane.GetComponent<Rigidbody2D>();
|
||
if (rb != null)
|
||
{
|
||
// Apply configured forward and upward impulse
|
||
// X = forward momentum, Y = upward lift
|
||
rb.AddForce(bobForce, ForceMode2D.Impulse);
|
||
|
||
if (showDebugLogs)
|
||
{
|
||
Logging.Debug($"[BobbingAbility] Executed - Force: {bobForce} (forward: {bobForce.x:F1}, upward: {bobForce.y:F1})");
|
||
}
|
||
}
|
||
|
||
// Instant ability - deactivate immediately (base.Deactivate starts cooldown)
|
||
base.Deactivate();
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
}
|
||
|