Jump to content
  • Advertisement
  • entries
    19
  • comments
    0
  • views
    928

Project: Fraud Simulator

Solving the tree problem

KrisWolfe

731 views

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.




0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Advertisement
  • Blog Entries

  • Similar Content

    • By RamblingBaba
      Hello,
      So I have been programming with C++ for 2.5 years now. I have been interested in checking out C# for fun. My question is pretty simple. Does C# use a form typically for their games? The simple game examples I have watched on YouTube reminds me A LOT of Visual Basic. 
      Was this just an easy way to show you C#? Or using the form is a big part of C#? Or is it nothing more than using something like MFC and completely irrelevant to making games?
      Thanks
    • By Data7 Games
      UNITY PROGRAMMER
      We are looking for Unity Programmers. You will be working with our programming team Lead to implement mechanics & features using C#

      Your Responsibilities will include:

      1. Attending team meetings.
      2. completion of implementation of assets.
      3. Direct contact with Project Lead and other project Leads
      4. Utilization of GitLab

      REQUIREMENTS
      Also, The following requirements apply:

      1. Clear communication
      2. Ability to Successfully complete tasks
      3. Comfortable with working with people remotely and via GitLab & Discord
      4. At *least* 10 hours of availability each week.
      5. Experience using the Unity Game Engine.
      6. Experience implementing assets into the Unity Game Engine.
      7. Be friendly and chill

      If interested email us at data7games@gmail.com
    • By RoKabium Games
      SAMA Tip #5 Some planets have harder bedrock than others. Upgrade the mining laser to mine faster.
    • By Lopiv
      I´m making a project based on X-Wing Alliance (Some kind of that game but upgraded to the nowadays technology).
      The idea I´m currently developing is a Space Shooter totally customizable (Add missions, add ships, planets, etc....) built in Unity 2017. I´m just making things of C# programming, 3D modelling, animation and so on.
      The help i´m asking for is for filling the next Areas:
      Gameplay programmer: Fix the current spaceship controlling system, shooting targets, turret movement, hangar landing, floating origin solutions, procedural content generator, and so on...
      UI Designer: Making all the UI or at least fixing the existant.
      Mods programmer: Developing a whole solution about integrating mods in the game in an easy way for the user.
      3D Modelling and FX: I have some 3d models from some webs and some others edited and created by me, but it would be nice to have some more missing models i can´t find anywhere, as well as creating beautiful and good FX for the ships.
       
       
    • By Bromaster
      Hi i´m currently working on  a SciFi-Shooter and im looking for people to help me. 
      If you´re interessted dm me here.
  • 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!