/// <summary> /// Chooses a tune to start playing. /// </summary> /// <returns>The index of the tune to play next.</returns> protected override int ChooseTune() { float totalTuneWeights = 0; float[] modifiedTuneWeights = new float[tuneWeights.Length]; for (int i = 0; i < tuneWeights.Length; i++) { Tune tune = bard.tunes[i]; if (tune.IsTuneUseless(control)) { modifiedTuneWeights[i] = 0; } else { modifiedTuneWeights[i] = tuneWeights[i]; } totalTuneWeights += modifiedTuneWeights[i]; } float random = Random.Range(0, totalTuneWeights); float counter = 0; for (int i = 0; i < modifiedTuneWeights.Length - 1; i++) { counter += modifiedTuneWeights[i]; if (random < counter) { return(i); } } return(tuneWeights.Length - 1); }