Question on Events and Delegates

Hello everyone, I’m working on using Events and Delegates but I’ve hit a roadblock and was hoping if someone could tell me A) if what I’m looking for is possible and B) point me in the right direction for how to accomplish it.

What I’m trying to do:
I’ve got a number of playable rooms, and when the play leaves those rooms, I would like all the audio from those rooms to turn off using a generic script that I can pass a int to and call the appropriate event.

My Problem:
I’m not sure how to use this int value to call the appropriate event (aside from using a ton of IF statements…). I was not successful in making a array of events or calling the main delegate event by index, so how would this be accomplished?

I’ve also considered a script that calls a Manager that then calls an event, but that again ends up with many scripts instead of 1.

Below is a basic concept of what I’m trying to do, any help is appreciated.:

using UnityEngine;
using System.Collections;

public class MasterManager : MonoBehaviour {

	public int roomNumber;

	public  delegate void TurnSoundsOff ();
	public static event TurnSoundsOff turnOff1;
	public static event TurnSoundsOff turnOff2;
	

	void Update () //would be ontriggerenter or something similar
	{
		if (Input.GetKeyDown (KeyCode.P))
		{
			RelayMessage();
		}
		
	}
	
	
	void RelayMessage ()
	{
		//call specific event based on roomNumber
	}
}

You could have a parent foreach of your rooms, and have their references in your MasterManager. When leaving a room, use that parent and GetComponentsInChildren() to disabled them all. Or search of your own script that knows what to disable and how.

If you still prefere events, have an array of them in MasterManager. The index represent a room. When something that can make sounds is created, have it subscribe the turn off sound function to the event corresponding to its room index. Something like :

// In a script attach to the thingy that makes sound
masterManager.SubscribeEvent(TurnOffSound(), roomIndex); 

// In MasterManager
public void SubscribeEvent(TurnSoundsOff turnOff,int roomIndex)
{
    onLeaveRoomArray[roomIndex] += turnOff;
}