Game Development Reference
In-Depth Information
Managing the shop
Now that we have our shop interface and some stock we can put in it, it's time to bring
them together.
First, we need to set up a shop manager who looks after the day-to-day running of the
shop, then we will add the shelves to the shop to manage where we can put the stock.
Note
As the ShopSlot and ShopManager folder depend on each other, we need to create
them together. Until both are complete, you will most likely see errors; just keep this in
mind as we progress.
It is always the same when you are creating codependent classes.
First, we need the shop manager itself. To keep things neat, create a new folder in the pro-
ject's Assets folder named Shop , then create a new script in the Shop folder named
ShopManager . This just ensures that any script related to shopping is stored here if you
want to expand it later. The manager is only used in this one scene, so we don't need to
make it a singleton.
To start off, we will just add some parameters so we can control the shop we are creating
and set it up as follows:
using UnityEngine;
public class ShopManager : MonoBehaviour {
public Sprite ShopOwnerSprite;
public Vector3 ShopOwnerScale;
public GameObject ShopOwnerLocation;
public GameObject PurchasingSection;
public SpriteRenderer PurchaseItemDisplay;
public ShopSlot[] ItemSlots;
public InventoryItem[] ShopItems;
private static ShopSlot SelectedShopSlot;
Search WWH ::




Custom Search