<commit_before>﻿using Assets.Scripts.Networking;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using System;
using System.Collections;
using Assets.Scripts.Player;
using UnityEngine.UI;

namespace Assets.Scripts.UI
{
    class VictoryScreenController : NetworkBehaviour
    {
        [Header("Time of victory screen in seconds")]
        public float vicotoryScreenTime = 4;
        public RectTransform scoresHolder;
        public GameObject playerScorePrefab;

        private NetworkLobbyController lobbyController;

        void Start()
        {
            lobbyController = (NetworkLobbyController)NetworkManager.singleton;
            FillScoreboard();
            StartCoroutine(PrepareToDisconnect());
        }

        private void FillScoreboard()
        {
            PlayerDataHolder playerData;
            GameObject newPlayerScore;
            GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
            int totalPoints = 0;
            float offset = 0.0f;
            Vector2 newAnchorMax;
            Vector2 newAnchorMin;

            foreach (GameObject go in players)
            {
                playerData = go.GetComponent<PlayerDataHolder>();
                totalPoints += playerData.GetPoints();
            }

            for(int i = 0; i < players.Length; i++)
            {
                newPlayerScore = Instantiate(playerScorePrefab, scoresHolder);
                playerData = players[i].GetComponent<PlayerDataHolder>();
                newPlayerScore.GetComponent<Image>().color = PlayerColor.GetColor(playerData.GetPlayerNetworkId());
                newAnchorMax = ((RectTransform)newPlayerScore.transform).anchorMax;
                newAnchorMin = ((RectTransform)newPlayerScore.transform).anchorMin;
                newAnchorMin.x = offset;
                newAnchorMax.x = offset + 1/players.Length;
                offset = newAnchorMax.x;
                newAnchorMax.y = totalPoints / (float)playerData.GetPoints();
                ((RectTransform)newPlayerScore.transform).anchorMax = newAnchorMax;
                ((RectTransform)newPlayerScore.transform).anchorMin = newAnchorMin;<commit_msg>Sample scoreboard implemented<commit_after>﻿using Assets.Scripts.Networking;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using System;
using System.Collections;
using Assets.Scripts.Player;
using UnityEngine.UI;

namespace Assets.Scripts.UI
{
    class VictoryScreenController : NetworkBehaviour
    {
        [Header("Time of victory screen in seconds")]
        public float vicotoryScreenTime = 4;
        public RectTransform scoresHolder;
        public GameObject playerScorePrefab;

        private NetworkLobbyController lobbyController;

        void Start()
        {
            lobbyController = (NetworkLobbyController)NetworkManager.singleton;
            FillScoreboard();
            StartCoroutine(PrepareToDisconnect());
        }

        /*
         * <NAME> forgive me...
         */
        private void FillScoreboard()
        {
            PlayerDataHolder playerData;
            GameObject newPlayerScore;
            GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
            int totalPoints = 0;
            int playerPoints = 0;
            float offset = 0.0f;
            Vector2 newAnchorMax;
            Vector2 newAnchorMin;

            foreach (GameObject go in players)
            {
                playerData = go.GetComponent<PlayerDataHolder>();
                totalPoints += playerData.GetPoints();
            }

            for(int i = 0; i < players.Length; i++)
            {
                newPlayerScore = Instantiate(playerScorePrefab, scoresHolder);
                playerData = players[i].GetComponent<PlayerDataHolder>();
                newPlayerScore.GetComponent<Image>().color = PlayerColor.GetColor(playerData.GetPlayerNetworkId());

                newAnchorMax = ((RectTransform)newPlayerScore.transform).anchorMax;
                newAnchorMin = ((RectTransform)newPlayerScore.transform).anchorMin;
                newAnchorMin.x = offset;
                newAnchorMax.x = offset + 1/(float)players.Length;
                offset = newAnchorMax.x;

                if (totalPoints > 0)
                {
                    playerPoints = playerData.GetPoints();
                    if (playerPoints <= 0)
                    {
                        playerPoints = 1;
                    }
                    newAnchorMax.y = totalPoints / (float)playerPoints;
                }
                else
                {
                    newAnchorMax.y = 1 / (float)players.Length;
                }
                ((RectTransform)newPlayerScore.transform).anchorMax = newAnchorMax;
                ((RectTransform)newPlayerScore.transform).anchorMin = newAnchorMin;
{'fraction_non_alphanumeric': 0.08251633986928104, 'fraction_numerical': 0.00428921568627451, 'mean_word_length': 2.0172520024645717, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4032229', 'n_tokens_mistral': 1214, 'n_tokens_neox': 1147, 'n_words': 233}