Jump to content
  • Advertisement
  • entries
    32
  • comments
    0
  • views
    2940

About this blog

This is my Game dev blog for Fraud simulator! Let's make a game together!

Entries in this blog

Refactor and Polish

This week has been has just been refactoring and cleaning up the code, finding more efficient ways to do things. All the bugs I've found I've crushed except one. For some reason if you try to build a building without the necessary resources, the text is not displaying that there's not enough resources. I've tried to trace it but can't see from a surface level detection. My first hard bug. I'll have to do some deep diving, but for now the behavior is correct...the building isn't being created. Just something with not displaying the text. I've ripped out my entire research system. The display and the data model. I've come up with a new idea. We're going to hunt and find collectible items, and slot them into slots on a research screen. The first research I have is the Storage building, researching a way to store resources. It's not game breaking or anything, but I was messing with some of the polish for the images and came up with this (Mind the placeholder art. It will likely be some sort of cube with shaders in the future): As the Macguffin gets closer to it's storage slot, it starts to shake, and then we will have a slow hum start to build up as the object gets closer and closer, with some effects and shaders when we've slotted the item in the research slot. This act of putting the storage macguffin into the slot unlocks the storage building, and that works fine. As for the refactor, I've decided that my most likely best course of action now is to have a different class for every dialogue and research in the game. I've tried to come up with ways to have a generic research or dialogue class that somehow knows what it's supposed to unlock. But I need custom behavior for pretty much every dialogue unlock and research unlock, that I've just gone with a separate class for each one. Will that mean I'll have 100 files? Yeah probably, but I can't think of any other way to deal with it right now. Plus, this allows me to unload all the strings of dialogue from memory once they're been read, which is nice I guess. Either way, we are moving on. I now have the entire beginning of the game scripted out, with each building being unlocked by actions and dialogue, and the storage building being unlocked through research. Next step is to code up humans and begin to work on that system. I will also work more on my research screen. I really like this idea of having slots and putting items we find for research, instead of just clicking a button. There's a lot to polish there.

KrisWolfe

KrisWolfe

 

Communicator up and running

Hey all, I just got my communicator working. It's not glamorous art, but it's good placeholder for now. I have 4 counselor robots for the 4 pillars of the game: Build, Navigation, Research, and Military. The communicator blinks a button when we queue up a dialogue. The screen will then fade to the dialogue screen, where we display the character portrait, and run through the dialogue. Lots of placeholder art. We run through the dialogue, we have lots of choices in the bottom portion of the screen when we get to options, and when it's done, we go back to the last screen we are on. The DialogueDB keeps a dictionary of all the dialogue in the game, and we send it an enum to pop out the dialogue. The dialogue is queued with the respective counselor button, so if we get 3 messages at once, we will run through the dialogue when the player wants to deal with the messages based on which one came first. If there's more dialogue, the communicator will pop back up and the player can choose to run through the next dialogue. So the next part is something I've spent all week trying to figure out how to handle. How does the game know when there is dialogue? I've thought alot about the observer pattern, but how do I hook up the observer pattern all throughout my code? I want dialogue to trigger when certain events happen. I want dialogue to trigger when you max out your resource stores and lose material. I want dialogue to trigger for ANYTHING. So how do I have my code listen in throughout without using monobehaviors and also not violating SOLID principles or the state of objects or anything that could possibly go wrong? I came up with an idea to have a DialogueTrigger class. This is something I think I'm willing to sacrifice some SRP by having these triggers inside the classes of my Colony Map, or map tiles. For instance, if we max out our storage, and we are now not being inefficient, we will call the dialogue trigger class. Inside the trigger, it can count down, or if it's just an event, it will trigger the event. This will send a message to our dialogue database to trigger a dialogue, and then my dialogue system handles it from there. So I can have these "portals" with dialogue triggers. The code doesn't know what the trigger is, it just sees a trigger and calls it. The class itself decides when to send the dialogue. I really can't think of anymore elegant solution, so this is what I will be going with for now. Visual Studio is actually pretty good about keeping tabs on when these dialogue triggers are called from, so if I need to remove them, I'll have an easy reference back to them. So the first step to game flow is to get these dialogue triggers working, which honestly shouldn't be hard, and then start polishing the game flow from start to finish...what do I want the player to see or do? This will be the next step to getting a playable prototype to start running it by some gamedev forums.

KrisWolfe

KrisWolfe

Unity Combat System in place

Hello World! This weekend met the completion of a goal I thought might take a month or so. I used Unity's ECS system to get about 10k enemies march towards the center of my map, and I had buildings created that could fire projectiles at them and kill them, throwing them away from the projectile. It has a lot of room for improvement, but it was really cool nonetheless. The turret I made is actually hybrid ECS. It uses the same Object oriented framework I have for the rest of the buildings, but I discovered I can just make an entity inside my original classes. So while the combat ECS systems are in different files, the Turret Building that I created, that I can easily inherit and put into my code, can create and destroy a single Turret Entity that my other combat systems are waiting for. So if the building goes offline, it can destroy the entity, and if it's online, it resets the Entity. And then it can check the entity to see if it fired, or let it know it can fire. Easy stuff. The Combat System is seamlessly added into my already existing framework, and I haven't seen any bugs. What I do need to do, is configure the FindTarget algorithm so it doesn't have to go through every single enemy...have some kind of quadrant system that it tests to see if there are enemies in range if they're in a nearby quadrant. But it's currently running at 100 frames per second as it is, so we will optimize in a future update. The Green Dots are the entities with a simple green texture mesh. The black hex is my turret building firing projectiles at the enemies. So with this system in place, what I really need to do is just start filling the databases with stuff to do. I need a story, I need dialogue, I need plot devices, and I need research in order to get to those places. The first thing I need is characters. I'm planning on having a "counselor" for each of the systems I have in place, so 4 counselors, with varying personalities. Luckily, if I'm strong in anything, it is writing. I'm going to make a system where I can pause the game and have characters converse...this is actually only important in big events, like the beginning of the game, and when something important is happening that can kill the player. So with this in place, we then need to define what the research tree will look like. My process will be to see what I need, and make a research for it. For the first few researches, it'll only take time, and to fill this time I want to have dialogue with the characters in order to explain what is happening. Why are we here, what is the plan, how are we going to accomplish our goals. This will all change as the game goes on and all the events start to take place, but I want to get a sense of immersion. We do this by letting the player explore. So that's next up on the agenda...begin to piece together these systems I've built.

KrisWolfe

KrisWolfe

 

Research Screen Complete

I honestly thought this would take me all weekend. But here we are. New button the tool bar. Research! Not much to look at the moment. We have faded buttons for research that is not unlocked, and we have buttons for available research. This is clearly not going to be the researchs in the game, this is simply for testing. These buttons are hooked up to a database and enum that fills the buttons with whatever is in the database. I don't really want to spend the time to have it dynamically create the positions of the buttons, since I don't think it needs to be randomized or something...the research screen will likely be the same everytime. However, the order of the buttons in Unity will be the same, which I can use to fill the correct links to the correct research. So, what happens when we click a button? The button fades and is not interactable, and a timer starts. The button actually sends a command to the data layer to handle the command, which is to switch research to whatever research I send down to the data layer. It then sends the research for my display to listen to, and on update it watches the time to unlock...what happens when the timer runs out? The next research unlocks, and the Fire button is now permanently disabled. Awesome! The timer also continues when on other screens, since the data layer isn't apart of the display layer, and I can set the display layer to inactive when it's not needed. So to polish this, we would need a tooltip to see requirements of research, maybe hints as to where to go to unlock research and so forth, and definitely things like multiple researches unlocked by a node or one node unlocking multiple researches...I want to section research into 4 categories of the 4 systems in the game (build, navigation, research, and combat). And we can also allow the player to scroll around and view the research tree, zoom out, so forth. But right now this works perfectly. I can change the research quickly, and none of the display changes the state of any of the research...it simply sends a command down to the data to ask them to switch, and it makes sure it is a valid command. So we're onto the last system. Combat. In this, I wanted to play around with Unity's ECS system, see what shakes out. I will need a new building of a turret, to defend our colony. I expect this to take awhile, since I've never used ECS, so sounds like fun. Stay tuned!  

