Hooking up the player to the Economy

posted in KrisWolfe
Published April 15, 2019
Advertisement

This week I focused on getting the player hooked up to interface with the economy. I've tested what I have with varying amounts of agents, and the numbers popped out about what I would expect, so it appears to be working. I need to capture more statistics later to make sure there's not "other" behavior going on that I don't anticipate, but I'll work on that once I have my player hooked up and I can start messing around with the engine to fine tune the numbers.

This week I also discovered that UI is boring as hell to design, and took a lot longer than I thought it would, specifically getting motivated to work on it.

I learned a lot about input boxes and drop downs. Dropdowns are way more complicated than they appear. I made two screens...one for managing your companies, and the other for placing orders into the market. The UI is not polished. I bought a UI pack for $5 off the Unity market just to have some placeholder art while I'm figuring out exactly what I want. I still don't know what the final product will look like, but as I hook up the systems to each other, I'll go back over them.

Another important concept I'm running into is refactoring. It is actually hard to just say "Ok, this works, I'll come back to it later." I want to refactor my code, but as I'm designing this system to hook the player up to the economy, I'm running into problems that I can only solve by rewriting sections of my economy code. So I need to hold on refactoring code until I have a complete idea of what my code needs. Specifically, I want the player's companies to act a little different than the NPC's. NPC companies have a change to turn their orders into market orders instead of limit orders. I only enter orders for the player when they actually want them. So, I can't just throw the player's companies into the list with the NPC's companies to "get handled." I also want the player to be able to run each part of their company, while the NPC's will require an employee to run parts of their business.

This is nice, because it gave me a chance to run some polymorphism. I had methods become different based on if it was a player or NPC, so it was fun to mess around with that. But eventually I think what's going to happen is that I turn the NPC's to act like player characters, but their actions are handled by a factory design pattern instead of the player object. But that's just something to do for another time.

I've attached my company management screen and my market screen. Right now I just have a button to create a company...the choices right now are a retailer or a producer...the producer always has at least one recipe, and if they have enough employees, they will produce goods. They will then send those goods to a retailer that they have a contract with. On the market screen, we have a bunch of drop downs which allow you to switch markets, choose which company you own that you want to get orders for, choose which recipe, and then see the current contract market for the good selected. Asks are what producers put out, Bids are what retailers put out, and they sell per good sent. Since I'm a producer with an output recipe, the bid options are disabled. I can then put in a market or limit order for contracts, and they will get executed on the next "game turn". It's a little complicated, and I will need an extensive tutorial, or at least make the UI better to read eventually.

And that is currently working. I can acquire contracts and I tested it this weekend.

I wanted to do the same for employees, but then realized I wanted the player to be able to run their business without employees. So, the next step is to now get the scheduler up and running with skills. When you own a company, you will have the "produce recipe" skill pop up and for each hour you spend on this skill, you will produce a certain amount of goods. With a retail store, you can "man the register", and if customers show up you will sell to them.

That highlights another problem I'm running into. I know I want a skilltree, but I'm not sure what to put in the skilltree, or how it works and unlocks. I want skills to be unlockable the more you use them, so that you get better at a job or skill overtime. Right now my plan is to just add them as I'm designing the rest of the game, and I'm like "oh yeah I should have a skill for this."

Another problem I'm running into is that I'm hard coding strings into my code to detect which type of company I have. I think I'm going to have to get a JSON database up and running sooner rather than later, and that can go hand in hand with editors I want hardcoded into the game. I'm thinking I should just create editors now to make skills and types of companies and goods, so that the buyer of my game can also do the same and use the same editors to make whatever skills and companies and goods they want.

Another aspect I've been keeping in mind is to keep this multiplayer ready. I want people to be able to run a company together, specializing in different skills and taking on the market, stealing from each other. I want players to be able to have a job AND a secret company on the side, siphoning funds from the business and sabotaging each other...or they could work together and build a mega corp. I know I will need to do a command design pattern for player actions eventually, so that they don't have all the information available to them to cheat. So for now the player object I'm using is a prefab that I edit, and I only store commands on it to send to the economy...Eventually I will put some code in to validate the commands, but for now I want to get systems up and running.

So this week I will work on the scheduler and some basic skills to get a company up and running and interfacing with the economy. Then likely start working on an editor to add skills, company types, goods, and recipes into the game through the editor instead of just hard coding it into code.

 

CompanyManagementScreen.JPG

MarketScreen.JPG

Previous Entry Economy milestone
Next Entry Taking a break
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement