Today was pretty good and I got quite a bit done on my game.

In order to select tiles, and display information about them, I thought I’d have to resort to raycasts. Raycasts are sorta like laser pointers, emitting from the camera to where your mouse pointer is, and they return the first object they collide with. This was how I did lots of pointer and aiming stuff a few years prior. But fortunately, things were much much easier this time around! Any game object with a collider has all the typical mouse events that come with most programming languages with a UI. I just had to add a collider to my tiles, and give them function calls for OnMouseClick. Each tile is given their own instance of the OnMouseClick, so they can send their own info the GUI Manager to update the UI with the appropriate info. I then display info about the tile, and info about any criminal that may be there as well.

With the knowledge of mouse events, I was also able to implement highlighting of selected tiles. It took a bit to figure out colors again, and my method ended up being a bit more hack-y than is probably best. I expect I should actually be changing the material or shaders or something. But OnMouseEnter, I simply subtract from the RGB of the renderer components. And OnMouseExit, I add back to normal. Works well enough.

I also got my cop to actually capture criminals now. He simply has to move onto the same tile as one, press Q (the contextual action button), and expend as much AP as the toughness of the criminal to put him in jail!

Actually, I should probably add some display on the UI to say what the contextual action will be as well. The idea is that some tiles will have special effects that can be triggered for AP: increasing public safety, decreasing spawn rates, etc

And lastly, I added a warning when the player attempts an action they do not have enough AP for. Which basically just required adding a new UI component. Unfortunately, the amount of UI update calls that are happening is starting to get a little out of hand. I feel like I need to consolidate them all and have a general update function at the end of each frame to ensure all the specific UI pieces are up to date.

Really, the best part about doing this blog is giving me a bit of a wind-down time at the end of the day to think about the project, realize mistakes I may have made or alternatives I could try, and come up with plans for the next day.