KrisWolfe

KrisWolfe

 

Still alive, still deving

Hi All, It's been awhile, but progress has been moving forward. My navigation screen is complete: I wanted to try and do something different than just make every square a different object like I did with the hexes. For this screen, it's all just one big object, and when you click on a square, it will highlight it, and then output the grid coordinates as a string: Part of what you are going to do with this screen is to explore the planet. The planet can be different sizes and will automatically adjust size and get the grids working:   Pretty cool. We can also send drones out to the squares...Right now that doesn't do anything, but I have it hooked up to a database that I can start to fill that it can retrieve, whether its resources, tech, or plot devices. If you attempt to send drones when you have none built, you get an error message. But once you have drones built, you can send out as many as you want. This can easily be expanded to add different terrains or searches for resources.   As for the build screen, we've updated it a little bit: I've shoved the building buttons under "Build", and there's a check to see which buildings are unlocked, which then immediately adds it to the list of options. We have a stats Display for each of the buildings that listens in on a building and displays their time to produce resources, and also their next maintenance cycle which will drain resources. This all needs balancing and the amounts I have right now are just for testing, but it works. The number at the bottom is the amount of drones available to send off, I'll be moving that somewhere else. And the explore button takes us to the nav map. You can also shut down buildings with the "online" button, and the little green light turns off on each of the buildings. They also automatically shut off when you are out of resources. So that's where we are at, I'm almost done with the research screen and data model, which is pretty simple, and then from there we can start doing the military side. I want enemies coming from all directions, so that there is an actual downside to building too many buildings...your turrets can't cover all your sides and they will be expensive. I'm also to the point where I need to start polishing art assets and sound, and I doubt I will be able to do that myself. I've tried. So I will likely start hiring someone to produce those for me, so stay tuned. My goal is to have a great main menu and character portraits for the characters. I want the beginning to be heavily scripted and then slowly let the player go as they unlock the explore and research options.

KrisWolfe

KrisWolfe

 

Coding a Mission System

I finished a dialogue system so that it will take any number of dialogue sentences that require a button press to move to the next sentence, then can handle any number of dialogue options from that choice. The map can loop on nodes and really go anywhere, along with code to run once the dialogue finishes.   Having set that up, I wanted to work on a mission manager. I wanted this to be completely divorced from my other managers and just listen in on the other systems. It would, unfortunately, need to know what's out there, but that's a simple compromise for now until I can learn to pass events and delegates through methods. The mission manager is nice. For now I have two types of missions. The first is to stockpile resources, the other is to build a number of a certain building. I quickly discovered some powerful features of properties. I realized that I did not need to define a delegate for every event. I defined one delegate, which was resource changed, that passed an integer. I then declared an event for each resource, then had a a small method to invoke the event. But here's the cool part. I put this method inside the setter of the resource integer. So now my mission manager checks which resource it needs to listen to, and then registers for the resources event to a simple method that updates the mission text. So everytime the resource count is changed, we automatically update the on screen mission text that the player sees. No update needed. I really like these types of solutions. The mission system is ready, the dialogue system is ready, and the building system is ready. Time to polish with animations and fill our databases with assets.

KrisWolfe

KrisWolfe

 

Creating a dialogue system

This week I wanted to start working on story elements. I decided to create a system for any game I make where I can easily navigate a dialogue tree...and one that is dynamic and loops on itself as well. I just finished it. It does not look pretty at the moment, but the next step will be polishing it. We have 5 classes for this and a struct, although I think one of them might be redundant. Firstly is the dialogue manager. This will be listening in on the game and load the dialogue system when it is activated. The screen will go dark. It will then load the dialogue from the dialogue database class. Once loaded, it calls a method to load the next text response. The Response is a struct that contains the NPC Name and the text. If this Queue has text, we will load the text objects on the screen with the name and the portrait of the NPC and what they said...there will then be a continue button to move to the next Response in the queue. Once the queue is out, we go through and instantiate our options. This is dynamic and created in code, with listeners loaded in code. The Options area is a grid that will line up all the buttons for me, and it can handle however many I want to give it. I need to have it resize things as the options grow, but for now it can handle 9 options without any issues on different screen sizes. Once a button is clicked, it cleans up all the listeners on the buttons and gets rid of the buttons. Later, we can implement a spawning pool here so that we don't constantly destroy game objects. Each button also will update the dialogue map on which node it gets sent to. The dialogue manager then loads up the responses from the Queue of the new node, and we continue on. So now with this sytem, the only thing I need to do to add dialogue is to place it all in the database, and then add a listener for this dialogue trigger in the game somewhere. Super cool stuff. Next time I will have animations polished, and have the UI look a little better to be able to show it off. I'm pretty happy with it.

KrisWolfe

KrisWolfe

 

A bit of a sidestep

So, normally I tell myself "focus focus focus" and work on this game I'm making. But I'm starting to think I bit off more than I can chew. Which, from reading other people's blogs, is pretty normal. This project is extremely ambitious, and I'm getting burnt out constantly. I keep getting ideas for other things. So I decided to let myself work on something that I think I can easily accomplish, as long as it works on a skillset I don't have...specifically working on art and events/delegates in C#. So, for the past two days, I created something I'm pretty proud of. One of my favorite games as a kid was a game called "Alien Legacy." It was created in 1994 and it did not do well. It was very buggy and the UI is very obtuse. The mechanics of the game are hard to figure out, and don't always work the way you expect, specifically orbital mechancs. It's also very hard. It didn't do well. But I absolutely love it. It's hard sci-fi, with your ship arriving in a new solar system with the crew waking from cold storage, finding out the earth was wiped out by our xenophobic neighbors.  You are all that is left of humanity. You have a sister ship that should have arrived in the solar system before you, but there's no contact. You begin colonizing the planets, discovering the fate of sister ship and running into all kinds of humanity ending threats. You can build as many colonies as you want, explore the planets of the galaxy, limited by fuel capacity and time. You create robots and slowly bring people out of cold storage until you reach your max. If you don't do things fast enough, cold storage malfunctions and you lose half your crew. It's really a great game if you can get past the bugs, and it's abandonware. So what I wanted to do was replicate the base building side of the game.   Here is what we start with...a simple airport. We have 4 buildings to create. Storage isn't apart of Alien Legacy. Clicking on any of the buttons on the bottom highlights areas that we can build...Alien Legacy uses a square grid, but I wanted to mess around with a hex grid. As we build, the grid grows. I don't create the entire map, I create new hexes as we expand, which means we can build infinite games as long as things don't crash from overflow. Construction takes real time, and when they're done they will sprite swap to the regular sprite. We can also bulldoze, and it will sprite swap back to the construction swap and then remove themselves back to the none sprite.  And lastly, I have green floating text that spawns and fades out and rises everytime the inventories increment. This only took me a handful of hours to make, and I love it. This base game I have here can go in so many directions. The inventory is correctly incrementing, I just, ya know, need to do stuff with it. So I'm really happy to be able to use these skills, especially since everything is based on the observer pattern, where the data model for everything is separated from the display model. When the data model changes, it invokes an event, and everything subscribed to it will change. So even though I'm not working directly on Fraud Simulator, I'm still expanding my skills and enjoying the art of game making.

