Comments and answers for "Add random amount of random items from one list to another?"
http://answers.unity.com/questions/680410/add-random-amount-of-random-items-from-one-list-to.html
The latest comments and answers for the question "Add random amount of random items from one list to another?"Answer by robertbu
http://answers.unity.com/answers/680462/view.html
The "hard" part of your question is handling the rarity. I can think of two approaches. Both solutions involve defining a value for rarity rather than an enum. In the first one you need an integer value, and I'd do it in terms of abundance. So say your rarest item is given a value of 2. All other items are relative to the rarest. So if next rarest is twice abundant, it would get a value of 4. And if you had one that was 3 1/2 as abundant, it would get a value of 7.
Once defined, you construct the 'store' array. You populate it based on the abundance value. So you for the item with a value of 7, it will have 7 entries in the list. You populate the chest by simply selecting one from the length of the list.
The second approach is similar to the first in that you assign abundance values, but they don't have to be integers. So say the rarest has a value of 1.0, the next rarest might have a value of 1.5 for example. To get a random entry, you first sum all the abundance values. Then you generate a random value based on all the abuncance:
val = Random.Range(0.0,totalAbuncance);
Then you walk your array adding up the abundance values as you go. When the sum is greater than your 'val', that is the entry that goes in the chest.Fri, 04 Apr 2014 17:58:30 GMTrobertbuAnswer by Xavier78
http://answers.unity.com/answers/680447/view.html
well i can push you in the right direction.
first I would make the rarity of the items so
var rarity = #;
and make it into a static var.
Then in your chest script make it call your array of items.
the chest should have a built in array of GameObjects
var ItemsInChest = GameObject[size];
var size = 0;
// make that how many items you want in the chest
or/also
var min = 10;
var max = 15;
function start()
{
size = Random.Range(min, max)
}
// so it chooses random amount of items
now this is just a basic over vew, if you have the array already you can just make it static and then do
var ItemsToGet = 0;
function start()
{
// make how ever many randum itomes you want to be in chest
// get those items from your items array
//add those items to this chest array
//set amount for those items
}
now with out knowing the type of array you are using i have no more i really can say.
hope it helped if not i will delete it to save space.Fri, 04 Apr 2014 17:42:32 GMTXavier78Comment by koray1396
http://answers.unity.com/comments/680431/view.html
a simple way is, all items would have multipliers, very rares would have one, some 2, some 50 maybe, as if they are listed x times. you can find the total number, and generate a random number out of it. then you can project this number to the list item number.
simply basic version of weighted random numbers.Fri, 04 Apr 2014 16:59:49 GMTkoray1396Comment by borro56
http://answers.unity.com/comments/680430/view.html
I dont undestand what you mean when you say based on an enum, the enum determines the chance of the object to be added or you just want to add objects of certain type determined by that enum?Fri, 04 Apr 2014 16:54:17 GMTborro56Comment by roojerry
http://answers.unity.com/comments/680427/view.html
Look into [weighted random numbers][1]
[1]: http://lmgtfy.com/?q=weighted+random+numbersFri, 04 Apr 2014 16:44:18 GMTroojerry