Skip to main content

How to create a turnbasedturn-based system with aan unknown number of enemysenemies?

This is my first time using Unity (and my third time creating a game in general), so I hope I can provide the needed information to solve this problem.

I want to create a turnbasedturn-based system for my 2D Top/Down RougelikeRoguelike. After the Generationgeneration of the dungeon, there will spawnbe x Enemysenemies spawned based of choosenon chosen difficulty and choosenchosen quest.

How should each turn look like?
Player for example is aan Orc, so he gets 7 movement. (meaning he can move 7 tiles.)
 . In his turn he can move for example 3 tiles, then attack, 2 tiles, use a potion and then uses his last 2 tiles of movement. And then he presses "End Turn" and then the enemysenemies go through theretheir turns (based ofon which typtype of creature therethey are). The Playerplayer can skip his turn completlycompletely, attack and dontdon't move or only move. But he always needs to press the "End Turn" Buttonbutton.

What I would do, tooto solve this issue:
I would create a boolean for every single enemy and the player, then turn them true or false. And whateverwhenever boolean is true, that person can do his turn. But to check this, I would need to put it in the "Update" method. So on every frame there would be x+1 checks (all Enemysenemies plus player), who can move or not.

A second idea would be, to put the player and the enemy in aan array, sort by speed variable (so who goes first, and who goes last) and then I would have my turn order without any boolean. But this still leaves the question, how I would prevent the player of moving or doing stuff, while it is not therehis turn.

I dont thingdon't think any of them would be a good idea. Since I use now Unity, I hope there is a better option for this. And just a heads up, english isntEnglish isn't my first language, but I hope you can understand me. I will happily answer any question.

How to create a turnbased system with a unknown number of enemys?

This is my first time using Unity (and my third time creating a game in general), so I hope I can provide the needed information to solve this problem.

I want to create a turnbased system for my 2D Top/Down Rougelike. After the Generation of the dungeon, there will spawn x Enemys based of choosen difficulty and choosen quest.

How should each turn look like?
Player for example is a Orc, so he gets 7 movement. (meaning he can move 7 tiles.)
  In his turn he can move for example 3 tiles, then attack, 2 tiles, use a potion and then uses his last 2 tiles of movement. And then he presses "End Turn" and then the enemys go through there turns (based of which typ of creature there are). The Player can skip his turn completly, attack and dont move or only move. But he always needs to press the "End Turn" Button.

What I would do, too solve this issue:
I would create a boolean for every single enemy and the player, then turn them true or false. And whatever boolean is true, that person can do his turn. But to check this, I would need to put it in the "Update" method. So on every frame there would be x+1 checks (all Enemys plus player), who can move or not.

A second idea would be, to put the player and the enemy in a array, sort by speed variable (so who goes first, and who goes last) and then I would have my turn order without any boolean. But this still leaves the question, how I would prevent the player of moving or doing stuff, while it is not there turn.

I dont thing any of them would be a good idea. Since I use now Unity, I hope there is a better option for this. And just a heads up, english isnt my first language, but I hope you can understand me. I will happily answer any question.

How to create a turn-based system with an unknown number of enemies?

This is my first time using Unity (and my third time creating a game in general), so I hope I can provide the needed information to solve this problem.

I want to create a turn-based system for my 2D Top/Down Roguelike. After the generation of the dungeon, there will be x enemies spawned based on chosen difficulty and chosen quest.

How should each turn look like?
Player for example is an Orc, so he gets 7 movement (meaning he can move 7 tiles). In his turn he can move for example 3 tiles, then attack, 2 tiles, use a potion and then uses his last 2 tiles of movement. And then he presses "End Turn" and then the enemies go through their turns (based on which type of creature they are). The player can skip his turn completely, attack and don't move or only move. But he always needs to press the "End Turn" button.

What I would do, to solve this issue:
I would create a boolean for every single enemy and the player, then turn them true or false. And whenever boolean is true, that person can do his turn. But to check this, I would need to put it in the "Update" method. So on every frame there would be x+1 checks (all enemies plus player), who can move or not.

A second idea would be to put the player and the enemy in an array, sort by speed variable (so who goes first, and who goes last) and then I would have my turn order without any boolean. But this still leaves the question, how I would prevent the player of moving or doing stuff while it is not his turn.

I don't think any of them would be a good idea. Since I use now Unity, I hope there is a better option for this. And just a heads up, English isn't my first language, but I hope you can understand me. I will happily answer any question.

Source Link

How to create a turnbased system with a unknown number of enemys?

This is my first time using Unity (and my third time creating a game in general), so I hope I can provide the needed information to solve this problem.

I want to create a turnbased system for my 2D Top/Down Rougelike. After the Generation of the dungeon, there will spawn x Enemys based of choosen difficulty and choosen quest.

How should each turn look like?
Player for example is a Orc, so he gets 7 movement. (meaning he can move 7 tiles.)
In his turn he can move for example 3 tiles, then attack, 2 tiles, use a potion and then uses his last 2 tiles of movement. And then he presses "End Turn" and then the enemys go through there turns (based of which typ of creature there are). The Player can skip his turn completly, attack and dont move or only move. But he always needs to press the "End Turn" Button.

What I would do, too solve this issue:
I would create a boolean for every single enemy and the player, then turn them true or false. And whatever boolean is true, that person can do his turn. But to check this, I would need to put it in the "Update" method. So on every frame there would be x+1 checks (all Enemys plus player), who can move or not.

A second idea would be, to put the player and the enemy in a array, sort by speed variable (so who goes first, and who goes last) and then I would have my turn order without any boolean. But this still leaves the question, how I would prevent the player of moving or doing stuff, while it is not there turn.

I dont thing any of them would be a good idea. Since I use now Unity, I hope there is a better option for this. And just a heads up, english isnt my first language, but I hope you can understand me. I will happily answer any question.