KrisWolfe

KrisWolfe

 

A working game

Huge milestone passed just now. I have the barebones of a game, finally. I started this journey in March, with literally no knowledge of C# or Unity, only a passion to get a game that I've always wanted...a business simulator that lets me do what I want to do, instead of just focusing on businesses. Please ignore the bad and unpolished graphics, that will come with time as my engine is up and running. So first of all, I have graphs for the price of goods and jobs. The agents in the game have some kind of AI, where they lower their goods prices if they don't get sold and raise them if they do. People seeking jobs also do the same, lowering their salary prices if they don't get hired and so forth. Companies and agents will try to get a good deal first, but some will have a chance to become impatient and just take the best seller or buyers price. This is also going to be adjusted as we go. Here's some interesting stuff: First off as you can see, we start up a company. I instantly assigned $5k to any new company to give them a little starting cash. The 1 employee is the player, the CEO. The Orange Recipe is randomly assigned as a farming license. Depending on what license the company starts up with, they will be assigned one of the recipes if they're a producer. If they're a retailer, then they will have a license on what type of goods they can buy and sell...restaurants and supermarkets are the only retailers at the moment. I don't have service companies up, but they will be up and running eventually. Next up is the market. We have a company and recipe, we need some employees. Here's the Jobs market screen. I don't have axis on the graph just yet, but the current price on the far right is at 27.06 salary per hour for farmers. I run the economy through 100 days when the game starts to give us some price history. The graph is a little bugged, not able to be all on the screen, which needs to be polished, but I love that farmers are so in demand. The salary starts at $10 I believe, so as you can see, there are 3 companies trying to get a good salary for farmers, and they have such a wide range of salary bids. It appears all the farmers on the market are hired, which makes sense, because farms are the most basic producer in my economy and there should be a large number of them to support the food. The market sets the price of the farmers. I think one run through the salary was at $100. Berries are on the downtrend here. Farms that produce Berries are probably in huge amounts of debt since farmers salaries are so high. Goods are chosen and consumed based on consumer preference, which is random at the beginning of the game. Agents decide on a restaurant to go to, based on market share of the restaurants/supermarkets. They then choose to either eat the highest consumer preferred item at the restaurant/supermarket, or they eat the cheapest. So some goods just don't get selected, and this drives their price down since there is no demand. I ran the game through a few more trials until a farmer was available. We can see the farmer setting his salary for 16.24 per hour, while a bunch of companies are setting their bid orders wayyy above current market price. Interesting stuff. The little x button is dynamically made and clears out the order if clicked on, so we can have multiple orders but there's really no reason too at this moment. Now we have two employees, one farmer and us, the CEO. let's get us a contract to sell apples. Hey good news! Apples are in demand and there's a supermarket that is looking for a contract. We immediately scoop that up. We now got a contract. The length is currently assigned randomly to give the market some chaos so that all the employees and companies don't expire all at the same time. Our employee is now making apples, and if you have a contract for those goods, the inventory will be remitted automatically to your contract and you get paid the price per good...which for some reason isn't on the screen. Need to add that. But unfortunately, that isn't happening at the moment. Inventory count increased by 8 again, and for some reason the contract length went down by two days...yeah we got bugs. But this is exciting stuff! A working market, orders, contracts, employees, jobs, salaries, recipes. Great stuff  Pretty important milestone for me, and I'm super proud. Now to get this game to a state that OTHER people want to play. First off, I need to get the code so that we can actually work for another company instead of owning a company. Secondly, we need to hook up the scheduler so that we can start utilizing skills like "manage employees" and "work at job". And do some bug fixing.

KrisWolfe

KrisWolfe

 

Testing out Generics

Hello world. Been a few weeks. I've been exhausted. I got a new promotion at work along with a move to a new apartment. I have begun worrying about work life balance, and the last thing I want to do when I get home is work on my game. But fear not, I have been dabbling and I've solved the issue I was working on. Specifically, how to handle current orders. The orders don't execute until the next day, and there's just so many things to handle. What if I want to cancel the order? How do I keep all the text in line with each other? How do I dynamically spawn a little red cancel button to cancel the order? How do I keep the button in line with the text? How do I remove the button and text from the screen when I execute the order on a different screen? What if I try to execute a market order when there are no contracts on the market? Alot of this I solved by learning the Invoke() method. If I tie all the cancelling to the button, I can actually execute those listeners in my code in other places with just the invoke method. It basically pushes the button. So after I've resolved the market order, just invoke the cancel button and it cleans up the current orders list and removes the button from the UI screen. Pretty cool stuff. I also figured out how to add event listeners to the button and also can dynamically remove them for garbage collection. So, it's alot to take in, but it's super important for later stuff. What gave me this idea was a youtuber named CodeMonkey. He has some awesome videos, and they're perfect for me since he makes management sims as well. He also has some utilities I want to use, like how error messages pop up next to the cursor as floating text, and his utilities can do it in one line of code. Definitely going to be combing through his videos. So what's next? I just linked the market orders to the market and tested them. So now I have immediate contracts coming through for companies the player owns, but none of that is displayed. It's time to rework the company info screen to show employees hired, contracts we own, how long the contracts are for and what price the goods are for, our current inventory levels and cash on hand, and other stats we want to know as a company. This screen will lead to the company hierarchy screen, which we need to go over and polish again. I'll probably rip out all the code for the dual objects that I had before, and just have one object representing the employees. Before, I would have a "holder" that would snap a "employee card" to it and would detect if it was removed and adjust the tree if it did. Instead, we're just going to have sticky notes and let the player drag "string" to each sticky note and rearrange the tree however they want. When you mouse over a sticky note for a second or so, it'll display a manilla folder with a bunch of info on the employee. I think this system will be much better than what I have. As for generics, before I had different market screens for jobs and goods. Now we have service contracts we have to worry about as well. But I want to build my code so that it can handle whatever I throw at it. I want market orders to be jobs, goods, or services. So how to do this? I think Generics is the way to go. I haven't researched generics as much, but it is something I need to learn to do, and I think this will be a great way to handle it. Besides, who knows what else I want to do in the future. I can't really think of anything I want to show off in markets, but maybe something else will come up? So that's the road forward, as much time as I can allow. Without unpacking anymore, I'll have more time to work on the game. Get the company info screen back up and running to display company stats, polish up the ol' hierarchy tree, and get market screens working with generics. That sounds like a month or two of work. Looking forward to it!

KrisWolfe

KrisWolfe

 

Quick Update: At a wall

So I have the economy running and graphs are up and showing me that I have a bunch of bugs in my economy code. Some goods are being bought but others are not. Why? I don't know, but the goods that are being bought are definitely working. But I'm stuck at something stupid. Player orders. It's one of those things that if you don't have in your game everyone wonders why, and it's super small and its taken for granted, but it's kicking my ass. Basically, to order a good, you need to know if it's a market or limit order, which good, whether it's a buy or sell order. But also, I need to spawn a button in order to cancel the order. So do I make a class that takes a button in? Where do I place this button? How do I handle this iteratively so that I can have multiple orders? How do I know if a order has been executed so that I don't display it again?  How do I dynamically spawn a button that links to only one order? And it's so simple. When I place an order in my market exchange, I display a current order. Then I click on the button and it cancels the order. This is absolutely kicking my ass, and it's absolutely not fun to code and is "work". So I am not motivated to work on it in my spare time. Plus I am moving next week to a new town, I just got promoted in my database administrator job, I'm exhausted everyday when I come home. This is kicking my ass. I want to work on other things, but there really isn't anything to work on besides polish. It's time to do the drudge work. I've been putting it off for too long and I need to polish this UI before introducing new mechanics. So super annoyed right now. I really don't have an idea of how to accomplish this task. Luckily, I found a cool Youtuber named CodeMonkey that makes the types of games that I'm working on, so maybe I can dig through his library and find something I'm looking for.

