I am having hassle growing and understanding Server code. Presently, I am attempting to have every individual that joins the Server be given a single digit ID that may then be used for figuring out flip order and plenty of different issues (ex: specify whose card to position the place). Because it stands, I attempted just a few variations, however the debug message indicating who ought to go first does not print and could not consider a approach for it to run DetermineFirstPlayer() after each gamers take part after the server is already current.
public class ServerManager : NetworkBehaviour
{
public MyNetworkManager MyNetworkManager;
personal Listing<Card> cardPool = new Listing<Card>();
personal Listing<Participant> gamers = new Listing<Participant>();
personal Dictionary<Participant, Listing<Card>> playerHands = new Dictionary<Participant, Listing<Card>>();
personal Listing<Card> gameBoard = new Listing<Card>();
personal Listing<Card> graveyard = new Listing<Card>();
personal Dictionary<Participant, int> playerNumbers = new Dictionary<Participant, int>();
personal int currentPlayerIndex = 0; // Index of the present participant within the gamers listing
// Methodology to find out the primary participant
personal void DetermineFirstPlayer()
{
// Shuffle the listing 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 listing of gamers
personal void ShufflePlayers()
{
for (int i = 0; i < gamers.Rely; i++)
{
Participant temp = gamers[i];
int randomIndex = Random.Vary(i, gamers.Rely);
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 purchasers
// Methodology to deal with participant actions (e.g., enjoying a card, attacking, and so on.)
}