diff --git a/Assets/Scripts/DatabaseClasses/Room.cs b/Assets/Scripts/DatabaseClasses/Room.cs
index 8637050..99c7496 100644
--- a/Assets/Scripts/DatabaseClasses/Room.cs
+++ b/Assets/Scripts/DatabaseClasses/Room.cs
@@ -37,6 +37,16 @@ public Player GetPlayerById(string id)
return players[id];
}
+ ///
+ /// Get the order of arrival of a player (the first player is 0, the last to connect is player.count-1)
+ ///
+ /// The player you want to know the position of
+ /// the position by arrival order
+ public int GetPlayerOrder(Player p)
+ {
+ return GetOrderedPlayerList().FindIndex(x => x.id == p.id);
+ }
+
public List GetPlayerList()
{
return new List(players.Values);
diff --git a/Assets/Scripts/PropositionFrame.cs b/Assets/Scripts/PropositionFrame.cs
index a905b12..c6d3d4a 100644
--- a/Assets/Scripts/PropositionFrame.cs
+++ b/Assets/Scripts/PropositionFrame.cs
@@ -55,14 +55,12 @@ private void DisplayPicture(string _gsUrl)
public void UpdateVoters(List _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();
- 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.");
}