static public T Select(Dictionary <T, double> set) { if (set.Count == 0) { Console.WriteLine("Null Select"); return(default(T)); } double totleRate = TotleRate(set); double rollValue = RandomNum.Value(0.0f, (float)totleRate); double accRate = 0; foreach (var k in set.Keys) { accRate += set[k]; if (rollValue < accRate) { return(k); } } throw new Exception("random no hit!!!"); return(default(T)); }
static public T Select(List <T> set) { if (set.Count == 0) { return(default(T)); } int index = RandomNum.Value(0, set.Count); //UnityEngine.Debug.Log("Random Select index:" + set.Count + " " + index); return(set[index]); }
public static ASCIIColor RndBaseColor() { int c = RandomNum.Value(0, 3); if (c == 0) { return(new ASCIIColor(255, 0, 0, 255)); } if (c == 1) { return(new ASCIIColor(0, 255, 0, 255)); } return(new ASCIIColor(0, 255, 255, 255)); }
static public ASCIIColor RndColor() { return(new ASCIIColor(RandomNum.Bit8(), RandomNum.Bit8(), RandomNum.Bit8(), 255)); }