Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Essential · Sep 07, 2012 at 06:59 PM · leveldataparameterslinear

Defining parameters for a level

For a game that uses waves of enemies in a specific spawn order, spread among 100 levels, what's a good way to store that data and read from it?

Right now I'm using a script I wrote that simply randomizes enemy spawning, speeding up with each new wave, but now I'd like to make it more defined per wave however I'm unfamiliar with this type of game design (defining a level's parameters in text) so I'm not sure where to start…

Should I look into xml files or something of the sort? And how would I structure them? Any help would be appreciated. (If it makes any difference, it's a mobile game.)

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by FatWednesday · Sep 07, 2012 at 10:00 PM

Well depending on what kind of definition you want, you may well be able to just use a very simple structure such as the example below.

     public struct LevelParams
     {
         public string LevelName;
         public float TimeBetweenWaves;
         public int MaxWaves;
         public int EnemiesPerWave;
         public float TimeBetweenEnemies;
     }

That is of course just a very basic and limited method of defining some simple level parameters, you could hard code these in a file, write a custom editor window for creating them, and if you want to, these simple structures would easily save and load to files. This could be with your own custom text serialization, or the very useful XmlSerialization, or a BinaryFormatter depending on what your comfortable with, and what target platform you are going for.

Hope this helps.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Essential · Sep 07, 2012 at 11:47 PM 0
Share

Thanks FatWednesday, that helps for sure.

The biggest thing I couldn't get my head around was how to say, "Release three of enemy type1, then a type2 enemy, then five type3 enemies…" etc. But after you listed your examples, I realized I could just create the wave pattern as variables too (e.g., "var numberOfType1")

Thanks for the kick in the right direction!

avatar image FatWednesday · Sep 08, 2012 at 12:31 AM 0
Share

you're welcome. and yes you can build a small "Wave" structure defining wave parameters, and then build up collections of those for completely custom designed level of waves :). Best of luck in the project.

avatar image by0log1c · Sep 08, 2012 at 12:44 AM 0
Share

+1, struct and class are the core of OOP. I'd like to tell everyone new to them to read about the subtle but very significant difference between them. They behave very differently and in most cases, you actually want to use a class, imho.

avatar image FatWednesday · Sep 10, 2012 at 09:40 AM 0
Share

this is true, I do find myself most of the time using classes, usually for me that's just because I need them to be nullable reference types.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Level builder for iphone 3 Answers

Door that changes level on character collision script help? 1 Answer

How can i switch to the next level after completing the task in level one? 3 Answers

Create level based on XML/TXT file 3 Answers

Quadtree Neighbor Level Differences 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges