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

public class CandelSpawner : MonoBehaviour {

    public GameObject placelist;
    public GameObject spawned;
    public int min;
    public int max;

    
	
	// Update is called once per frame
	void Start() {
        int amt = Random.Range(min, max + 1);
        for (int i = 0; i < amt; i++) {
            GameObject.Instantiate(spawned,
                placelist.GetComponent<PositionHolderScript>().GetRandomPositionOnce(),
                Quaternion.identity);
            FreqFallScript ffs = spawned.GetComponentInChildren<FreqFallScript>();
            FreqSwingScript fss = spawned.GetComponentInChildren<FreqSwingScript>();

            ffs.resonance_note = Random.Range(19f, 22f);
            fss.resonance_note = ffs.resonance_note ;
            ffs.resonance_frequency = Tools.Note_To_Freq(ffs.resonance_note);
            fss.resonance_frequency = Tools.Note_To_Freq(fss.resonance_note);
            ffs.precision_needed = 1; // Random.Range(1.1f, 2f);
            fss.precision_needed = ffs.precision_needed;
            ffs.amplitude_needed = 1;
            fss.amplitude_needed = ffs.amplitude_needed;
        }
    }
}