KrisWolfe

KrisWolfe

 

Refactoring and Polish

So the time has come...I need to polish the UI and user experience. I finished up the economy and I'm pretty happy with it. It seems stable. I haven't run it through 10,000 turns or anything, but its workable. So, we have 3 times of companies, we have licenses that easily determine what category of companies within their classes they will be. Now we work on Art. I played a game that came out recently, and they had a board where you could drag around elements and connect them. I realized I was completely overthinking my Corporate hierarchy screen. Instead of having "employee holders" and "employee cards", I was just gonna have employee cards. Instead of worrying about where to place all of them and having it ordered, just let the player figure that out and save the positions for when we load the screen. Let the user drag them wherever they want and let them connect with whoever they want. As for the art for the corporate hierarchy screen, I want a white board with post it notes with the employees name on it. When you mouse over the sticky note, a manilla folder will pop up and you can peruse their stats and how long they've worked, their salary and a little picture of them. I spent about an hour in photoshop to make my own stickynote art: and I'm pretty proud of it. I don't think I want a pixel art aesthetic for the game, but pixel art helps put in the area of what I'm looking for. I figure I'll just add a few different layers to about 5 images so they look a little different when placed. So this will replace the placeholder art I had and completely get rid of "employee holders." Might be fun to organize, who knows. But I'm kinda sick of looking at the corporate hierarchy code, so I went to redo everything else. Before, I had it where you could choose a recipe, but licenses completely streamlined all my code, as long as I don't have to show recipes. I might just let the player decide which recipe they want to do within their license, and can pick and choose and respond to market conditions. Might have NPC's do that as well, have them check after their contract is up to see if they're making the most profitable good in their license. So, what I spent most of my weekend on was the market screen. Here is the old screen: I don't have any labels up yet. Was waiting until I polished and figure out where I want everything. The left side of the screen shows the bids and the asks...right now they are centered around the price of $10.00 per good. The left side first selects a company that you own, and then the buttons below will go active and not if you actually need the good that's selected in the top left. Since fish isn't required for Peach, you can't bid for it. It SHOULD be disabling the ask as well, but hey, no one's perfect. The current market orders is in the bottom right panel, but I don't have any currently up. So, this is nice, but it doesn't give us really any information. And it sucks. There's so much unused space. What I really want is a price graph, showing the price of the good over time. So I came up with this: Of course, I don't have labels up yet. But that's actual price data from each day. I have a static dictionary that holds a list for each good, and it keeps the last 100 orders for each good. Then we run it through a line renderer and display it on a panel and viola. There's a company drop down that is hidden when you don't own a company, which I don't at the moment when I took this photo. I need to put in a button or selector for market/limit orders and buy/sell. I want the "Place Order" button to be contextual instead of the 4 different buttons from above. In the middle of the two dark panels will be the last price that the contract was obtained for, with the ask prices above the current price, and the bid prices below. RIght now there are 3 ask prices, which means there isn't any demand for Apples and it drove the price down. The price shot up to what looks like $20, then drove down to $5. I don't plan on having tick marks...but I do want a text label for the highest and lowest price on the graph. The current price will be displayed between the prices and labeled correctly. The current orders will be at the bottom, and I think I'm gonna have the player's order history in the bottom right. Unsure at the moment. So lots more polish to go, but now we're getting some actual data on how the market is fairing. I want this screen to act for service contracts and job contracts as well. I need to combine the classes somehow, but they use completely different numbers for what they do. The prices work the same, and that's all I need from the contracts in order to display them. So I think I might make an IGraph interface to chuck on them, or maybe learn how to use Generics. Anyways, the polish and art has begun. I've never made art in my life, so it's a whole learning process for me. Photoshop is great though, and pretty intuitive to use and figure out where the things I need are. I probably need to spend some time with Youtube like I have with C# and figure all of this out. Next week hopefully have this screen completely polished and functional.

KrisWolfe

KrisWolfe

 

Markets are done, moving to Service Companies

Huzzah! Not much to really show since everything happens in Debug.Logs and code, but markets are done. So what can retail agents do? Right now they can choose between restaurants or super markets...both of them have a different lists of goods. The restaurants will have the more complex good types that cost more, and supermarkets will have cheaper goods. Eventually I will have retail agents responding to market conditions and possibly switch Licenses. That's for another time. When a market has a positive inventory, they will put themselves available to the market. A list will be updated every day in the game that gets the total market share of all the companies, and creates a random list of markets based on that market share. This only happens once per day, and before agents start choosing markets to eat at. If you have 40% market share, you will have a 40% chance of being picked. An agent will come and pick a market, and then either decide on picking the most popular good  available at the market, or the cheapest. Once decided, the market will feed the consumer and exchange cash. The consumer's hunger goes up based on the good and how well the employees are at their job. If a market successfully feeds a customer, their market share goes up, so being good can snowball. Since this is percentage based on the market share, your market share will go up quickly, but as time goes on, since the change is always a fixed amount, that fixed amount will increase percentage wise less and less. Everyone starts with an integer of 1-10, and it will go up 1 each success. So increase of 10 to 11 is a 10% increase, but a 100 to 101 is a 1% increase.   Anyways, I've unit tested it and each part works, and I'm happy with it for now. The player will have the option of just going wherever they want. For now though, we move on to the last type of company. Service Companies. Service Companies will probably be the meat of the game when all the systems are in place. They aren't going to interact with Goods. They are going to provide services to companies and to the player. Most markets are usually service based. To get them online and working with my company, I really just want utilities up and running. As companies hire more employees, they will need more utilities or productivity will be hindered.  We will need an ISP utilities which I'm bundling with electricity. They will need IT services to keep everything running. Janitorial services. Mechanics. There will be builders that create more real estate for companies to open more businesses. I will have goods that aren't for eating, but required for construction. Legal services for when I implement a justice system. Accounting services for companies to get their financials straight. Customer service to make sure we don't lose customers. Marketing companies to increase market penetration and market share. Sales forces to get contracts cheaply. Service companies require experts, and that's basically it. I will eventually put supplies in the game like pens and pencils, but keep it abstract with just a "supplies" account on the ledger, and periodically decrement it. Productivity will suffer if the supplies account isn't kept up. I have the code architecture in place for service companies, so it should be a simple manner of creating the Licenses and the Job Types for them, and then getting Service Contracts up for their services. Penalize companies if they have a certain number of employees and they don't have required services. Hopefully have that before the weekend is done. But the goods and contracts are all interacting and moving. Once I have Service companies up I will work on how the player is going to interact with all of this, and start polishing the UI and art to get it ready for Alpha!

KrisWolfe

KrisWolfe

 

I changed my mind. Licenses.

