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

public class DepositZone : MonoBehaviour {

    GlobalManager manager;

    AudioSource audioSource;

    void Start()
    {
        manager = GameObject.FindGameObjectWithTag("GameController").GetComponent<GlobalManager>();
        audioSource = GetComponent<AudioSource>();
    }

    void OnTriggerEnter(Collider other)
    {
        GoldWindow[] windows = GameObject.FindObjectsOfType<GoldWindow>();
        if (windows != null && windows.Length > 0)
        {
            manager.score += (windows.Length - 1) * 2 + 1;
            foreach (GoldWindow window in windows)
            {
                GameObject.Destroy(window.gameObject);
            }
            audioSource.Play();
        }
    }
}
