예제 #1
0
        public static int GetRandomIdentifier <T>(List <T> source) where T : IGladiator
        {
            // Joust Selection Algorithm
            List <int> arena = new List <int>();

            for (int i = 1; i < source.Count; i++)
            {
                IGladiator item = source[i];
                for (int j = 0; j < item.GetProb(); j++)
                {
                    arena.Add(i);
                }
            }
            return(arena[Random.Range(0, arena.Count)]);
        }
예제 #2
0
        public static T GetRandomObj <T>(List <T> source) where T : IGladiator
        {
            // Joust Selection Algorithm
            List <int> arena = new List <int>();

            for (int i = 0; i < source.Count; i++)
            {
                IGladiator item = source[i];
                for (int j = 0; j < item.GetProb(); j++)
                {
                    arena.Add(i);
                }
            }
            int result   = Random.Range(0, arena.Count);
            T   selected = source[result];

            return(selected);
        }