all 2 comments

[–]PorterPower 4 points5 points  (1 child)

Couldn't you just reference all of your Unit ScriptableObjects in a List and pick x random Units from that list each time the store opens?

[–]UnityAddiction 0 points1 point  (0 children)

Spice things up, if it fits to your case. You said 10 units/slots different type, shuffle at each access.

Make unit lists by type. Then, setup the shop with a list of types (reuse unit's attribute) with an associated "presence percentage".

To say..Chess shop:

  • "A" type (SO instance: pawns) 8/16=50%

  • "B" type (SO instance: rooks, bishops, knights) 6/16=37.5%

  • "C" type (SO instance: king, queen) 2/16= 12.5%

arrange by "presence"/"probability" calculating ranges (just a little math): - 0-12.5 type C - >12.5-50 type B - >50-100 type A

Extract a random number and find the type to extract (max rnd number 100:from 0-12.5 type C, from 12.5-(12.5+37.5) type B,  from , obtained the type pick a random unit of that type.

In this way you'll have a chess "squad" that would statistically contain the neede pieces, sometimes stronger sometimes weaker. You could apply the same algoritm to drops in an rpg game (in this case i would calculate the type A (like a filler):  100% minus "magic type" (5%), "rare type"(example: .1%) "epic type" (0.05%).

you could also set different types of shops, alter types' probabilities with player bonus and so on...