Inventory shop with multiple currencies

Shanmukh

Member
Hi
1. in my game there are two types of currencies (Gold and Silver). some items in the shop can be purchased with any one of the currencies. please guide me to implement this.
2. and in the shop, I want to show only the Main collection. it shows all collection items in inventory, even I added a collection filter.
3. I would like to create my own shop please guide me to start with the script, to handle buying and selling items, with different currencies
 
1.
When you make your currencies you can choose to link them or not. For example you can define 1 gold = 100 silver. This way if something costs 254 silver you can buy with 2 gold and 54 silvers, 1 gold 154 or 254 silver. the conversion is done automatically by our CurrencyCollection class.

If you do not want to link Gold and Silver then you don't have to. They can be completely separate currencies with no way to pass from one to the other. At that point if something cost 1gold and 5 silver you will need exactly that amount.

Defining the currencies relationship is done in the Editor Window:
also you can learn more about currencies here:

In your case though it seems you want to be able to buy either with gold or silver not a combination of both. Unfotunatly that means you will need to create a custom shop Menu. Fortunatly it seems you already plan too :)

The easiest way you would set that up is by having two CurrencyAmount Attribute on your items. One for the Gold amount and another for the silver amount. This way in your custom shop menu, all you need is to change what Attribute the shop needs to look at to find the currencyAmoutn value of the item

2.
That seems very odd to me, it should work. Please send me some screenshot or video of your setup, it's possible you haven't set the filter properly. For example if you are using tabs like the demo scene you must add the collection filter to each tab not to the InventoryGrid

3.
You can create your own Shop and ShopMenu. In your case I thing you only need a cusotm ShopMenu but it's up to you.
You can simply dupplicate the ShopMenu script call it whatever you like and place it in your folder.
Then read the code, everything is fully documented to it should be easy to understand what each function does. and modify it to your needs.

(If you have trouble with getting references to Opsive types then make sure to read or watch tutorials about Assembly Definition, there are many of them on youtube)

You might also be interested in these pages:

Good luck! And don't hesitate to ask if you need more guidance :)
 
Thank you for addressing my concerns and for your quick response!

I'm currently working on implementing an equipment system for character equipment in a 3D view, similar to an inventory system. Before players purchase an item from the shop, they should be able to preview how the item will look when equipped by the player.

I initially set up the system based on the inventory mechanics, where items can be moved to the equipment collection in the shop inventory through item actions. However, I've encountered a couple of issues:

  1. When I select an item, it correctly transfers to the equipped collection. However, the index order of the item in the inventory grid changes. Instead of remaining in the same position as in the inventory panel, it moves to the last position I selected.
  2. Additionally, after transferring to the equipment collection, the item info goes missing.
Could you please take a moment to review the screenshot I've attached below? Your insights and assistance in resolving these issues would be greatly appreciated! Thank you again for your support.
Screenshot 2024-04-05 115808 (1).png
 
Interesting.

So you want to preview the Equipment visually on the character before buying the item.

I would highly recommend you write the code for a custom shop menu in that case. It will give you a lot more feedom.

The way I see it, yoou have two options
1) Have a copy of the character in the ShopMenu that you will use to dress up your character to preview how the items would look like
2) Save the currently equipped items in a list. Remove them and then equip back duplicate versions of those items. When you preview an item to buy you replace the equipped item on the character. When you buy an item you replace it in the equipment list you made. And when you exit the shop menu you remove all equipped items and add back the list of equipment you had save.


Both approaches have pros and cons, but both are viable in my opinion.

By having a completely custom shop menu you should be able to fix your second issue of the item going missing by just redrawing the description.

I hope that points you in the right direction, good luck!
 
Back
Top