Team Manager Script

This is the longest script at the moment out of all the other scripts. This is gonna be fun to talk about!

To start off again, here are the variables which will be used. So, the first part is it will be calling the game objects that are teamMembers and enemies. Nothing too difficult. The next is an int that will keep track of the current turn the battle is in.

Two materials will be called, one that is for active and one that is inactive. This is so it is easier to see whether a certain character will be making a decision or not.

Finally, the UI will be called, specifically the turn button and the buff panel, for now.

So, an easy start!

At the start of the game, the script will call for objects which has the tag of Player and enemies. It will also disable the buff panel since it will not be in use on the first phase.

Now, something that is honestly, very difficult to understand.

This line of code. Oh my. OK.

Pretty much, if you click on a character, it will set them as active.

Wow.

Insane.

Well, actually not. It will call the SetActiveMember, which is the next piece of code!

Wow, it is SetActiveMember! Was it a journey to get here? You need some refreshments? I shall provide. Don’t worry about it!

Now, this will cast another ray from the camera to wherever the player’s mouse is pointing. It will then call the HandleMemberSelection. Which is the next part! It is like I planned this. Damn.

Now, this is a chonker, but honestly, it is nothing too difficult. Once the HandleMemberSelection is called, this piece will activate.

The first thing it does is that it will change the isActive boolean to true for the selected character, as well as apply the material activeM. This way the player knows that this is the character they selected, and it can be moved.

Then it says, if the teamMembers is not active, it will run the next few lines. If it is active, then it will break

So, if it is not active, it will change the isActive boolean to false. It will then check if said character has made a decision. If it has not, then it will change the material to inactiveM, indicating that it will be doing nothing.

This part though. Oof. It is something.

All it does is increase the current turn by 1. The next part then says that once the number hits 3, it resets back to 0. So, the turn counter is 0, 1 and 2. It starts at 0.

Alright. Here comes the first part of the actual turn based system. Or is it?

Anyways. As I said before, the counter starts at 0. So, on turn 0, the CharacterMovement script will be enabled and the CharacterShoot will be disabled. It then breaks.

On turn 1, the CharacterMovement is disabled and the buffPanel is now active. The it breaks.

On turn 2, the CharacterMovement is still disabled, the CharacterShoot is enabled and the buffPanel is disabled.

Quite simple.

This part literally says what will happen during the attacking phase. So the players characters will be able to apply damage, and the enemies AI for attacking will do their attack as well. It then says that the button will change it’s text once it is clicked. It will turn to the next phase.

For now, we have not included any buffs for the characters, so there is only a debug to say setting buffs. The player clicks the button and the text changes again.

Same as the attacking phase, the character movement will occur, as well as the AI movement script.

Same as before, click the button, and it changes its text.

The final part! Yay!

All it says is what each turn is, and what is done in each turn. For example, in turn 0, the MoveAllCharacter part is active, then breaks. Same with turn 1 and 2. It also increases the counter each turn.

Leave a comment

Design a site like this with WordPress.com
Get started