- Home /
How do you create and control a proper turn manager?
For context, as I'm unsure how to post code here, I will try to explain as much of the logic of the code I am trying to create here. I am creating a board game, with multiple players. I followed a turn manager guide online that used a Queue based system which in essence works perfectly, but it is not what I am looking for. What I'm looking to have is a means of creating something to hold variables (the players) and a means of manually selecting who's turn it will be. Now I have the "who's turn is it" figured out in the idea of cycling between the variables, but I can't figure out how to assign turn order. If there's 4 players, but I want to manually assign the turn order, I'm not sure how to do that.
The things I'm missing from my logic is whether or not to hold the variables in an array, list, or dictionary, and what the variables will be. Each player piece is different (won't go into details) but they each have different amount of spaces they can move, thus each is unique. My thought process is to use the variables in whatever to store them into as GameObjects, but I'm not sure how I would go about doing that.
TLDR in steps:
Players select a character they want to play.
The game would add this character to a list/array/dictionary.
After each slot is taken, the game will select the turn order. I figured I could manually assign first and then add a shuffle later, but thinking out loud it might be easier just to shuffle off the bat.
Basically create something along the lines of Mario party turn order/character selection where a player selects a character, that character cannot be chosen twice, once all players have readied, then the turn order will be shuffled.
I mean, you'd give every player an ID, you'd then create all your relevant game data in a class that would be stored with the player ID, then you'd create a list or array using each of these playerID-DataClass sets, and have an ActivePlayer member in your manager so you know who's active, or an intID of the active player, then when a player attempts to make a move it checks if its their turn and if not, rejects the move. Then you'd create a class that handles the linear process of your board games "Turn" So you'd code each "Step" of a turn, you could even create a TurnStep interface that you use to expand your TurnSteps from, with Parameters like
public TurnStep[] Steps;
private int step = 0;
private int subStep = 0;
public enum StepAction()
{
RollDice,
$$anonymous$$ovePiece,
DrawCard,
PassTurn
}
public void PerformAction(StepAction actionType)
{
if (Steps[step].SubSteps[subStep] == actionType)
{
if (actionType == StepAction.DrawCard)
{
PerformDrawCard();
$$anonymous$$oveNextStep();
}
}
}
public void $$anonymous$$oveNextStep()
{
if (subStep + 1 < Steps[step].SubSteps.Length)
{
subSteps++;
//Display new Sub Step info
}
else
{
if (step + 1 < Steps.Length)
{
step++;
//Display new Step Info
}
else
{
$$anonymous$$oveNextPlayer(); //Or display a "Finish Turn" button
}
}
}
void $$anonymous$$oveNextPlayer()
{
//Display turn complete info
BoardGame$$anonymous$$anager.$$anonymous$$oveToNextPlayer();
}
How do you want to store your data in the end? aka Written to file , server or is this a stand alone game
What type of game is it? Online, offline. what?
Do you want a random selection or a set selection for the players turns this needs to be decided as the logic's are different?
Do you want this to be usable for other applications or simply just this one?
How much do you know about c# and how far along are you?
Do you have any images, code, example to show us to help a bit more?
This is a place for questions and answers NOT a place for people to pre-write code for you, I myself was criticized for writing people code.
Q:"For context, as I'm unsure how to post code here,"
A:4 spaces before each line. if you want to indent 4 more spaces. The window also if pasting will take tabs into consideration, but if you try and hit tab on your keyboard, it wont work. For more info hold your mouse over the text box sometimes it pops up with a tool tip.of course... Isn't doing it when i try to test.
Your answer
![](https://koobas.hobune.stream/wayback/20220612192027im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to send/copy array from dictionary to class and further to list of class 0 Answers
How to check if the string is on a text file 0 Answers
Nested Dictionary Change Value Problem 3 Answers
Split Textasset into List 1 Answer
A node in a childnode? 1 Answer