MVP of the plane throwing game (#77)
Co-authored-by: Michal Pikulski <michal@foolhardyhorizons.com> Co-authored-by: Michal Pikulski <michal.a.pikulski@gmail.com> Reviewed-on: #77
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
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)
|
||||
{
|
||||
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 and start cooldown
|
||||
base.Deactivate();
|
||||
StartCooldown();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user