Exemplo n.º 1
0
        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]);
        }
Exemplo n.º 2
0
 public AbstractFactory()
 {
     factoryGroup = new Dictionary <string, CurrentFactory <T> > ();
     chanceSystem = new ChanceSystem <string> ();
 }