I'm currently playing around with a base builder/manager-esque type of game similar to Evil Genius. To build a room I would like to have the following process: 1. Select room type 2. Click and hold the mouse. Drag to create a rectangle over the area. 3. On release, place entire room.
I have already implemented this, but I find it inefficient and I would like to improve it. As of now the indicator rectangle is simply a sprite that is scaled and moved to fit. I would, however, like to have the indicator rectangle to be "adaptive". Meaning that if I drag a placement rectangle over an invalid area the indicator will be red at that point.
To do this I figured I could go with some sort of loop. I.e. "A change in rectangle size noticed. Update all new indicator tiles with correct colour". I had all the pseudo code figured out, but then I realised instantiating a number of gameobjects would be kinda inefficient. If the player is making a large rectangle in a short amount of time, that would surely slow down the game? Is there any other way to solve my problem, or is this the most efficient solution?
I should note that this build system is grid based. Each tile has a coordinate given by two integers and is saved in a 2D array. You can easily access the array and see what tile is at any given point or find the coordinate of any tile.