top of page

Impulse: Turn Order and Action Select

I have continued to develop my UI and have made several major additions. First of all, I have added a UI element which displays the turn order. I placed 10 panels into the UI, each with a portrait, name field, faction field and acting character icon. When the battle begins, these panels are modified to each represent a character in the scene. The first character in the turn order gets the top panel, the second gets the one under that, and so on. If there are fewer than 10 characters in the scene, any spare panels are made inactive. The acting character icon is then made inactive on all panels other than the one representing the first character in the turn order. When the acting character changes, the previous character's icon turns off, and the new acting character's icon turns on. This system clearly displays all the characters that are in the battle, their name, their faction, and the order in which they will take their turn.


Variables added to the manager script for the turn order UI element:

Code added to the update UI function to manage the turn order UI element:

After this, I moved on to implementing the ability for the player to select their character's action. The simplest action to perform is, of course, no action at all, so that is where I began. I added a small game object to the main UI panel with an image and button component. I then edited the button component settings so that when it is clicked, it calls the "end turn" function in the manager script. I also added code to the managed script so that this button is only visible when the acting character is a player character so that the player cannot skip their enemies' turns:

Finally, I have added functionality to the action buttons in the UI, so that pressing them sets the player's selected action to the character action depicted by the icon. Previously, as movement was the only action available, right clicking on the ground would automatically attempt to move the acting character. As I will soon be implementing various other actions, this was no longer acceptable. As such, I added a "perform action" function to the manager script which will contain each of the actions available to the player characters and execute the selected action when the appropriate conditions are met. As the only action available at the moment is movement, that is all the function contains. This meant that I had to remove the movement code from the update function and place here instead.


Perform action function:

To allow the player to select their action using the action buttons in the UI, I set the buttons to call a new "select action" function in the manager script and pass it an integer. Button 0 passes 0, button 1 passes 1, etc. The manager then set its "action to perform" variable to the action at the given integer in the acting character's action list. The icons on the buttons, of course, also correspond to the actions in the character's action list and so now clicking on the button with the move icon will make "move" your selected action. Once this is done, clicking on an appropriate target for the selected action will cause it to be performed. In the case of movement, as you can see in the image above, clicking on an unoccupied, and within range, square of ground, will cause the character to move there. All the other buttons currently just print their integer to the debug log for testing purposes:

Here's a video of all the new additions:



Comentários


bottom of page