Battle Manager

The longest script in the game. Yay…

First thing is getting them variables. We have the player and enemy game objects, as well as many other things. It also has materials and counters and a line renderer. Many things this script does…

The awake function. This is called before the start function. Here, we get the game objects of the enemies, set the attack and skill panels off and get the line renderer.

In the start function, it calls the function, draw range indication. That is it.

Here is the way to change characters. As the player presses e or q, it changes the counter, which then changes the player. It either increases the counter or decreases it depending on what button you press.

So, the actual change player function. This will turn the active player to the player count, as well as call the player selection function. It will also move the camera to the active player and draw the range indicator.

It will also change the images of the player skills and guns, depending on the character.

So, the player selection function. It turns on the movement script for that character and applies the active material. It will then get all the other player characters, and turn their movement active function off.

It will then check if the other characters have a decision. If they do not, then it will apply the inactive material.

This is the function that calls skills. It just activates the skill depending on which button you press, and is different for each character. Very nice bit here.

Same as the one above, except for guns. Just applies the guns stats onto the player character that is active, and voila.

This function then calls the passives for every character on the scene, as well as checking whether they have a status effect. Easy stuff.

This function applies the status effect on the characters, if they have status effects to apply.

This function calls for the skills for every enemy. As the boss and mini boss has slightly different functions, it calls them from their respective scripts.

Same as above, but this time is for guns. Only the boss has a specific function for the guns, so it calls it from its script.

As the player and enemies apply skills, they need to be reset every round, so that they do not become super defence every turn. This helps with that.

The death function. Everyone dies eventually, just at different times and different circumstances.

This function checks whether the characters are dead, both players and enemies. If so, it turns off their mesh renderer, activates their gravestone and disables their player stats script.

This little function increases the turn counter. Very nice.

This thicc boi controls what the player can do each phase. So, in the first phase, the movement is enabled, shooting disabled and the attack panel is inactive.

The next phase, the movement is inactive, and the skill panel is active.

The third and final phase, the movement is disabled, shooting enabled, skill panel inactive and the gun panel is active. It then repeats it every turn.

This function is the PERFORM ALL ATTACKS. Everyone deals them damage, either applying or just wildly shooting. The mini boss and boss has different functions for attacking, like before, and the boss also has an extra function to check whether it will lose body parts or not.

It will then change the end turn button to the movement button.

This only changes the end turn button to attacking. Very lonely little function…

This function moves every character on the field. Everyone be shuffling. They are called from the respective scripts.

It also changes the end turn button to the skill sprite.

This is where the actual chonk of the management is. Here you can see what happens in every phase. So, in the first phase, the characters move, the effects are applies, the passives are applied, it checks if anyone has died and resets the stats.

Second phase is similar, except for applying the skills for both players and enemies.

The third phase is also similar, except for applying the enemy guns and performing the attacks.

It will then call the increase turn counter function, to indicate which phase they are on. It will also call the manage phase function, to check what the player can do. Finally it calls the draw range indicator.

This function calls the get active ring function. It then draws the indicator, using a ring and line renderer. It also set the position of the rings centre.

This is function is how the ring is going to be drawn and for whom. It draws the indicator as a circle.

Next it checks what phase of battle it is on. So, the first phase, it will draw the speed range. Second range it will draw nothing. On the third phase, it will draw the ranges for the guns.

It also only draws for the active player, and no one else.

The next part is how the ring is drawn, using cosine and sine stuff… I actually do not know how this works… help…

It then keeps changing depending on which character is active… I think…

Well, hope you enjoyed this specific script…

Leave a comment

Design a site like this with WordPress.com
Get started