<commit_before>using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System;

public class Manager : MonoBehaviour
{
    // -- CONSTANTS --
    public List<string> teams =
             new List<string> {
        "Blue",
        "Red"
    };

    public Dictionary<string, Color> teamColors =
       new Dictionary<string, Color> {
        {"Blue", new Color(58f/255f, 112f/255f, 225f/255f, 1f)},
        {"Red", Color.red}
    };

    public Dictionary<string, Vector2> spawnLocations =
       new Dictionary<string, Vector2> {
       {"Blue", new Vector2(5f, -1f)},
       {"Red", new Vector2(-5f, 1f)}
    };

    public Dictionary<string, int> teamLayers =
       new Dictionary<string, int> {
       {"Blue", 9},
       {"Red", 10}
    };

    public float manaTime = 10f;
    const int countdownLength = 3;
    const int pointLimit = 5;

    // -- VARIABLES --
	public Dictionary<string, int> teamScores;
	public Dictionary<string, int> teamManas;
	public Dictionary<string, GUIText> teamScoreText;
	public Dictionary<string, ManaBar> teamManaBars;
    public Dictionary<string, GameObject> teamBases;
    public List<Player> allPlayers;
    public Flag flag;
    public GUIText countdownGUIText;
    public GUITexture countdownBackground;

    private float timePassed=0;
    public bool roundStarted = false;
    public bool itemPickups = false;

    static public Manager S {
        get {
            return GameObject.FindObjectOfType(typeof(Manager)) as Manager;
        }
    }

    // -- SETUP --

    void Start() {
        teamScores = InitScores(teams);
		teamManas = InitManas(teams);
        teamScoreText = InitScoreText(teams);
        allPlayers = SpawnPlayers();
        CreateOverlayCamera();
        CreateCountdown();

        if (itemPickups) {
            foreach(GameObject go in GameObject.FindGameObjectsWithTag("ItemSpawn"))
            {
                go.GetComponent<ItemSpawn>().activ=itemPickups;
            }
        }
        else
            teamManaBars = InitManaBars (teams);
        teamBases = teams.ToDictionary(team => team,                                 //key
                                       team => GameObject.FindWithTag(team+"Side")); //value
        flag = GameObject.FindObjectOfType(typeof(Flag)) as Flag;

        StartNewRound(true, null);
    }

    Dictionary<string, int> InitScores(List<string> teamList) {
        return teamList.ToDictionary(t => t, t => 0);
    }
	Dictionary<string, int> InitManas(List<string> teamList) {
		return teamList.ToDictionary(t => t, t => 0);
	}
	
	Dictionary<string, GUIText> InitScoreText(List<string> teamList) {
        GameObject scoreBoard = GameObject.FindWithTag("ScoreBoard");
        return teamList.ToDictionary(t => t, t => {
            GameObject go = Instantiate(Resources.Load("ScoreText")) as GameObject;
            GUIText gt = go.GetComponent<GUIText>();
            float width = .5f / teamList.Count();
            float index = (float)teamList.IndexOf(t);
            go.transform.parent = scoreBoard.transform;
            go.transform.localScale = new Vector2(width, 1);
            go.transform.localPosition = new Vector3(index*width - 0.15f, 0.1f, 1);
            gt.color = teamColors[t];
            gt.fontSize = (int)(Screen.height * 0.04);
            return gt;
        });
    }

	Dictionary<string, ManaBar> InitManaBars(List<string> teamList) {
		return teamList.ToDictionary(t => t, t => {
			GameObject go = Instantiate(Resources.Load("ManaText")) as GameObject;
			ManaBar mb = go.GetComponent<ManaBar>();
			mb.team=t;
			GUIText gt= go.GetComponent<GUIText>();
			float index = (float)teamList.IndexOf(t);
			go.transform.position = new Vector3(Mathf.Abs(index - 0.04f), 0.3f, 1);
			gt.color = teamColors[t];
			return mb;
		});
	}
	
	List<Player> SpawnPlayers() {
		return PlayerOptions.teamForPlayer.Select(kvp => SpawnPlayer(kvp.Value, kvp.Key)).ToList();
    }

    Player SpawnPlayer(string team, int index) {
        GameObject playerGO = Instantiate(Resources.Load("Player")) as GameObject;
        Player player = playerGO.GetComponent<Player>();

        Vector3 initialPos = spawnLocations[team] + (new Vector2(index, index));
        playerGO.transform.position = player.initialPos = initialPos;
        playerGO.layer = teamLayers[team];
        player.team = team;
        player.number = index;
        player.renderer.material.color = teamColors[team];
		player.pickups = itemPickups;

        return player;
    }

    void CreateOverlayCamera() {
        GameObject cameraGO = Instantiate(Resources.Load("UICamera"),
                                          new Vector3(0f,0f,-10f), 
                                          Quaternion.Euler(180, 0, 0)) as GameObject;
        Camera camera = cameraGO.GetComponent<Camera>();
        camera.rect = new Rect(0, 0, 1, 1);
        camera.clearFlags = CameraClearFlags.Nothing;
    }

