0

No products in the cart.

How InstLife Works

A quick ~behind the scenes~ look at how we develop InstLife.

Why?

We’ve had a few requests asking how we handle menu based gameplay within Unity, so here we are!

UIWidgets

The main force behind InstLife is a great asset called UIWidgets, this has been a life saver with it’s expanded UI elements – but more importantly it’s EasyLayout functionality.

This is great for auto spacing and padding your elements.

Check out a demo here. Store link here, which also reminds me that I need to rate this asset…

Changing Screens

Each page is its own GameObject, with all relevant UI for this page as children to this GameObject.

I have created a MenuManager script which controls which GameObjects (pages) should be displayed dependant on what page you have selected.

We also have page specific scripts that initiate when the new page has been enabled. One example of this is job history. I don’t want this updating when we’re not looking at it. Only update this page when it is enabled by the player.

I don’t know if this is best practise, but it works.

Handling The World

In the game world we have the player, obviously, but we also generate GameObjects for people like potential partners, your parents, company CEOs, burglars etc.

Each ‘person’ is sent through the game’s WorldHandler script. This script updates their health, education, their outgoings, manages their job life (gets them a new job, or finds one if they’re unemployed), all that kind of stuff.

        // Sim every person in the game world
        Person[] people = Object.FindObjectsOfType<Person>();
        foreach (Person p in people)
        {
            if (p.alive) // Make sure they're alive, a dead guy can't pay bills
            {
                updatePerson(p); // Send the alive person we've found through the cycle
            }
        }

Most of the time the player will go through the same cycle except for careers and events as they only directly affect the player.

Triggering Events

So, after we have sent our player through the cycle of having their salary paid, health updated etc. we then hit them with events! If they’re still alive that is.

Each ‘module’ of the game has its own handler script.

This allows me to have a master function for each module that decides if a random event has been selected, and if it has – are the conditions met for the player to experience this event?

            else if (randomEventChooser == 3) // burglary
            {
                if (player.houses.Count > 0)
                {
                    if (player.bankBalance > 0 || player.currentJob.annualSalary >= player.CountryLivingIn.avgCountryIncome || player.famous)
                    {
                        Burglary();
                    }
                }
            }

Once all of these events are out the way, the player can then begin their year and decide what to do for themselves.

Again. I don’t know if this is best practise, but it works.

Summary

I hope this write up has been useful, I’ve never really done anything like this before.

Any feedback would be great – even if you’re telling me how bad my code examples are.

Comments

  • Syaz Amirin

    July 17, 2017 at 5:00 pm

    Wow! Really nice!

  • PanFist

    July 17, 2017 at 5:00 pm

    It’d be nice if you made a plugin spot where we could make our own plug-ins

  • Rees

    July 17, 2017 at 5:00 pm

    As a student of Games Development, this is really helpful. Thank you 🙂

  • my mum

    July 17, 2017 at 5:00 pm

    plz add a president career

  • Somebody

    July 17, 2017 at 5:00 pm

    It would be cool if you made the game folder available, so we could create our own game

  • Kiedré Johnson

    July 17, 2017 at 5:00 pm

    Hello! I am in love with InstLife,and my advice to you is to keep up the good work!
    Some New content I would like to see is:
    -Taking over the role of your children after you die.
    -Have different careers like being a police officer,fireman,mayor etc.
    -Making friends at work or any other social event.
    -When making friends they save in a contact list on the phone.
    -Being an entrepreneur.
    -Having to make your own house.
    -Being able to get pets and whether to care for them or abandon them.
    -More career choices again like: Teacher,tv host and chef.
    -Add an extra to whether you want to be obese,plus size,anorexic,skinny,thin,thick etc.
    -Add extras to design our facial features and body features.

    Than, you for taking time out to read them I know it’s alot.As I said before great game and keep up the good work!

Your email address will not be published.