To start this dungeon-building project, I wanted to get a basic set of models made. These models will be the objects placeable by the player to build the level. I wanted to keep it simple to start and add one enemy, one reward, and one scene light. I decided to create a goblin to be the basic enemy type, which I created five varieties of.
To start with the goblins, I created a new project in MagikaVoxel, a software that creates voxel models for games and rendering. I will use this for every model in this game. For the goblins, I made one base model and cut it into parts. For the parts, I created multiple heads which I will switch out to create unique prefabs in unity.
For the lights, I wanted to create two versions, one to be placed on the walls to act as basic scene lighting and one to be placed on the ground by the player. For the lights, I imported a fire effect I made for a past project and I added a point light. To get the lighting to work properly, I made sure to create a new lighting asset.
For the goal, I made a simple treasure chest for the player to reach. I split it into just a top and bottom so I could animate it opening. This would add an extra element of detail to the game.
I imported this all into Unity creating a prefab for every spawnable object.
The game will need an environment and for this, I needed to create three tiles. One will be the walls as seen from the top down, which need to be open to see the level. Then I needed to create the wall tiles that will create the room the player sees. Lastly, I required a floor tile, so I created a dungeon floor tile using a darker colour pallet. I added moss on to the ground tile and tried my hand at adding cracks. This was to add detail to the map.
Next, I wanted to work on the TV screen effect. For this game, I wanted to make it look like it was being played on an old-style TV computer screen. For this, I used a video tutorial on how to get the effect I wanted, linked above. The effect will be done through the post-processing of the game, but first I wanted to add a border.
To start on the border, I opened a new empty Photoshop file and began adding shapes that fit the desired effect. After a few attempts, I switched to using the pen tools to create the border I used. The border took some time to create as I tried to create it using different methods and different software to get the look I wanted. After I created it, I also wanted to add some effects, which also took a while.
Then for the post-processing, I used the same ones from the video, just changing some values till they fit my desired look.
Following along with the video, I went on to create the input system. The input system works by getting the coordinates of the mouse. It gets the position of the mouse and then the camera on the z. then it sets a ray down from that position, searching to see if it hist the placement layer. If it does, it sets the last position.
For the Placement system, I have so far done it in two parts, there is more to come but this is it for right now. I will walk you through the systems, both the ones I made on the first day for creating and visualising the grid and on the second day for the basic placement system.
For the grid visualization, I used a shader graph following along with the video to get the effect I was looking for. The shader puts a grid onto a plane, using the shader graph as the base. There are values to control the line size, colour and thickness. This can be used to make sure the grid fits the grid of the actual placement system. I put this object under the grid in the hierarchy to make sure they align.
Along with the video series. I added a boolean that checks if the player is over the UI, this will be used to check if the player presses the buttons to start placing and to check if the player is trying to place over the UI. Then I add some code that checks if the player is clicking and adds an as clicked. I added some code that checks if the player presses the escape key, this will be used to stop the placement system.
Then I create a new script, which will be the scriptable object class for the placeable objects. This script will hold all the info the objects require, so the placement system can identify the item. The list includes but is not limited to, the ID to mark the object, the name, so the player knows what they are placing, and the game object that is to be placed. There is also the size, which is important for the grid to know how much space the item takes.
Here is my placement system, it takes in an object data object from the hierarchy. It also takes in a few other objects for the indication and inputs. This code has a few functions. It has one for starting and stopping the placements, which will be set to the on-clicked and on-exit functions from the input manager. A place object function to handle the placing and an update function for the rest.
The start placement system calls stop placement sets the cursor to invisible and enables the mouse indicator. It also sets the selected object index and if it is less than zero it debugs an error. Lastly, it enables the grid and sets the input manager events.
The place object first checks if the players' pointer is over the UI, doing nothing if so. Then it gets the position of the mouse over the grid, then it gets the cells of that mouse's position. If the selected object that is being placed allows a random object, the script sets the prefab to any random object from that list of prefabs. Then it instantiates the prefab and sets its position to the position of the cell.
The stop placement system sets the selected object to -1 causing it to be reset from the object. Then it sets all the visuals to false which ensures no system remains. Then it removes the functions from the on-clicked and on-exit functions. Lastly, in the update function, it returns if the selected object is less than zero, and sets the mouse position. Lastly, using this position sets the position of the mouse indicator and the cell indicator.
Here is the video of the current state of the project. You can see the placement system and the UI controls. You can also see the randomly selected goblin.