This weekend I probably put in around 20 hours with my economy code. I ripped up everything and slowly rebuilt it in a new class, transferring over logic. My controller code is now just a flow controller, and all the logic is contained in the actual companies and contract logic. So what can we do? Both companies and agents create job contracts, and put them on a market. Sometimes companies decide to just take the lowest contract from the consumers as far as salary goes, and sometimes the agents will take the highest paying company contract. Those contracts get thrown into a active contract list, and the list executes the contract. What the execution is left up to the company's internal logic based on what type of employee it needs. So far the only company I have is producers, or manufacturers. They have a recipe, and they hire employees to execute that recipe. Each recipe has different conversion times, or time it takes to convert from raw materials to finished goods. I have some goods that come from nothing, and some that require other goods. Apple Pie needs Apples. These companies will create Goods contracts with each other, sending off their inventory for an agreed on price, and they change the price of the contracts everyday that it doesn't get filled in order to be a more attractive offer. I also have productivity in the game, but it currently is just set to 100% until I decide what I want to affect it. Contracts expire, thrusting agents back onto the job market. Agents and companies both change their prices if they do not get what they want. Agents have the chance to apply to any job instead of just their highest skill. I have multiple skills now. Each of them show up on the market. And the best part of all, it works (at least as far as I can tell). So what's not in the game? I took out hunger for now, because I don't have a place for agents to shop. I don't want producers to sell goods directly to consumers, I want them to act like vendors and distributors. I need retailers. I don't have a way for consumers to die from hunger, or go shopping. So that's what we're going to fix today. So, how does a company know what type of employee to hire? I want shopping markets to hire retail clerks, and restaurants to hire cooks and waiters/waitresses. Right now, producers hire only "Good Makers". I thought that I didn't really want to differentiate between farmers and iron workers. But now I'm rethinking all of that. So producers have "Good Makers" hardcoded into their logic. But what about retailers? Both shopping markets and restaurants are going to look identical. I don't want to make a separate class for them. Their class is just going to be "RetailAgent". They just have input contracts, they don't have output contracts. They don't send goods anywhere. Consumers come to them to consume their goods and pay for it. So how do I differentiate these types of retail agents within their class, but reuse all of their code? I decided on something called "Licenses". Inside this class will be everything a company needs to hire employees. It will be an array of what skills are needed, so we can have multiple jobs needed. I will have a licensing database to hold all the different licenses, and when businesses are instantiated, they will decide then what license they want. License to sell alcohol, or marijuana, or italian food, or a shopping mart. And depending on the license, it will tell it what type of input goods it needs. On top of that, we can use licenses to differentiate between farms and iron mines. So there's a bunch of different possibilities. We can even outlaw licenses with a government system in the future. Anyways, all good stuff, and I have a clear road now on how to have infinite possibilities of company types without having to have a billion different classes. I'll have 3 classes, Retail, Service, and Producer with 3 interfaces for each, and then licenses that tell them what goods and employees they'll provide. That's the focus for this week...get retailers up and running and hunger back into the market. Also my significant other told me that I needed art very very badly, so I might start researching what type of unifying aesthetic I want for this game.

KrisWolfe

KrisWolfe

 

Differentiating NPC and Player agents

The refactoring of the market code is trucking along. I've learned so much about C# and programming since I first wrote it, and my design has changed since then, so I'm using the old pseudocode as my template while rewriting the class itself. It's not really hard. My new code looks like this: Compared to my old code where I would loop through the agents List and then loop through all the companies that the agents owned...now that's handled internally to the class itself: This solves one of the things that was rubbing me wrong while coding. I hate casting. It feels so wrong. Now, instead of telling the market code which type of company it is, the company itself would know what type of company it is and just do what it needs to be done. The function "Beginning of Day" will be different for each type of company. The only thing it really needs is the properties from the market class, which I pass along in the call to the internal functions. So now we have this delegation of tasks to internal classes. I ran into an issue with the "GetAJob" function. Before, it was just abstracted out to the companies to decide what the job was. But with an actual economy rolling along, we're going to need to differentiate them. We also want NPC's to have different productivity based on how well they are at the job. We start with the simplest type of companies. Producers. These are your iron mines, or farms, or anything that creates goods from "nothing". In the real world, we have mineral rights and finite resources, but I don't think I really want to go into that. So my base company will just create goods, with their only costs being utilities, rent and salaries. No licenses, no natural finite resources, no fertilizer. Just creating goods from nothing. So, we need a job type of "Good Maker". I don't want to differentiate industries at this level. I want you to just start up a company, it has to buy a recipe from lets say the government, and then start making whatever good that recipe calls for. So the job is just to execute whatever recipe we have. So what if we have two recipes? I think I'm just going to disable that option, force the player to buy a second company if they want a different recipe. It doesn't really add much to "fun" or the economy if one company can have multiple recipes. Besides, in the real world you want to focus on core competencies anyways. So right now, the recipes require a certain amount of employees. Once you've hit that threshold, it starts producing the good. What I want is that the more employees you have, the faster you create goods. The better an employee is at creating goods, the more goods they make, and so on. Is it realistic to make 0.1 of a good everyday? Why yes, it is...in manufacturing companies, they have three inventory accounts: Raw materials, work in progress, and finished goods. So half a good would be a good that is halfway through the conversion process in the work in progress inventory account. So it makes sense. So you keep hiring employees while it's profitable. What if an NPC doesn't have the skill required? Well it's created in the skill set and they start earning hours. Their productivity will be a function of how many hours they've spent on that skill. So now back to the function "GetAJob". What do we want an NPC that doesn't have a skill to do? In the real world, most people just get a job in their best skill. But that's not always true. Sometimes people just want to do something new. So we want a chance for an NPC to go and get a job for something he's not really qualified for...maybe lie on the resume. You know, all going back to "committing Fraud". So what I think I'm going to have to do with NPC's, is that they don't actually check the skill of the NPC that they're hiring. People can slip through the cracks. And this allows for chaos in the skill system, allowing NPC's to have all kinds of skills instead of just whatever skill I assign them on initiation. I want to think of NPC's like loot...they have 2-6 different skills, and they can roll higher productivity on skills, and eventually earn higher skills through hard work anyways. Or, god forbid, a lowly entry position employee somehow getting to be CEO of a company. So the market decides demand, and NPC's will adjust their asking salaries on how that goes. Businesses will also be evaluating their NPC's, and if they aren't profitable, they'll likely be fired. Layoff's and what not, which should be pretty easy with producers. You check what the market price for a good is, you can easily calculate the marginal cost of each employee, and if they're unprofitable fire them. So we have this balance of NPC's getting one over on the companies that hire them by obtaining a salary that they might not deserve, and companies periodically checking the marginal cost of those employees. But now, we have our first branch off between NPC's and players. None of this really applies to players. They're not going to get randomly assigned skills. The player choose what job they want to do, and begin earning hours in that job. We will also have free time to work on skills and get better to be more hireable. I don't want the player to be forced into owning companies, they can just work for businesses and focus on their skills and leisure time. So now we need NPC Skills, NPC Skill Database, and NPC Agents that are different from player agents. Interesting stuff. Looking forward to getting this up and running.

KrisWolfe

KrisWolfe

 

Refactoring the Economy

