Week 3
In the third week, the lecturers have shown how to organise the code using C# classes and collections, which helps us to write better code and reduce the number of bugs in our code. After we got introduced in we were asked to create some scripts for a sample project, called Crazy Cube, which was uploaded by our lecturers on Moodle.
Pictures with the scripts:
These two pictures represent the script for the colour gun. I was supposed to create a script which will allow the cube to shoot some paintballs of different colours. The idea of the code is to access the inventory script to check if there is enough "substance" of a colour to shoot. The script checks if there is enough colour and if the "paint" variable is different than "null" than the cube will be able to shoot a random colour.
In this script, I have created a class called "Inventory", the class which the "Gun" script is inheriting the inventory for colours. In the script, I have created a "list" for the colours of the paintballs and a "dictionary" for storing them and accessing them when needed.
This script was created to reload the green colour and to add it to the "inventory".
This script is supposed to show a message with the colour of the next paintball which is about to be shot.
This picture is illustrating the movement script for the cube.
The role of this script is to change the shape of the paintball after it collides with the ground.
No comments:
Post a Comment