// Use this for initialization
    void Start()
    {
        prevClipPlayTime = 0f;

        waitingClips = new List <AudioEvent>();

        // normalize
        foreach (AudioClipManager acm in audioClipManager)
        {
            acm.NormalizeClipPlayChance();
        }

        // put into more useful format
        announcerClips = new Dictionary <AnnouncementType, AudioClipManager>();
        for (int i = 0; i < audioClipManager.Length; i++)
        {
            AnnouncementType t = audioClipManager[i].announcementType;
            //PlayerReactionType pt = audioClipManager[i].playerType;
            if (!announcerClips.ContainsKey(t))
            {
                announcerClips.Add(t, audioClipManager[i]);
            }
        }

        matchClips = new Dictionary <MatchEffect, MatchProgressionEffects>();
        for (int i = 0; i < matchClipManager.Length; i++)
        {
            MatchEffect t = matchClipManager[i].type;
            //PlayerReactionType pt = audioClipManager[i].playerType;
            if (!matchClips.ContainsKey(t))
            {
                matchClips.Add(t, matchClipManager[i]);
            }
        }
    }
    public void PlayMatchEffect(MatchEffect type)
    {
        if (!sfxSource.isPlaying)
        {
            int i = matchClips[type].GetNextClipIndex();

            if (i >= 0 && i < matchClips[type].clips.Length)
            {
                sfxSource.clip = matchClips[type].clips[i];
                sfxSource.Play();
            }
            else
            {
                sfxSource.clip = silence;
            }
        }
    }
Esempio n. 3
0
 private void Awake()
 {
     onDestroyEffect = GetComponent <MatchEffect>();
 }