# How to program (architecturally/organize) a set of customizable changes to a game?

The floor of my game (tower defense) is composed by a set of cubes. I wish to change these on some of the waves. I have a list of the changes that need to be made on each wave in a floorController class. However, in order to decide which floor cubes should appear or disappear on each round, I had to assign each cube a bool for each wave (if this is set to true the floor changes in that wave). However this process is tedious and not ease to change and customize in order to experiment with the level. From an architectural programming perspective how can I better structure this system?

Code vs. content

Game level layout is typically stored separately from your codebase. Why? Because as you've discovered, the cost of change for code is higher than the cost of change for say, a text file.

In your simple case, I would opt for something like what Angband does to describe its vaults:

       %%%%%%
%%%..##..%%%
%%....####....%%
%......#&&#......%
%...4.##+##+##.4...%
%.4.4.#&#&9#&#.4.4.%
%.4.4.#&#9&#&#.4.4.%
%...4.##+##+##.4...%
%......#&&#......%
%%....####....%%
%%%..##..%%%
%%%%%%


The structures you need are drawn/typed by hand in a text file this way, for all your levels or for each level as a separate file. You typically load / parse these either at game startup, or whenever they need to be used (e.g. player has reached level 3). You could write these out as text files initially, then store them in PlayerPrefs or as text files on server (e.g. Node).

Up to you, but I'd start by using hand-editable text files loaded from the game's own folder.

For booleans, a level matrix may be as simple as:

11101
01111
01110
11111
00100


...this totally depends on how you want to represent a missing vs present floor tile - it doesn't have to consist of 1s and 0s!

If you need more information per cell, you can either use multiple characters with separators (e.g. |) for each cell, or you can draw multiple maps per level with one character per cell, as shown.

These are your decisions to make, because you'll be the one writing the code to parse / understand this information in order to create levels with it.

• When you need more information per tile than you can squeeze into a single character, then it might be time to invest into the development of a WYSIWYG level editor. Or to develop an importer for an existing one. – Philipp Apr 1 '20 at 8:17
• How would these files be incorporated into the build? (I'm using Unity) – ManoTech Apr 1 '20 at 15:03
• @ManoTech AssetBundles, if you don't want to access them from a central server. It's really up to you. Google "bundling text assets unity". I've given you the core solution - it's up to you to determine the implementation details. – Engineer Apr 1 '20 at 16:14
• You didn't understood my question. When building a game in Unity, how can one tell unity that some text files need to be included into the build? – ManoTech Apr 1 '20 at 16:38
• @ManoTech I understood your question perfectly. Unity has full documentation written just for you. Moreover, this. Your question was "From an architectural programming perspective how can I better structure this system?" I have answered that question. I am not a technical manual. If you have new questions based on this answer, follow the documentation, or ask a new question on this site. Thanks. – Engineer Apr 1 '20 at 18:46