Clearing my mind of what needs to be done

posted in KrisWolfe
Published May 04, 2019
Advertisement

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.

1 likes 0 comments

Comments

NubDevice

I enjoy how language allows concepts to be built. 

May 04, 2019 09:44 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement