using Godot;
using Newlon.Components.Level;

namespace Newlon.Components.Plants;

public partial class ThreepeaterShooter : Shooter
{
    public override void SpawnProjectile()
    {
        for(int i = -1; i <= 1; i++)
		{
			if (GetParent<Node2D>().GlobalPosition.Y+i*Utility.TileHeight >= Utility.RightFieldBoundary.Y || GetParent<Node2D>().GlobalPosition.Y+i*Utility.TileHeight <= Utility.LeftFieldBoundary.Y)
				continue;

			var instance = _projectile.Instantiate<Node2D>();
			PoolContainer.Instance.Projectiles.AddChild(instance);
			instance.GlobalTransform = GlobalTransform;

			if(i != 0)
			{
				var tween = CreateTween().SetEase(Tween.EaseType.Out).SetTrans(Tween.TransitionType.Sine);
				tween.TweenProperty(instance,"position:y",instance.Position.Y+i*Utility.TileHeight,0.5);
			}
		}
    }
}
