using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Pearl : MonoBehaviour
{
    public Transform glow;

    public bool won = false;

    private void OnTriggerEnter2D(Collider2D collision) {
        Debug.Log("collision: " + collision);
        if (collision.attachedRigidbody.CompareTag("Player")) {
            Debug.Log("Win");
            if (!won) {
                OnReachedPearl();
            }
        }
    }

    [ContextMenu("Win")]
    void OnReachedPearl() {
        won = true;
        FindObjectOfType<UIWin>().OnWin();
    }

    private void Update() {
        if (won && glow.localScale.x < 1000) {
            glow.localScale += Vector3.one * 1f * Time.deltaTime;
            glow.localScale *= 1 + glow.localScale.x * Time.deltaTime;
        }
    }
}
