Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 PandaWrangler · May 09, 2017 at 05:52 AM · c#2dsetuplevel loadprogrammatically

2D Level Generation Storage

Alright, so this question has been driving me nuts all day. My game is a 2D game which consists of a grid layout. Each level has a 2D grid of blocks that are various colors. The colors represent the states of the blocks. I am planning on creating dozens of levels and have been trying to come up with a good way to store each level's setup layout.

I have a GridManager that can take the size of the grid, the total number of possible colors and a List<T> of the starting states of the blocks. I have all of this information wrapped up in class LevelLayout but that's where I run into an issue. Is there an easy way for me to create a List<LevelLayouts> MasterLayoutList and keep it somewhere until a level is loaded. Then access that List<LevelLayouts> MasterLayoutList and pull whatever index is necessary and generate the level from the loaded class instance. My problem is, I don't know how to create a file that hard codes these levels, they are not going to change, and stores them in the master list for use later. Any suggestions?

I would prefer not to have to generate every puzzle layout and save it as a different scene, that seems rather time consuming and less elegant than generating the necessary level at Runtime. I'm not against using XML or some other resource file but it seems silly to me that I can't just create a code file that populates a list and include that in my GridManager script.

If it helps here is the class that is designed to hold the information for each layout:

 public class PuzzleBlueprint
     {
         /* ---------- Public Variables and Functions ---------- */
         public PuzzleBlueprint(int new_puzzle_level, int new_size, int new_selection_limit, int new_total_colors, List<PuzzlePieceStates> new_puzzle_layout)
         {
             m_puzzle_level = new_puzzle_level;
             m_size = new_size;
             m_selection_limit = new_selection_limit;
             m_total_colors = new_total_colors;
             m_puzzle_layout = new_puzzle_layout;
         }
 
         private int m_puzzle_level;
         private int m_size;
         private int m_selection_limit;
         private int m_total_colors;
         private List<PuzzlePieceStates> m_puzzle_layout;
 }
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

0 Replies

· Add your reply
  • Sort: 

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

6 People are following this question.

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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

How to make Comanion AI pass through the player??,How to make your Companion AI pass through the player?? 0 Answers

How to Set the Game Speed Based on the Player's Current Score? 1 Answer

Script calling onCollisionEnter2D and onTriggerEnter2D while disabled 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