Compare commits
No commits in common. "f73c19731076c0119ca162d0149dae36533ab0e5" and "503634db53002753bfe5c52236285b308fed3918" have entirely different histories.
f73c197310
...
503634db53
@ -1,14 +1,11 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class ScoringPage : MonoBehaviour
|
public class ScoringPage : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private List<PlayerSticker> playerStickers;
|
[SerializeField] private List<PlayerSticker> playerStickers;
|
||||||
|
|
||||||
private Dictionary<string,int> scoreByUser = new Dictionary<string,int>();
|
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
if(playerStickers == null || playerStickers.Count == 0)
|
if(playerStickers == null || playerStickers.Count == 0)
|
||||||
@ -28,38 +25,10 @@ public void Initialize(Room _room)
|
|||||||
|
|
||||||
gameObject.SetActive(true);
|
gameObject.SetActive(true);
|
||||||
Player[] players = _room.GetOrderedPlayerList().ToArray();
|
Player[] players = _room.GetOrderedPlayerList().ToArray();
|
||||||
|
for (int i = 0; i < players.Length; i++)
|
||||||
foreach (var player in players)
|
|
||||||
{
|
{
|
||||||
scoreByUser[player.id] = 0;
|
|
||||||
getPlayerScore(_room, player);
|
|
||||||
}
|
|
||||||
var sortedList = scoreByUser.ToList();
|
|
||||||
|
|
||||||
scoreByUser = scoreByUser.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);
|
|
||||||
|
|
||||||
List<string> playersId = scoreByUser.Keys.ToList();
|
|
||||||
for ( int i = 0; i < playersId.Count; i++)
|
|
||||||
{
|
|
||||||
Player p = _room.GetPlayerById(playersId[i]);
|
|
||||||
playerStickers[i].gameObject.SetActive(true);
|
playerStickers[i].gameObject.SetActive(true);
|
||||||
playerStickers[i].Initialize( p.name , i);
|
playerStickers[i].Initialize(players[i].name, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getPlayerScore(Room _room, Player _player)
|
|
||||||
{
|
|
||||||
List<Proposition> propostitions = _room.GetPropositionsForPlayer(_player);
|
|
||||||
propostitions.ForEach(p =>
|
|
||||||
{
|
|
||||||
|
|
||||||
if(p.voters != null)
|
|
||||||
{
|
|
||||||
scoreByUser[_player.id] += p.voters.Count;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Debug.Log(_player.name);
|
|
||||||
Debug.Log(scoreByUser[_player.id]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user