Example #1
0
    public void spawnAsEndMatch(Player winnerPlayer, Player loserPlayer, int winnerScore, int loseScore)
    {
        gameUI.surrenderButton.gameObject.SetActive(false);
        gameUI.surrenderScreen.SetActive(false);
        temporalEndGame = true;
        foreach (PlayerController player in gameUI.players)
        {
            Transform tmpTransf = null;
            player.ball.SetActive(false);
            player.goalkeeper_obj.SetActive(false);
            player.goalkeeper_cam_obj.SetActive(false);
            player.kicker_cam_obj.SetActive(false);
            player.kicker_obj.SetActive(true);
            endGameCam.SetActive(true);
            if (player.id == winnerPlayer.ActorNumber)
            {
                tmpTransf = gameUI.GetDidWinSpawn(true);
                player.kicker_anim.SetBool("DidWin", true);
            }
            else
            {
                tmpTransf = gameUI.GetDidWinSpawn(false);
                player.kicker_anim.SetBool("DidLose", true);
            }
            player.transform.position = tmpTransf.position;
            player.transform.rotation = tmpTransf.rotation;
        }

        PhotonNetwork.CurrentRoom.CustomProperties["gameEnded"] = true;

        if (PhotonNetwork.IsMasterClient)
        {
            bool isTorneo = (bool)PhotonNetwork.CurrentRoom.CustomProperties["isTorneo"];
            Debug.Log("Es torneo? :" + isTorneo);
            NetworkManager.instance.CrearDueloNormal(winnerPlayer, loserPlayer, Convert.ToInt32(isTorneo));
        }


        if (PhotonNetwork.LocalPlayer.ActorNumber == winnerPlayer.ActorNumber)
        {
            NetworkManager.instance.AddEstadisticasToLocal(true);
            StartCoroutine(gameUI.ActivateWinnerScreen(winnerScore, loseScore, winnerPlayer, loserPlayer));
        }
        else
        {
            NetworkManager.instance.AddEstadisticasToLocal(false);
            StartCoroutine(gameUI.ActivateLoserScreen(winnerScore, loseScore, winnerPlayer, loserPlayer));
        }
    }