Esempio n. 1
0
    private void ShowCrazyTexts()
    {
        PlayerScript p1, p2, p3, p4;

        p1 = GameObject.FindGameObjectWithTag("Player1").GetComponent <PlayerScript>();
        p2 = GameObject.FindGameObjectWithTag("Player2").GetComponent <PlayerScript>();
        p3 = GameObject.FindGameObjectWithTag("Player3").GetComponent <PlayerScript>();
        p4 = GameObject.FindGameObjectWithTag("Player4").GetComponent <PlayerScript>();

        PlayerScript[] players = new PlayerScript[] { p1, p2, p3, p4 };

        var mostMove  = players.Aggregate((i1, i2) => i1.DistanceMoved > i2.DistanceMoved ? i1 : i2);
        var leastMove = players.Aggregate((i1, i2) => i1.DistanceMoved < i2.DistanceMoved ? i1 : i2);

        var mostPoints  = players.Aggregate((i1, i2) => i1.Points > i2.Points ? i1 : i2);
        var leastPoints = players.Aggregate((i1, i2) => i1.Points < i2.Points ? i1 : i2);

        var mostDeaths  = players.Aggregate((i1, i2) => i1.PlayerDeaths > i2.PlayerDeaths ? i1 : i2);
        var leastDeaths = players.Aggregate((i1, i2) => i1.PlayerDeaths < i2.PlayerDeaths ? i1 : i2);

        var mostCollisions  = players.Aggregate((i1, i2) => i1.NumberOfBounces > i2.NumberOfBounces ? i1 : i2);
        var leastCollisions = players.Aggregate((i1, i2) => i1.NumberOfBounces < i2.NumberOfBounces ? i1 : i2);

        GameObject playerWin = null;

        switch (mostPoints.playerId)
        {
        case 1:
            playerWin = Player1Text;
            break;

        case 2:
            playerWin = Player2Text;
            break;

        case 3:
            playerWin = Player3Text;
            break;

        case 4:
            playerWin = Player4Text;
            break;
        }

        GameObject playerCollision = null;

        switch (mostCollisions.playerId)
        {
        case 1:
            playerCollision = Player1Text;
            break;

        case 2:
            playerCollision = Player2Text;
            break;

        case 3:
            playerCollision = Player3Text;
            break;

        case 4:
            playerCollision = Player4Text;
            break;
        }

        GameObject playerLeastMove = null;

        switch (leastMove.playerId)
        {
        case 1:
            playerLeastMove = Player1Text;
            break;

        case 2:
            playerLeastMove = Player2Text;
            break;

        case 3:
            playerLeastMove = Player3Text;
            break;

        case 4:
            playerLeastMove = Player4Text;
            break;
        }

        GameObject playerTerrible = null;

        switch (leastPoints.playerId)
        {
        case 1:
            playerTerrible = Player1Text;
            break;

        case 2:
            playerTerrible = Player2Text;
            break;

        case 3:
            playerTerrible = Player3Text;
            break;

        case 4:
            playerTerrible = Player4Text;
            break;
        }

        var go = Instantiate(TextPositions) as GameObject;

        var winPos = GameObject.Find("WinPlayerPos").transform.position;

        winPos = new Vector3(winPos.x, winPos.y, 20);
        Instantiate(playerWin, winPos, Quaternion.identity);

        var collPos = GameObject.Find("MariachiPlayerPos").transform.position;

        collPos = new Vector3(collPos.x, collPos.y, 20);
        Instantiate(playerCollision, collPos, Quaternion.identity);

        var movePos = GameObject.Find("SiestaPlayerPos").transform.position;

        movePos = new Vector3(movePos.x, movePos.y, 20);
        Instantiate(playerLeastMove, movePos, Quaternion.identity);

        var terriblePos = GameObject.Find("TerriblePlayerPos").transform.position;

        terriblePos = new Vector3(terriblePos.x, terriblePos.y, 20);
        Instantiate(playerTerrible, terriblePos, Quaternion.identity);
        //   Instantiate(playerWin);
    }