fix: players keep their sticker's color during voting time
This commit is contained in:
parent
9a23f40604
commit
a64ce8c7ac
@ -37,6 +37,16 @@ public Player GetPlayerById(string id)
|
||||
return players[id];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the order of arrival of a player (the first player is 0, the last to connect is player.count-1)
|
||||
/// </summary>
|
||||
/// <param name="p">The player you want to know the position of</param>
|
||||
/// <returns>the position by arrival order</returns>
|
||||
public int GetPlayerOrder(Player p)
|
||||
{
|
||||
return GetOrderedPlayerList().FindIndex(x => x.id == p.id);
|
||||
}
|
||||
|
||||
public List<Player> GetPlayerList()
|
||||
{
|
||||
return new List<Player>(players.Values);
|
||||
|
@ -55,14 +55,12 @@ private void DisplayPicture(string _gsUrl)
|
||||
public void UpdateVoters(List<Player> _newVoters)
|
||||
{
|
||||
//Debug.Log($"There are some new voters for {proposition.owner}'s proposition", this);
|
||||
int index = 0;
|
||||
foreach (Player p in _newVoters)
|
||||
{
|
||||
index++;
|
||||
if (!currentVoters.Keys.Contains(p))
|
||||
{
|
||||
PlayerSticker sticker = Instantiate(voterStickerPrefab, playerGrid).GetComponent<PlayerSticker>();
|
||||
sticker.Initialize(p.name, index);
|
||||
sticker.Initialize(p.name, RoomManager.Instance.myRoom.GetPlayerOrder(p));
|
||||
currentVoters.Add(p, sticker.gameObject);
|
||||
Debug.Log($"{p.name} has just voted for {proposition.owner.name}'s proposition.");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user