Central to the idea of a “space trading game” is the presence of something to trade. The most basic idea is that you as a player must find the lowest price on a specific item, buy as much of that as you can afford/hold, and then fly it to another location where you sell it for more — hopefully much more — than you paid for it. In a simulation, it can’t be the case where you bounce between two nearby stations ferrying goods back and forth until you’ve amassed a fortune, so the system needs to implement a kind of rough supply-and-demand system so that stations with lower inventory will buy for more cash, while stations with higher inventories will offer less cash. Behind the scenes, processes run to simulate other traders, moving goods around to shift buy/sell conditions at all stations.
I’ve gone over this system about 100 times at this point, but I still haven’t quite mastered the art of market simulation. Ideally, I should be creating dummy data and then simulating it with a spreadsheet or some quick scripting tests. I am cursed with being a visual developer; I need to see something in front of me in some semblance of how I picture it in my mind, and that usually leads me to taking a detour into the world of UI design.
The “new” Unity UI is better than the old system at least because it’s visual. I can drag elements onto the screen and position them, wiring up actions to event handlers to make stuff happen. Unfortunately, the new system is sometimes pretty esoteric if you’re not internalizing it’s quirks. Scale and position have all thrown me for a loop recently, and I’m always just one slip of the mouse away from getting myself hopelessly tweaked in a way that I struggle to recover from, because now a panel is too big or the font is too jagged. I learned today that using childTransform.SetParent(parentTransform, false) is better than the standard transform.parent = ? when dealing with the UI because the former method respects scale and position, whereas the later does not. Thankfully, I learned that quickly. Other questions haven’t been as forthcoming with satisfactory answers.
Like other iterations I’ve worked on in the past, this market panel takes the inventory of a specific station’s commodity (trading goods) market and lists them. Unlike previous attempts, this is an integrated list. Previous attempts had been working under the assumption that I needed to have two panels: one for the shop inventory, and one for the player inventory. But that was unwieldy and required me to duplicate code, once for the player, once for the shop. And then they had to talk to one another to keep each other updated. Yeesh.
My decision to use a central data clearinghouse is paying off by helping to fix this issue. Now I’m taking more of an Elite: Dangerous method as opposed to the traditional RPG shop method. The list of commodities at any shop shows one row for each item. Each row contains the name of the commodity, it’s calculated price, the quantity in the shop, and a quantity that the player is hauling. The SHOP and HOLD columns will have buttons pointing at one another (SHOP > and < HOLD). Those buttons equate to “transfer one unit of this item in the direction of the arrow when I click that arrow”.
What’s happening under the hood (eventually) is this:
One thing I’ve always wanted to do was to add an extra layer not usually found in trading sims, and that’s history. I know that EVE Online has a kind of trading history, so players can see what the historical high and low prices were for specific items. In a single player game like mine, though, I think that data would be for edification, maybe for light analysis. Obviously you can see the difference in price between toilet paper and palladium, but what’s the profit margin? Is it better to haul toilet paper in one sector, even if palladium is available? This is why I need to work weight or mass into each item, and to create different classes of cargo holds, so you might be able to jam in more soft rolls of TP than you can carry in palladium bars.
First things first: I want to make the player inventory, a cargo hold view, and then get the buying and selling working.