C# Advanced basics post-mortem
This time I decided if I want to make bigger projects, I needed to understand more specifically about the C# programming language I use and how it works so I can understand it to make the best fun games as possible.
I even made 3 short mini games as a little exercises to warm myself up.
What I learned
different types of variables like doubles, characters, and colour.
different ways of how variables/ parameters add with each other, e.g. float sum = (2 + 3) * (4 - (4 / 3)).
A better understanding of Enums and how the states can be used. e.g played dies or at main menu waiting for player to press play or restart, what happens next? does he move a inch or not?
The calculated difference of float and int when dividing them respectfully such as calculating the nearest inside numbers (part of floats).
Casting: Converts a variable to another variable. Eg int a = 5 into float a = 5.0f.
How more robust Lists can be, such as being counted, added, removed specifically or all selected, reversed, removed at range and etc. Also, an idea of what its generics are <>.
Different types of functions that can be used like voids, ints, floats and returning their parameters such as strings, ints and floats.
Functions store many parameters as much as they need. Also different types of functions can share the same name, except for the same types.
How effective and distinctive behaviour of If, if else and else statements of controlling mechanics.
Not to have so many if statements in a nested code otherwise it may affect performance of the game.
More detailed info, cleaner code, similarities to the ifs, if else, else statements and how complex switch Statements of how they execute with different variables to run code inside each of the cases and defaults.
the unique behaviour of breaks that break out of the code to execute outside code.
The Different types of loops such as For loops, for each loops, do while loops of how their used respectfully so it doesn't crash the computer on the wrong use.
Better understanding of Arrays of what the elements can contain such as ints, game objects, floats, bools, strings, doubles etc and how it can only be programmed to access their elements not outside its index or length.
How you can change array element values by code without setting its variables.
How for loop doesn't need to be specialised how many times to repeat the loop so it doesn't crash.
Advanced use of Coroutines such as Stopping Coroutines, waiting for seconds in real time (no matter how slow or fast the game is with time scale), how they can pass Parameters and strings to reference other functions and how the waitforseconds can be slowed or speed up by Time.TimeScale.
Passing arrays into void returning functions like ints. The parameters can even have the same names of its variables and it won't cause an error.
How interesting is to model objects from classes each with their variables and to update them overtime.
How useful are constructors when passing variables.
How "this." refers to the class variable and outside the function parameters.
Difference of Objects create that get passed in Memory as references and values.
More detail of Data encapsulation/visibility modifiers other than public or private. I learnt more such as Internal, protected modifiers, setting and getting variables.
A deeper understanding of inheritance such as from Mono behaviour and from other classes such as behaviours, functions, properties and variables.
How Inheritance works with child game classes using override functions to override the virtual function from their parent classes to do something else.
Most functions, datatypes values including transforms which are inherited from Mono behaviour.
The pros and cons of method overloading, while good to use a variety of functions and parameters, but needs to be specific of which function and parameters to run.
The use of the Ternary Operator such as using ? (if) and : (else) respectfully like if statements.
Variable Attributes and such as [RequireComponent], [ExecuteInEditMode], [AddComponentMenu], [HideInInspector], [Range]and [TextArea] which are broadly useful to read and get components to reduce unexpected issues, and makes the life's easier for designers, respectfully.
How static variables and functions can work together with each other's scripts without get components and creating objects. They also don't work with non-static variables and functions.
How Delegates can be used to subscribe or call events from scripts including statics
How to return value answers when adding or subtracting.
How to make log warnings and log errors execute by code in the console depending how the script is written.
-Pumpkins and Golems
The possibility that I can make a game based on its rigid body physics a little more than complex code. E.g dodging rolling pumpkins from a slope, etc
-Bombs Away
Being able to spawn bombs in-between min and max distances with floats randomly from one transform variable.
Being able to restrict players movement with floats, Vector 2 and if statements without using a box collider.
-Knife Hit
Able to add force on knife with either Space or Mouse keys respectfully without causing unwanted design issues or bugs.
Able to set the knife game object to be parent of the wood by collisions and turning off collisions with "Detect Collisions" by turning it false on the knife once collided.
Overall
It was a long and hard work to get a better understanding with these datatype concepts. But I'm glad that I've done it so I can get a better understanding of how C# works so that way once I start to make more complex games, I am more aware of how it works so its easier to understand, fix unexpected bugs, and work differant ways to execute code.
Kommentare