[ad_1]
I am having bother creating and understanding Server code. At present, I am making an attempt to have every person who joins the Server be given a single digit ID that may then be used for figuring out flip order and various different issues (ex: specify whose card to put the place). Because it stands, I attempted a number of variations, however the debug message indicating who ought to go first would not print and could not consider a means for it to run DetermineFirstPlayer() after each gamers take part after the server is already present.
public class ServerManager : NetworkBehaviour
{
public MyNetworkManager MyNetworkManager;
personal Checklist<Card> cardPool = new Checklist<Card>();
personal Checklist<Participant> gamers = new Checklist<Participant>();
personal Dictionary<Participant, Checklist<Card>> playerHands = new Dictionary<Participant, Checklist<Card>>();
personal Checklist<Card> gameBoard = new Checklist<Card>();
personal Checklist<Card> graveyard = new Checklist<Card>();
personal Dictionary<Participant, int> playerNumbers = new Dictionary<Participant, int>();
personal int currentPlayerIndex = 0; // Index of the present participant within the gamers record
// Methodology to find out the primary participant
personal void DetermineFirstPlayer()
{
// Shuffle the record of gamers
ShufflePlayers();
// Get the primary and second gamers after shuffling
Participant firstPlayer = gamers[0];
Participant secondPlayer = gamers[1];
// Set the primary participant as the present participant
currentPlayerIndex = 0;
// Log the names of the primary and second gamers
Debug.Log("First participant: " + firstPlayer.playerName);
Debug.Log("Second participant: " + secondPlayer.playerName);
}
// Methodology to shuffle the record of gamers
personal void ShufflePlayers()
{
for (int i = 0; i < gamers.Depend; i++)
{
Participant temp = gamers[i];
int randomIndex = Random.Vary(i, gamers.Depend);
gamers[i] = gamers[randomIndex];
gamers[randomIndex] = temp;
}
}
// Methodology to initialize the sport
// Methodology to deal with finish flip motion
// Methodology to maneuver to the subsequent participant's flip
// RPC methodology to replace the present participant's activate all shoppers
// Methodology to deal with participant actions (e.g., taking part in a card, attacking, and so forth.)
}
[ad_2]