Question by
kaitoren · Feb 08, 2019 at 09:30 PM ·
c#script.turn-based
How can I control the turns of 4 players?
Hi! I'm making a little turn based game where 4 players can play it. To perform the basic aspects of the game I was running it with only 2 players in this way:
private IEnumerator WhoTurn()
{
//this command manages the turn of the players based on a int variable, which control the movement of every player
if (whosTurn == 1)
{
GameController.MovePlayer(1);
}
else if (whosTurn == -1)
{
GameController.MovePlayer(2);
}
whosTurn = whosTurn * -1;
yield return 0;
}
But this formula only works with 2 players, and I can not think of a way to make an Ienumerator capable of controlling the turns of 4 players. Could someone suggest me some way to do this? Thank you very much.
Comment
some like?
public int maxPlayers = 2;
private IEnumerator WhoTurn()
{
//this command manages the turn of the players based on a int variable, which control the movement of every player
whosTurn = whosTurn +1;
if(maxPlayers < whosTurn)
whosTurn = 1;
GameController.$$anonymous$$ovePlayer(whosTurn);
yield return 0;
}
Your answer
Follow this Question
Related Questions
Can someone please help me find out what wrong with my code. 0 Answers
C# - JS problem. 1 Answer
Enabling & Disabling Script via On Click 1 Answer
i need help jump script c# 1 Answer