Saturday, August 20, 2022
HomeGame Developmentunity - The right way to handle my nested Stage Knowledge so...

unity – The right way to handle my nested Stage Knowledge so {that a} singleton Stage Supervisor can simply increment by way of Ranges


I am making a singleton Stage Supervisor for my Unity phrase sport, and undecided how you can construction the information/code.

In my sport, there are phrase puzzles organized right into a 4-level organizational construction:

  • Realms (there are 6 realms)
  • Areas (there are 5 areas within the first realm)
  • Ranges (there are 8 ranges within the first Space)
  • Phrases (there are 12 Phrase puzzles within the first stage)

I’ve Scriptable Objects for every stage within the organizational construction, and the whole lot may be very straightforward to handle and intuitive. That is particularly essential, as others could find yourself designing and including the Phrase Puzzles.

Now I am programming a Stage Supervisor singleton. I’ll begin the person in Realm 1, Space 1, Stage 1, Phrase 1… and in the event that they end it, they’ll go on to the following Phrase (Realm 1, Space 1, Stage 1, Phrase 2)… and so on.

If all of the Phrases had been organized in a single flat desk, the Stage Supervisor singleton can be trivial. I might simply have a Phrase Quantity for every phrase, and increment it by one upon profitable completion of the Phrase Puzzle.

However since my Phrases are organized into this nested organizational construction, I’ve to loop by way of all 4 tiers of the organizational construction in an effort to discover the following stage to go to. It isn’t a giant deal at first, however the sport may have round 5000 phrases upon launch and so it looks as if plenty of pointless looping!

To this point, I can see 2 methods to deal with this:

  1. On Begin, I might loop by way of all 4 ranges of the organizational construction and generate a flat Record of Phrases. Then it will be trivial to increment by way of the Phrases.
  2. I might create a backend button and if I click on on it, it will loop by way of all 4 ranges of the organizational construction and generate a flat Record of phrases. It will then Save that listing, in order that it does not need to be generated upon runtime every time.

However each of those approaches really feel a bit kludge-y to me. The primary one would run each time this system is run, and the second would require me to recollect to re-bake a brand new flat Record of Phrases each time I add a brand new one.

Is there a extra elegant approach I might be storing/incrementing by way of the Phrase Puzzles? Thanks!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments