Esempio n. 1
0
    void Awake()
    {
        scoreTexts = GetComponentsInChildren <Text>();
        photonView = GetComponent <PhotonView>();
        foreach (Text text in scoreTexts)//gets all the text elements in this object
        {
            if (text.name == "NameElement")
            {
                playerName = text;
            }
            if (text.name == "KillsElement")
            {
                playerKills = text;
            }
            else if (text.name == "DeathsElement")
            {
                playerDeaths = text;
            }
            else if (text.name == "DamageDealtElement")
            {
                damageDealt = text;
            }
        }
        HUDScript hud = FindObjectOfType <HUDScript>(); //Gets the HUD game object

        hud.ActivateScoreBoard();                       //To ensure this object can find the scoreboard sets it to active
        GameObject scoreRow = GameObject.Find("ScoreRows");

        transform.SetParent(scoreRow.transform);              //Sets the parent to the score rows

        transform.localPosition = new Vector3(0, 0, 0);       //resets the position
        transform.rotation      = new Quaternion(0, 0, 0, 0); //resets the rotation

        ScoreRow[] scoreBoards = FindObjectsOfType <ScoreRow>();
        foreach (ScoreRow scoreBoard in scoreBoards)//Sets the position of the rows under each other.
        {
            this.gameObject.transform.position -= new Vector3(0, 25, 0);
        }

        hud.DeactivateScoreBoard();//Deactivates the scoreboard
    }