using UnityEngine;

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

public class ComboGenerator : MonoBehaviour {

    public List<int> generatedCombo = new List<int>();
    public int maxSize = 5, minSize = 1;

    [SerializeField]
    private bool firstIteration = true;
    private int randNo = 0;

    void OnEnable()
    {
        EventManager.StartListening(Constants.GenerateCombo, GenerateCombo);
    }

    void OnDisable()
    {
        EventManager.StopListening(Constants.GenerateCombo, GenerateCombo);
    }

    void GenerateCombo()
    {
        generatedCombo.Clear();
        for (int i = 1; i < maxSize; i++)
        {
            if (firstIteration)
            {
                randNo = Random.Range(minSize, maxSize);
                generatedCombo.Add(randNo);
                //previousCombo.Add(generatedCombo[i]);
                firstIteration = false;
                continue;
            }
            //else
            //{
            //    randNo = Random.Range(minSize, maxSize);

            while (generatedCombo.Contains(randNo))
            {
                randNo = Random.Range(minSize, maxSize);
            }
            generatedCombo.Add(randNo);


        }
    }
}
