So some background. I started this project while I was exchange in Germany, in November 2015. I was downloading and playing all sorts of apps in pure boredom, and came across few of these "flood" games. I thought that the mechanics were really interesting and I wanted to know exactly how this sort of game could be made. I did some Googling and found absolutely no tutorials or even any tips on how to make a game like this so I decided to give it a try!
So basically every level consists of simple UI-elements (Menu/New game-buttons and colour swatches), "idle" boxes and "player" box.
When the game starts, each "idle" box generates its own colour out of five different options, and sets a tag which matches the colour (for example, Material0, a bright pink, would have a tag named "0"). Each idle box also has a box collider with trigger set on.
This is going to get hella complicated real soon but just bear with me.
When one of the colour swatches on the UI element is clicked, "Player"-block (first block on upper left hand side) changes its colour accordingly. Player block also reads the tags of its surrounding objects, and if any block near it has the same material as itself, this piece of code will set it as Player blocks child.
Now, on each idle block there's also a code to "correct" their material. I'll try to explain this as simple as I can. Basically this bit of code reads the tags of all of it's surrounding blocks. If a block next to it has tag set to "0" and the Player block currently has the same material displayed (and if the current idle block is a child of Player block), it sets the other colliding block as a child of Player block.
Also, in Update-function, there's a few lines like this;
What this means is that if Player currently has Material0 on, and this idle block is a child of Player block, this block will also have the same material as the Player block.
I know this project/ the scripts are very complicated and messy, and I am working on making it more neat and simple. This has already been a wild ride and it has been a real big challenge to get the project even this far! To be completely honest I am really proud that I got this to work.