duck

duck

Jun 15th, 2010
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.28 KB | None | 0 0
  1.  
  2. float r = Random.value * categoryProbabilitySum;
  3. float sum = 0;
  4. Category selectedCategory = null;
  5. foreach (Category category in rarenessCategories)
  6. {
  7.     if (r >= sum && r < sum + category.probability)
  8.     {
  9.         selectedCategory = category;
  10.         break;
  11.     }
  12.     sum += category.probability;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment