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

public class CharacterManager : MonoBehaviour {

    public static CharacterManager instance { get; private set; }

    void Awake()
    {
        instance = this;
        characters = new List<CharacterData>();
    }


    public List<CharacterData> characters { get; private set; }

    public CharacterData PlayerCharacter { get; private set; }

    public void registerCharacter(CharacterData character)
    {
        characters.Add(character);
        if (character.Type == CharacterType.Player)
        {
            PlayerCharacter = character;
        }
    }

    public void unregisterCharacter(CharacterData character)
    {
        characters.Remove(character);
    }

    public int getNumberOfRegisteredCharacters(CharacterType type)
    {
        int count = 0;
        foreach (CharacterData character in characters)
        {
            if (!character.isDead && character.Type == type)
            {
                count += 1;
            }
        }
        return count;
    }
}
