using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;

public class Bubble : Bullet
{
    public BubbleBinding binding;

    public Rigidbody rb => binding.rb;

    protected float startTime;

    public float time => Time.time - startTime;

    protected virtual void Start()
    {
        startTime = Time.time;
        GameManager.instance.PlayAudioEffect(binding.spawnClip);
    }

    protected virtual void Update()
    {
        var speedTime = binding.speedOverTime.Evaluate(time);

        rb.AddForce(transform.forward * speedTime * binding.speed * Time.deltaTime);

        rb.AddForce(Vector3.down * binding.gravity * Time.deltaTime, ForceMode.Acceleration);

        // transform.localScale = Vector3.one * binding.scaleOverTime.Evaluate(time);
    }

    public virtual void Burst()
    {
        GameManager.instance.PlayAudioEffect(binding.destroyClip);
        Destroy(gameObject);
    }
}