public string GetRandomBackgroundTrack() { if (backgroundTracks.Count == 0) { return(null); } if (lastTracks == null) { lastTracks = new string[musicNotReplyCount]; for (int i = 0; i < lastTracks.Length; i++) { lastTracks [i] = ""; } } int index = Random.Range(0, backgroundTracks.Count); if (ContainsInLastTracks(backgroundTracks[index])) { if (ChanceSystem <bool> .IsChanceByPercent(50)) { for (int i = 0; i < backgroundTracks.Count; i++) { if (!ContainsInLastTracks(backgroundTracks[i])) { return(backgroundTracks[i]); } } } else { for (int i = backgroundTracks.Count - 1; i >= 0; i--) { if (!ContainsInLastTracks(backgroundTracks[i])) { return(backgroundTracks [i]); } } } index = 0; } return(backgroundTracks [index]); }
public AbstractFactory() { factoryGroup = new Dictionary <string, CurrentFactory <T> > (); chanceSystem = new ChanceSystem <string> (); }