The data model merge took place. I broke the code and then rebuilt it. This is actually more fun than I imagined. So, now I'm working on refactoring the market code to allow it to be extensible as I add in company behavior. All the market decisions were being handled inside the market controller class before, but now with more knowledge of C#, I'm moving it to basically a "flow" controller. The main loop in the game turn is basically 4 for loops...beginning of the day, middle of the day, end of the day, and finalize. The beginning of the day I build up the lists that I need...which markets are available for consumers to eat from? Who needs employees? Who needs a job? The middle of the day is where the player's actions gets executed and all the contracts get executed. The UI will collect player actions and here we inject them into the economy. The Job contracts will perform their tasks, pay their employees, remove themselves if they've expired, and send goods to other companies based on the terms of the contracts. Also we randomize the order of the lists so that the same agent doesn't get first mover advantage everyday. The end of the day is when we execute commands for the AI. Companies hire employees, get contracts, decide on new states for the AI. Finalize is where the economy goes over everything and updates its average market prices and market shares based on the actions of the day. So my old market code was 500 lines long. Now I'm going to have the actual companies decide what they need to do. Retail companies and manufacturers need to do different things, so I'll have an interface for them that basically say "BeginningOfDay()" but they will be done differently. Interfaces are clean and nice for this. I also ran into an issue when I was merging data models. I have two interfaces, IAgent, and IEmployee, that are both on the ConsumerAgent class. But if I make an IAgent, it doesn't have access to the IEmployee methods. I started just copying the methods I needed to the IAgent interface, but then I realized I was violating the DRY principle (Don't repeat yourself). I discovered that IAgent can actually implement IEmployee interface, which is hilarious to me. Interfaces are so nice. I also ran into another issue with interfaces. Production Agents and Retail Agents both have an ICompany interface, which means they both implement a "HireEmployee" method. But it's the exact same method. I'm violating DRY principle by just copy pasting the code. Then I realized I could use both an abstract class Company AND implement interfaces. Mind blown. Seriously. So now when we have financial statements and accounts like "cashOnHand", I don't have to keep copy pasting that property to all these classes. So, pretty excited to get this code refactored and working. No pictures for awhile since this is all just code, but hopefully show some different employees and companies off as I get them off the ground and rolling.

KrisWolfe

KrisWolfe

 

Moving on to clear my mind

The iteration is going well with the tree. I have the bottom layer finished. I can now drag and drop low level employees into the tree and it grows, and if I take low level employees out, it clips the tree. Dragging Oliver Torre into Olivia Escalona's team As we can see, got a bug with Sophia Lamarche being duplicated. Deal with that later. Now we drag Sophia into Olivia Atencio's team And voila, the tree grows, and adds more empty slots to drag in employees. If I drag them out, it does the reverse, and it's a pretty nice system. I think I have some memory leaks with delegates, but I'm exhausted with the corporate hierarchy tree and I want to move onto something else, solve some other problems, and write down some ideas when I return. Some of the problems I have with the tree is that it doesn't do odd numbered sizes correctly. The display of the empty slots is funky for the manager side of the tree. The bottom layer is easy, I just reserve an empty slot in the tree for each team lead. But the team leads and managers are averaged over their employees and placed there...so where do I place a new manager slot? If I place it directly under the manager, what about if I have an odd number managers? As shown here: So, maybe I can put them to the right or left of the tree? But how does a manager know what underling to place? I want infinite tiers, you can just keep growing...how would a manager know to spawn a manager slot instead of a team lead slot? That's not an easy solution. And then we have to detect where to place them anyways. I have a few ideas, and I'm not exactly sure where to go yet. I could just have all managers not care, and don't put a name to the slot, and let the slot detect what was placed in it. If the user wants to pay an extra 100k salary for a team lead, they can hire a manager and throw them in. I could then have some kind of array that counts the amount of tiers, and places tiles in their tier sequentially. Another idea that I'm leaning toward is to look at how actual corporations deal with layers of management. Oh look, they just make up unique titles for each layer. Which brings up a light bulb. I could generate random strings to create tiers of management. I could even theme them for different ERP sections, like Human Resources could be "Overseer of Unhappiness" and Sales could be "Bringer of Rain." Honestly maybe I could even do both of these ideas, and we could have some emergent comedy for the player to discover. The other thing is that the tree is unwieldly and hard to view. I think I'm gonna have to collapse sections with pluses and minuses, which will allow me to put everything super compact and expand as you go. I don't even want to think about the algorithm to make that, but I will almost certainly be implementing something like that. So for now, the low level employees works perfectly. I want to start iterating on Companys. The first thing I need to do is merge the data models so that the economy side works with this new display layer I have, using interfaces. That should take a day. And then I made a realization. I'm actually pretty close to starting Alpha than I thought. I almost have a playable game. Once I implement different types of companies, add in different skills and goods and recipes, do some polish and art and sounds, I'm pretty damn close to an Alpha, and that makes me excited. I've been working on this for two months, and to have something tangible and ready to tune and iterate over is awesome. So we got a couple months or so to get things rolling, but I'm pretty happy with the direction this is taking, and I'm making the game I want to make. So where do we move on from here? There's really 3 types of companies in my mind...Service, Retail, and Manufacturer. I have retailers and manufacturers in, but I want services as well. I want the player to roleplay as a janitoral company that works the black market and pushes the competition out by force. IT Services for companies, entertainment services, massages and salons. Things that don't sell a tangible product. We then have retailers, which sell goods. Hardware companies sell the things you need to build a company...You have to have so much steel and so much wood to build a building. You have manufacturers that take goods in and does more advanced recipes. Artisan restaurants that people can go to for better food boosts instead of the super market for groceries. It's not going to be incredibly detailed, but enough abstraction to find some fulfillment for people to roleplay in. With that system in place, I have a playable game. I will just need to finetune the economy for money sinks and money creation...ability for agents to die and immigrate in. I doubt I'll let agents have babies...Simulate sort of a community, and people leave and immigrate too based on how well the economy does. After Alpha begins, I want to create a government that will support people with welfare and loans, money creation, create laws that legalize or make illegal your competitors goods. Pass laws that restrict free trade. I can have a judicial system so that companies can sue for breached contracts, or individuals and companies for committing fraud. And of course we still need to create the fraud system, which is going to be iterated and fine tuned with the economy. When does an agent want to commit fraud? What motivates them to? How will they have the opportunity to? I need a system of internal controls in order to regulate this, and I need financial statements for companies for the player to peruse through and catch people stealing from them. And I need it to be fun and interesting and playtested. So exciting stuff. Every day is one step closer to playing the game that I've always wanted to play.

KrisWolfe

KrisWolfe

 

Solving the tree problem

So, I think I've designed a possible solution to my tree problem. First off, I really like C#. My background when I was young was C++, and learning data structures and pointers was interesting. I did really well with assembly language, and enjoyed those kind of recursive things. But I never kept up with coding, and now here I am much older and way behind. Object oriented programming had just becoming a thing back when I was coding, and until a few months ago I had no idea what it was. I started doing some coding with javascript a few years ago, and let me tell you, that's one of the worst languages to start in. Now that I know what a strongly typed language is, having the compiler interpret what you want to do leads to so many obscure bugs it's crazy. With C#, if I make an error, I know exactly where the problem is most of the time. I haven't really run into any huge logic bugs I couldn't track down. One of my favorite parts of C# is that practically everything is a reference. Keeping track of pointers in C++ was a pain, but C# does it so naturally and intuitively. I absolutely love it. So now we get to the solution part. I don't know if C++ had events and delegates back when I was coding, but this is a dream. Because of how they work, I don't even care about animations or sounds in the game, because I know I can just go find the method that I want a sound to play and throw in an event code and plug it into my audio, or animation. It makes things so painless. We have quite a few objects interacting with this hierarchy tree. First off, we have the employee objects themselves, that hold all the data I need to interact with the economy. Salary, jobtype, skills, hunger, cash, so forth. When we load the screen, we have to spawn an "Employee Card", which is the visual layer for the user. The card doesn't care what the data is, it just has a "data container" for the employee...or a pointer. The Employee card is draggable. When they don't have a job assigned, their just idle, and sit on the bottom panel. There's really only two things you can do with an employee card on the hierarchy screen: Drag the card to an employee slot or the idle panel. Right now, I can drag it anywhere, but I'll cut off that hippie golbydygook user freedom later. The next object we have going on is the employee slot, and I think this is where most of the logic is going to happen. I don't the card really cares what happens to it or where it goes. But the employee slot DOES, because on the display, I want you to be able to grow the tree...in order to do that we need empty slots spawned...and we're going to have to do it for each manager. So if the CEO has two managers, and those managers have 4 employees each, then we're going to need the CEO to have an empty manager slot next to the two managers so you can hire a new manager, and then each manager will have an extra employee slot in order to grow their trees. But, if I drag someone in, we're going to need to spawn another empty employee slot next to it. And it has to know where to spawn. in the opposite vein, if I drag out an employee or manager, then they're going to have to despawn the empty employee slot, since there would be two, and I only want 1. And if you drag out a manager, I want the employees to reattach themselves to a different manager. On top of all that, I currently display things by spawning all the objects. So when I do I refresh the display? I also don't think it's wise to continuously spawn and despawn all these objects everytime something moves slightly. So for the display, I'm going to be doing some spawning pools. The cards and slots and lines aren't unique, and this will help performance. I'll need 3 different spawning pools. The card slots will have event listeners on them, waiting for the employee that they're holding moves. If we drag an employee to them, then we register our delegates and then attach them and then have that slot's manager spawn a new empty slot. I think all of this will work pretty well. I can think of a few edge cases off the top of my head, but I can get most of this up and running this weekend hopefully. I think making the tree itself will likely be the hardest part of the hierarchy screen.
 

Recursive thinking

Recursive programming is tough, but oh so rewarding. After 2 days of trying to figure out this thing is going to take shape, I've done it: A hierarchy tree. It's quite dynamic too. It can have lopsided trees and uneven trees. But, what it can't have is managers without employees. It's assumed that if there's a manager, it has an employee. How it works is that while I'm running through the employee roster to get all the idle employees to my idle panel, I count how many bottom nodes there are going to be. Using that, I enqueue up an offset counter, and each time I hit the bottom, I dequeue the list and multiply that by my width of the card. My recursive model races to the bottom first, and then once we've placed the subordinates, the manager just averages their x positions and places himself up. I keep track of how high we are in the tree as we step in and out of our recursive function, and multiply the height counter by the height of the cards. This has been oh so satisfying to code. Now to figure out how to add and delete branches.
 

One small step in algorithms

So, from my last update, I got most of it working. Using 3 interfaces, I have the CEO of a company being created, and all the idle employees being placed into the idle panel, along with an empty slot being spawned in order to start getting people managed and working. Which is all fine and good. I'm pretty happy with how the concept worked out. I had trouble working with interfaces for the first time, because I didn't realize what properties were. When I tried to put a field into an interface, it would kick it back. So I thought I couldn't have guaranteed fields for interfaces. I tried to make get methods, but as I began to work on the display level of the code, it was causing all kinds of problems. I finally looked it up online if I could guarantee fields, and discovered properties and get/setters. I don't really understand what the difference between a field and a property is, as in why you would have fields at all if there are properties in the language, but here we are. As soon as I put properties into my interfaces, the display code just fell out easily. So, now I'm at a crossroads. How does the tree know where to place all these card holders onto the board? Clearly we can't have them stacked on top of each other. How does it detect to place an empty? Where does it place it? What if I pull a card out of a slot...does it disappear? Do the other slots need to be reordered? I want to add managers to managers, increasing the tree. Where does it place these cards? Do we start at the bottom or the top? This is going to require math, unfortunately. I'm going to have to develop some algorithms on detecting which tier of the tree we are at, how many items are in the tree at that tier level, and so forth. So for now, at a wall. Time to research and figure out how it needs to be displayed.
 

Clearing my mind of what needs to be done

So I think I have a general idea of what I want now. I wasn't exactly sure how I was going to implement this. I was studying the SOLID principles, especially the ones I have no clue about, and was going over the L. I noticed the examples online had a lot to do with interfaces. So here's what I want to happen. You load up the screen, and if you have multiple owned companies you select which company you want from a drop down. There will be tabs eventually so you can switch from production to sales to marketing to accounting. On the screen will display a hierarchy, starting with the CEO, down to managers, team leads, and finally employees. You can then drag and drop the employee cards where you need to go. If there are idle employees, they are on the bottom panel waiting for you to drag them in. Each tree will also have an empty slot next to it, so you can grow the tree. So if you don't have a manager and two employees, there will be a line from the CEO to the employees, with an empty manager slot ready to receive an employee card. When that has been filled, a new empty slot will spawn for you to put another manager in. Should always have an empty slot next to every position, so you can grow the tree. So...how do I get Unity to do all of this? I know right now that I would have to break my current employee class to implement this, so what I'm going to do is make a TestEmployee class with an IEmployee interface...and pray to God that all I have to do eventually is just throw the interface on my current implementation and it works...Problem is, the way I have companies, they just test to see if they have enough employees. So I'm going to have to figure out how NPC's will do all of this in the background. For now though, I just want the player implementation to work. So, how do we get this working. We start with the CEO. Whoever creates the business will by default be the ceo. Cool. So now each person is going to have a property of IEmployee that is called "Manager", which is a link to the IEmployee that is the manager. They will also have a list of first order IEmployees. So with just those two things, I can do some recursion and display the tree. The company will have a list of employees, so I don't miss any stragglers. I think I'm just going to break up the lists to each department, so that I know that if I have employees in a list for production, I need to display all those employees instead of testing to see if they're part of the production department in some giant employee list. Ok, so that's the first idea. Now, as counterintuitive as this sounds, I don't think I'm going to have the employee know what job they're even doing. I don't think it's necessary. So, what I'm thinking of doing, is this list of employees the company has, has an object that has the employee in it, along with their job contract. The job contract will have the specific job they're performing, whether it be manager or producer or team lead, along with salary and time until the contract expires. So the company will care about what employees it has so it can pay them. The job contract will be linked to an employee so that it knows what job it has, and the employee will contain the links to it's supervisors and subordinates. I first scan the list for the employee that has no manager (the ceo), and then recursion to display the tree. If I drag a manager out of it's slot, that will call a method to break the links, and then link the subordinates to the manager's manager and vice versa. Which means I will likely have to keep the default CEO as the player at all times, and you won't be able to drag yourself out of the CEO slot...you can put someone else in, but when you drag them out you just get defaulted back in. I think this could work. Then of course none of these classes cares about displaying to the screen, so have my screen controller call all of this whenever it happens, and when you drag and drop a card, have some delegates be called for these functions. This is what I'll be working on this weekend. Wish me luck.
 

Creating my first art asset

The day has finally come. I've created my first art asset. A simple placeholder silhouette for my Corporate hierarchy tree. I'm sure it's not much to any savvy artist, but it took me about an hour. I chose to go with Photoshop because of the myriad amounts of tutorials and help I can find on how to do what I need to do. I will eventually need to deal with art assets, and I haven't decided on whether to do them myself or not. But I do need to start getting placeholder art in, so here we are. At first I was attempting to create some type of table to place employee cards down on, with slots for jobs. I discovered very quickly though, that text is a pain in the ass if it's not UI. The only solution I could see was to have separate sprite art for each employee name or job name. So I scrapped the entire sprite idea and went back to everything just being UI. The first thing I wanted to happen was to be able to scroll the screen, move around and view the entire corporate hierarchy. That was the original reason I wanted to do sprites and cameras. I realized quickly that I had no idea how to deal with cameras, and spent a day learning. But now that we're simply dealing with UI, I have to keep everything in view of the UI "portal"...so instead of moving the camera, I created an empty game object called "Table" and when I right click and move the mouse, it moves the object and everything attached to it. I keep the background and the camera static, and simply move things off camera. The bottom panel will spawn in "idle employees" or unassigned employees. You hire an employee, they pop up in the bottom, and then we drag them to empty slots available. The first step was to get the employee cards to snap to where they need to go. The job slot highlights when we get near enough, and then the position is set over the inset. If we drag the employee card back to the bottom panel, it snaps to a grid inside the panel. Simply changing parents when things enter and leave is pretty simple to do. However, this also poses a problem. Unity's UI renders by hierarchy. So objects higher in the hierarchy get rendered first. So if the employee cards somehow get above the job holders in the hierarchy, they will be under the job holder visually. Have to find a way to manage all this as we press on and I start spawning job holders in later, which would mean that they are below the employees in hierarchy (bad thing). So for now, it works. Employee cards snap to where they're supposed to, and when I right click and drag, the objects that are supposed to move do. I need to add in a zoom out feature eventually to add more detail, but for now it works fine. Next step: When we load this screen, populate the hierarchy. Have employees already in their job slots, have a tree with managers and the CEO and team leads, with employees attached to all of that. And it needs to spawn dynamically. If I choose a different owned company, it needs to repopulate the screen. Later, once that is working, we will have green or red highlights for job slots the employees can go to, and productivity bonuses based on how many employees a team lead has or is managed correctly or whether the employees are better at the job than the manager. All interesting stuff.
 

Setting up careers and Corporate Hierarchy

It took a few hours, but I finally got back up to speed from losing my entire scene from a crash. I now have backups and will be implementing some type of version control so I don't have this issue again. One of the good things about this crash was that I had run into a wall on how to implement jobs and this allowed me to fix it. I had made two markets...one for hiring employees and one for obtaining contracts for goods. The contracts is working and works in the way I envision for it to work for the rest of my development. Jobs do not, however. Right now, my current implementation is that employees either have a job or they don't. If they don't, they put themselves on the market to receive a job. A job contract is created, and if the employee gets hired, the job contract will extract funds from the company and pay the employee. The company either has enough employees for a task or it doesn't, and if it doesn't, it will seek out a job contract. When the job contract expires, it delinks itself from everything, resets the company and employee to not having an employee/job, and awaits garbage collection. So I could spend my time getting a visual job market working so that the player can also do the same, but I don't want that. Because I want a visual corporate hierarchy, I want separate job types, I want employees to have skills that affect their jobs (or don't), and I want a drag and drop interface screen where you can drag employees to whatever job you want them to do. Also eventually we will have internal controls hooked up so that employees can commit fraud, and you can stop them from committing fraud and so forth. So now my contract market is better streamlined because there's nothing on the screen for jobs, and now I can look through every good on the market, instead of only the goods that my company is working with. If my company is a producer, then the bid buttons are disabled because we aren't buying goods, we're selling goods. I also can't get sell contracts for goods I don't produce. It's pretty nifty. This week I will be working on the job system. I am going to be using my first interface with this job system, and I have a feeling companies and skills will also move to interfaces. I like the whole superclass idea that I used for skills and companies, but it's just not working out and is confusing me. Interfaces are a lot more intuitive to me, and I think it naturally fits better with how I write code. So Jobs will all have an interface IJob. My other code won't care what type of job it is, it will just tell the job to run it's behavior. It will know it has certain methods because it's an iJob, and that's really all my other code wants from the job class. The corporate hierarchy will be interesting. For any jobs that are left unfilled, you will be able to drag your character into that slot. For each slot that your character is in, it will unlock a "job skill" for the scheduler, and you can slot in how much time you want to spend on each task per day. There's only so many hours in a day, so you will have opportunity cost on what to choose, and will have to hire employees if you want to have an efficient company. The corporate hierarchy itself will unlock over time as you become better at managing. You will get production debuffs if you don't have team leads after you have two employees working on a task, and then those teams will start to get debuffed if you don't have managers that have multiple team leads, and so forth. Then we can have different parts of the company in tabs. Accounting, Sales, Marketing, HR, IT. I can implement interviewing for new employees. People in the market don't have to always apply for the job they are best qualified for, just like in real life. Employees can almost be "loot", where each time someone applies, they will have 2-6 random skills, and it's not guaranteed that those even apply to the job they're applying for. With time, this hiring skill can be increased to where maybe you always get at least one skill that's relevant. Or you can just hire a competent HR team to do it for you and you can worry about other things. I love this idea of just making a game mechanic, and all this strategy falls out of it. Hopefully I can do it justice. So, this week, gets this up and running, and have some screenshots.

KrisWolfe

KrisWolfe

 

A lesson in Version History

So, today, while going through my code, my computer crashed. It's an old computer from 2011 that I haven't the heart to replace. When I loaded up Unity, I got over 1000 errors, all talking about the GUI not being able to load. My scene was gone. I double clicked my scene, and it was empty. I had no backup. All my assets were fine, but it was extremely disheartening. Looking up support, it appears my scene got corrupted and is gone. I might've been able to save it if I hadn't loaded Unity, but I didn't know. Unity stores a backup scene to the last it loaded. But once you load unity, that backup is overwritten. Everything I had was UI, luckily. No custom settings or anything. I think I had some fonts that were not the same, so this will give me a chance to get the measurements correct for everything. My scripts were doing all the settings, so I literally just have to drag the UI into their slots once I have them up, and it'll work as plug and play. So a lesson learned. Back up your work. Use version control. I had no back up to this scene. I didn't think it would happen to me. Luckily it was stuff that I can reproduce in a day, and not my code.

KrisWolfe

KrisWolfe

 

My code really isn't as bad as I thought

This week I've been working on bugs and doing a little refactoring. I finally hooked up the scheduler to the economy. This actually made me realize I'm a much better coder than I was giving myself credit for. For instance, my old rescheduler code took strings in of the skillnames and then looked through my scriptable objects for it. I changed the code and deleted it from scriptable objects because I want to edit skills with a JSON editor eventually. Well, instead of a string, I gave it a reference to the skill. And it worked. I was applying all the SOLID principles without even realizing it. So then I thought, "Well ok, I have a list of skills from the scheduler, now how do I get it to affect things." The skill I was messing around with was "Execute recipe." The skill itself is linked to a company, so it doesn't care what kind of company it is. I went to go and write the code to execute the recipe, but I'd already written it for NPC's to mess with. And since my player was also an NPC through inheritance, I literally just called the method and it worked...without a bug. Open closed principle, done and done. Now instead of hiring an employee, the player can simply work for 8 hours and do the same thing for their company. So there will be a decision of what you want to handle in your company, or whether to hire someone to accomplish it, and you only have so much time in the day. I realized I hadn't even set it up so you could hire an employee. So opened up the market code after taking about a week from looking at it, and started to see some issues. Just by looking at the code, I found some other bugs...like the method that went through and counted all the inventory at the end of the day wasn't working, so had to check that...and if a job contract expired, the employee wouldn't stop working and would keep getting paid. Another issue I saw was performance. When I hit the next day button or initialize the economy, it went freeze up for a couple seconds. I figured I would run into that eventually. But then I realized it was my Debug.Logs that were hitting performance...a bunch of outputs to show me what was happening. Once I took them all out, I have no noticeable slowdown. My computer is from 2010, as well. All in all, I felt really worried about my code. But now, I'm starting to see it's actually not too bad. It still needs to be refactored, but it's easily navigable, simple to add behavior to, and adheres to alot of the SOLID principles I was worried about. I am running into an issue of motivation. I don't have the drive I did before that would keep me up until 3 in the morning. My creation is kinda boring to mess around with. It's now WORK. And work sucks. I went through all the screens, adding buttons and functionality to navigate. But I'm finding myself being drawn to do other things. I want to start making a different type of game, or do another hobby. After reading a lot of blogs on game makers running into the same issue, I know not to do that. Don't rewrite my entire code base. Don't keep starting projects that I know I won't finish. Finish the game. I find it best not to listen to music, but to listen to game developers talk about making their game in the background. Keep the motivation up. Here's a picture of my scheduler at the moment with it's single skill in the game. I will add skills to the game as I run into something I want to code. For instance, I want the player to have a managing skill that gives bonuses to employees. I think I might make a screen that shows the company hierarchy next, where you can drag and drop employees and yourself into roles, and then have internal controls for each job as well...some jobs require certain controls to even function...and if you give too many controls, employees can steal from you. Guess that'll set myself up to begin creating the main mechanic of the game, Fraud.

KrisWolfe

KrisWolfe

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!