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

public class WaveLevels{

    public Dictionary<WaveType, int> levels;

    public WaveLevels()
    {
        levels = new Dictionary<WaveType, int>();
        Array waveTypes = Enum.GetValues(typeof(WaveType));
        foreach (WaveType waveType in waveTypes)
        {
            SetWaveLevel(waveType, 0);
        }
    }

    public void AddWave(WaveType waveType)
    {
        ChangeWaveLevel(waveType, +1);
    }

    public void RemoveWave(WaveType waveType)
    {
        ChangeWaveLevel(waveType, -1);
    }

    public void ChangeWaveLevel(WaveType waveType, int amount)
    {
        SetWaveLevel(waveType, GetWaveLevel(waveType) + amount);
    }

    public void SetWaveLevel(WaveType waveType, int level)
    {
        /*GetWaveLevel(waveType);
        levels[waveType] = level;*/
        levels[waveType] = level;
    }

    public int GetWaveLevel(WaveType waveType)
    {
        /*int level;
        if(levels.TryGetValue(waveType, out level))
        {
            return level;
        }
        else
        {
            levels.Add(waveType, 0);
            return 0;
        }*/
        return levels[waveType];
    }

    public void Increase(WaveLevels waveLevels)
    {
        foreach(WaveType key in waveLevels.levels.Keys)
        {
            ChangeWaveLevel(key, waveLevels.GetWaveLevel(key));
        }
    }

}
