Esempio n. 1
0
    public void SetupMultiplayerGame()
    {
        _myParticipantId = _playGamesManager.GetMyParticipantId();
        List <Participant> allPlayers = _playGamesManager.GetAllPlayers();

        for (int i = 0; i < allPlayers.Count; i++)
        {
            Vector3 spawningPoint = SpawningPoints[i].transform.position;

            string nextParticipantId = allPlayers[i].ParticipantId;
            if (nextParticipantId == _myParticipantId)
            {
                _localPlayer = Instantiate(PlayerPrefab, spawningPoint, Quaternion.identity);
                _localPlayer.GetComponent <SpriteRenderer>().sprite = PlayerSprite[i];
                Camera.main.GetComponent <MainCameraController>().SetLocalPlayer(_localPlayer);
            }
            else
            {
                _otherPlayer = Instantiate(OtherPlayerPrefab, spawningPoint, Quaternion.identity);
                _otherPlayer.GetComponent <SpriteRenderer>().sprite = PlayerSprite[i];
                _otherParticipantId = nextParticipantId;
            }
        }

        _multiplayerReady = true;
    }