    void CreateCountdown() {
        GameObject countdownParent = Instantiate(Resources.Load("Countdown")) as GameObject;
        countdownGUIText = countdownParent.GetComponentInChildren<GUIText>();<commit_msg>rework spawn locations for fairness<commit_after>using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System;

public class Manager : MonoBehaviour
{
    // -- CONSTANTS --
    public List<string> teams =
             new List<string> {
        "Blue",
        "Red"
    };

    public Dictionary<string, Color> teamColors =
       new Dictionary<string, Color> {
        {"Blue", new Color(58f/255f, 112f/255f, 225f/255f, 1f)},
        {"Red", Color.red}
    };

    public Dictionary<string, int> teamLayers =
       new Dictionary<string, int> {
       {"Blue", 9},
       {"Red", 10}
    };

    public float manaTime = 10f;
    const int countdownLength = 3;
    const int pointLimit = 5;

    // -- VARIABLES --
    public Dictionary<string, Vector2> spawnLocations =
       new Dictionary<string, Vector2> {
       {"Blue", new Vector2(5f, 0)},
       {"Red", new Vector2(-5f, 0)}
    };
	public Dictionary<string, int> teamScores;
	public Dictionary<string, int> teamManas;
	public Dictionary<string, GUIText> teamScoreText;
	public Dictionary<string, ManaBar> teamManaBars;
    public Dictionary<string, GameObject> teamBases;
    public List<Player> allPlayers;
    public Flag flag;
    public GUIText countdownGUIText;
    public GUITexture countdownBackground;

    private float timePassed=0;
    public bool roundStarted = false;
    public bool itemPickups = false;

    static public Manager S {
        get {
            return GameObject.FindObjectOfType(typeof(Manager)) as Manager;
        }
    }

    // -- SETUP --

    void Start() {
        teamScores = InitScores(teams);
		teamManas = InitManas(teams);
        teamScoreText = InitScoreText(teams);
        allPlayers = SpawnPlayers();
        CreateOverlayCamera();
        CreateCountdown();

        if (itemPickups) {
            foreach(GameObject go in GameObject.FindGameObjectsWithTag("ItemSpawn"))
            {
                go.GetComponent<ItemSpawn>().activ=itemPickups;
            }
        }
        else
            teamManaBars = InitManaBars (teams);
        teamBases = teams.ToDictionary(team => team,                                 //key
                                       team => GameObject.FindWithTag(team+"Side")); //value
        flag = GameObject.FindObjectOfType(typeof(Flag)) as Flag;

        StartNewRound(true, null);
    }

    Dictionary<string, int> InitScores(List<string> teamList) {
        return teamList.ToDictionary(t => t, t => 0);
    }
	Dictionary<string, int> InitManas(List<string> teamList) {
		return teamList.ToDictionary(t => t, t => 0);
	}
	
	Dictionary<string, GUIText> InitScoreText(List<string> teamList) {
        GameObject scoreBoard = GameObject.FindWithTag("ScoreBoard");
        return teamList.ToDictionary(t => t, t => {
            GameObject go = Instantiate(Resources.Load("ScoreText")) as GameObject;
            GUIText gt = go.GetComponent<GUIText>();
            float width = .5f / teamList.Count();
            float index = (float)teamList.IndexOf(t);
            go.transform.parent = scoreBoard.transform;
            go.transform.localScale = new Vector2(width, 1);
            go.transform.localPosition = new Vector3(index*width - 0.15f, 0.1f, 1);
            gt.color = teamColors[t];
            gt.fontSize = (int)(Screen.height * 0.04);
            return gt;
        });
    }

	Dictionary<string, ManaBar> InitManaBars(List<string> teamList) {
		return teamList.ToDictionary(t => t, t => {
			GameObject go = Instantiate(Resources.Load("ManaText")) as GameObject;
			ManaBar mb = go.GetComponent<ManaBar>();
			mb.team=t;
			GUIText gt= go.GetComponent<GUIText>();
			float index = (float)teamList.IndexOf(t);
			go.transform.position = new Vector3(Mathf.Abs(index - 0.04f), 0.3f, 1);
			gt.color = teamColors[t];
			return mb;
		});
	}
	
	List<Player> SpawnPlayers() {
        if (PlayerOptions.teamForPlayer.Count == 0) {
            //for testing without needing to load menu
            PlayerOptions.teamForPlayer[0] = "Red";
            PlayerOptions.teamForPlayer[1] = "Blue";
        }
		return PlayerOptions.teamForPlayer.Select(kvp => SpawnPlayer(kvp.Value, kvp.Key)).ToList();
    }

    Player SpawnPlayer(string team, int index) {
        GameObject playerGO = Instantiate(Resources.Load("Player")) as GameObject;
        Player player = playerGO.GetComponent<Player>();

        Vector3 initialPos = spawnLocations[team];
        spawnLocations[team] = Quaternion.Euler(0,0,20) * spawnLocations[team];
        playerGO.transform.position = player.initialPos = initialPos;
        playerGO.layer = teamLayers[team];
        player.team = team;
        player.number = index;
        player.renderer.material.color = teamColors[team];
		player.pickups = itemPickups;

        return player;
    }

    void CreateOverlayCamera() {
        GameObject cameraGO = Instantiate(Resources.Load("UICamera"),
                                          new Vector3(0f,0f,-10f), 
                                          Quaternion.Euler(180, 0, 0)) as GameObject;
        Camera camera = cameraGO.GetComponent<Camera>();
        camera.rect = new Rect(0, 0, 1, 1);
        camera.clearFlags = CameraClearFlags.Nothing;
    }

    void CreateCountdown() {
        GameObject countdownParent = Instantiate(Resources.Load("Countdown")) as GameObject;
        countdownGUIText = countdownParent.GetComponentInChildren<GUIText>();
{'fraction_non_alphanumeric': 0.11665409279517164, 'fraction_numerical': 0.014145605431912485, 'mean_word_length': 2.5326449033977347, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 85, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1326907', 'n_tokens_mistral': 3330, 'n_tokens_neox': 3113, 'n_words': 683}