S
S
Sergey Tsyplakov2021-05-06 17:35:21
Unity
Sergey Tsyplakov, 2021-05-06 17:35:21

Adding new items to the reward chest?

Hi people. There is a question that I could not find an answer to or do not quite understand how to ask it.
There is an array that contains drop-down rewards and there is an array that has a different % drop for each reward. (Like this is called a weight table).
So the question is, how do I add new rewards to this array? At the same time, adding a new item to the array, I would like the% drop in the array to change too.
For example, there was such a percentage {50, 50} (there are also two items), but when I add the 3rd item to the list of drop-down rewards, I would like to change the percentage, for example {65, 25, 10}, i.e. it turns out an array with% also needs to be changed?
It feels like I'm trying to reinvent the wheel, but I'm just learning and have not yet figured out how to do it right.
Maybe you can send or throw a resource with a similar topic, English is also suitable.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2021-05-06
@Sodjiro

Use an array (and even better list) not of primitives, but of classes.
You start a class "reward". It has two fields - the reward itself and the percentage. And you already store an array of awards

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question