using System;
using System.Collections.Generic;

public class EnemyType
{    
    public class EnemyTypeStat
    {
        private int _statLevel;
        private int _statSpawnCount;
        private int _statLevelScore;
        private float _statLifeTime;
        private float _statFailureChance;

        public int Level
        {
            get
            {
                return _statLevel;
            }
        }
        public int SpawnCount
        {
            get
            {
                return _statSpawnCount;
            }
        }
        public int Score
        {
            get
            {
                return _statLevelScore;
            }
        }
        public float LifeTime
        {
            get
            {
                return _statLifeTime;
            }
        }
        public float FailureChance
        {
            get
            {
                return _statFailureChance;
            }
        }

        public EnemyTypeStat(int level, int spawnCount, int levelScore, float lifeTime, float failureChance)
        {
            _statLevel = level;
            _statSpawnCount = spawnCount;
            _statLevelScore = levelScore;
            _statLifeTime = lifeTime;
            _statFailureChance = failureChance;
        }
    }

    private List<EnemyTypeStat> _enemyStats = new List<EnemyTypeStat>();

    public bool AddLevelStats(int level, int spawnCount, int scoreAmount, float lifeTime, float failureChance)
    {
        if (this[level] == null)
        {
            _enemyStats.Add(new EnemyTypeStat(level, spawnCount, scoreAmount, lifeTime, failureChance));
            return true;
        }
        else
        {
            return false;
        }
    }

    private EnemyTypeStat GetLevelStats(int level)
    {
        EnemyTypeStat result = null;
        if (_enemyStats.Count > 0)
        {
            foreach (EnemyTypeStat currentLevelStat in _enemyStats)
            {
                if (currentLevelStat.Level == level)
                {
                    result = currentLevelStat;
                    break;
                }
            }
        }
        return result;
    }

    public int Count
    {
        get
        {
            return _enemyStats.Count;
        }
    }

    public EnemyTypeStat this[int level]
    {
        get
        {
            return GetLevelStats(level);
        }
    }
}