I chose to utilize some free to use assets to spice up my projects a little. Instead of bare-bones mechanics it looks semi believable as a real game. The assets I used are:
Asteroid Pack, by Pixel Make
Star Sparrow Modular Spaceship, by EBAL STUDIOS
Spacescape, byAlex Peterson
Seamless sun texture, by Textures4Photoshop
To create an accurate asteroid generator I made many of the aspects variable. The generator is quite simple and uses random coordinates to place the center of a cluster. Each cluster scatters a number of asteroids around it. All of the asteroids are chosen from a set of 5 prefabs and are both scaled and rotated randomly. This gives the effect that all of them are different from few assets.
The ship’s main ‘PlayerController’ holds most of the information for the ship including; arrays of all of its mount points; all of its attached mining lasers; the current target, etc. The most important array is ‘mounts’, it holds the prefabs of modules for each mount point on the ship. Once the game is run, it creates all of the modules from the prefabs given. The script handles the mouse-based controls of targeting too.
Mounts are derived from the Mounts class, which only contains a target variable to store the current target. The fire function is abstract and needs to be overridden by the module.
Targets are derived from the Target class, which contain health and ‘maxhealth’ variables. The health is automatically set in start. The most important part is the abstract Mine function.
I chose to use the top right for informative UI elements, that includes the health of the current target and the cool-down on the lasers. My bottom left corner is controllable elements, the speed of the ship and whether the ship auto turns to your target. The current target is identified by the blue ring that changes size dependent on the size of the target.