Set variables in an array dependent on which scene the player is in.

This may be kind of a confusing issue, but I’ll do my best to explain my problem. I am making a game with many scenes (will probably end up at around 50 to 60). At the end of each stage I have a scoring system that awards 1, 2 or 3 gold stars depending on how well the player did. I then send this value to an int array to be saved. The number of the array that is saved needs to be dependent on which scene the player is currently on. I have a system that works, but will end up being very text heavy.

function SetGold(goldCount : int)
{
	if(Application.loadedLevelName == "1-1" && goldCount > goldArray[1])
	{
		goldArray[1] = goldCount;
	}
	if(Application.loadedLevelName == "1-2" && goldCount > goldArray[2])
	{
		goldArray[2] = goldCount;
	}
	
    //etc...

    //etc...

    //etc...

	Save();
}

This works fine, but I would need to copy, paste and change values many times. This is no big deal if I only have to do it once, but if I need to alter my code later on, I will need to copy, paste and change values all over again. So I’m wondering if there is a simple method that will allow the script to check the level and set the corresponding value to the array automatically.

There are lots of ways, but one might be to use a Dictionary for your storage, where the key is the “level name” and the value is your totaled INT for that level.