********************************************************************************************************************************************************Game-Logic:Alright, we have done a lot of preparation work: camera, background, markers - all done.
Now it's time for the logic, and how this game works.
The logic is done in modular design - it means that all systems are responsible for them-selfs.

- GL.jpg (49.46 KiB) Viewed 927 times
Short Description: First, we want to select our Camera. Then we are turning Off the player controller, in this demo we just don't need any controls except the mouse. Afterwards we are checking if the game was launched first time. If yes, then do some initialization work and then do some HUD and Game introduction logic. If not, then skip all introductions. After all, all modules (e.g. spawning the targets, pick-ups, timer, bullets HUD and reloading and so on...) of the game are up and running.
As you can see, this logic can be simplified, this is because firstly the logic was created to allow us to restart the game with "Jump To N scene" node, but this approach took about 1 minutes to reload the scene (game). So, later play again logic was created without this node.
Before we continue, we should have several variables created, they are needed for power-ups, timers, stats and the game itself.
Variables:A lot of variables just keep tracking our bullets value, debt score, game score, the time, any pick-up if it is enabled or disabled and so on.
********************************************************************************************************************************************************Game-Logic Groups:"Main Menu" this group is used for the main menu in the game. It just showing us a background and a button to start the game.
"Initialization" this group is used for almost all game HUD, variables and objects initializations.
By default we should Remove from the scene all HUD and in-game objects.
Also, all variables should be initialized to their default values.
"Bullets HUD & Reloading" in this group we are doing all work with Bullets HUD and Reloading.
It consists of two loops, and they are connected with each other and before each loop we initialize "Bullets" variable. When we have no "Additional Ammo" power-up small loop will be used, either bigger one.
Loop itself have many interconnected "Bullets" variable tests, and when we have small amount of bullets than before it hides corresponding HUD Bullet image. When we have 0 bullets it's showing HUD Reloading Text. Always after each cycle it tests the "Reload" button, after that we test have we or not "Additional Ammo" power-up, and if yes, then loop should be switched to another one.
"Timer" group consists of very simple game timer, and 2 variable tests. One is testing "GameTimer" and if it equals to 0 then it's The End. Another one is testing "TimeStop" variable and if it equals to 1 it means that we have Time Stop power-up, and timer should be paused for 10 seconds.
"Decor - Clouds" group have one loop, at the beginning of the loop we are adding some clouds to the scene, moving it to its default position marker, and then we have a random event node, we use it to randomly choose the speed.
"Game-Play" consists of 3 groups:
"Targets appearance",
"Power-Ups appearance",
"Clicked? If yes, destroy this object",
OnlyMiss Pick-Up,
StopSpawn Pick-Up.
"Targets appearance" and
"Power-Ups appearance" are very similar, they just have several
"Random Event" nodes used to choose where to spawn the target or power-up, what direction and speed should be used.
"Clicked? If yes, destroy this object" group is just a loop to test if an object was clicked if yes then test for "OnlyMiss" power-up, after this we need to test the bullets. Then if the player have shoot anything then play some random sounds, add some points, or enable a pick-up, and destroy the object.
"Debt Arrow HUD" and
Bullets HUD & Reloading groups are working pretty much the same. Inside them we have a loop in it we are checking bullets count variable value or debt score value and then correspondingly changing the HUD elements. It's very easy to understand, you just need to look through the logic.
Scoring System group is checking what debt value we have, and then it is calculating the game score value as needed.
The End group is responsible to display one of three in-game endings, what ending HUD to show depends on the debt value. Then we are testing if the "Play Again" button was pressed, if yes then restart the game.
********************************************************************************************************************************************************