Beispiel #1
0
    private void SpawnPlayers(int winnerId)
    {
        List <PlayerInfos> playerInfosList;

        playerInfosList = VariablesGlobales.GetAllPlayers();


        if (playerInfosList == null)
        {
            return;
        }
        if (playerInfosList.Count < 3)
        {
            //Deux joueurs
            foreach (PlayerInfos p in playerInfosList)
            {
                GameObject playerObject;
                if (p.GetBoatId() == BLUE_BOAT_ID)
                {
                    playerObject = Instantiate(GetBlueModel(), new Vector3(0, 100, 0), Quaternion.Euler(0, 180, 0));
                }
                else
                {
                    playerObject = Instantiate(GetRedModel(), new Vector3(0, 100, 0), Quaternion.Euler(0, 180, 0));
                }

                playerObject.GetComponent <Player>().InstantiateCeleb(p, p.GetBoatId() == winnerId, p.GetBoatId() == winnerId ? 0 : 5);
            }
        }
        else
        {
            //4 joueurs
            playerInfosList.Sort((a, b) => (a.GetBoatId() != b.GetBoatId())? 1 : 0);
            float blue_offset = 6;
            float red_offset  = 6;
            foreach (PlayerInfos p in playerInfosList)
            {
                GameObject playerObject;
                if (p.GetBoatId() == BLUE_BOAT_ID)
                {
                    playerObject = Instantiate(GetBlueModel(), new Vector3(0, 100, 0), Quaternion.Euler(0, 180, 0));
                    playerObject.GetComponent <Player>().InstantiateCeleb(p, p.GetBoatId() == winnerId, blue_offset);
                    blue_offset = -6;
                }
                else
                {
                    playerObject = Instantiate(GetRedModel(), new Vector3(0, 100, 0), Quaternion.Euler(0, 180, 0));
                    playerObject.GetComponent <Player>().InstantiateCeleb(p, p.GetBoatId() == winnerId, red_offset);
                    red_offset = -6;
                }
            }
        }
    }
Beispiel #2
0
    private void SpawnPlayers()
    {
        List <PlayerInfos> playerInfosList;

        playerInfosList = VariablesGlobales.GetAllPlayers();


        if (playerInfosList == null)
        {
            return;
        }
        if (playerInfosList.Count < 3)
        {
            //Deux joueurs
            foreach (PlayerInfos p in playerInfosList)
            {
                GameObject playerObject;
                if (p.GetBoatId() == BLUE_BOAT_ID)
                {
                    playerObject = Instantiate(GetBlueModel(), new Vector3(0, 100, 0), Quaternion.identity);
                }
                else
                {
                    playerObject = Instantiate(GetRedModel(), new Vector3(0, 100, 0), Quaternion.identity);
                }
                playerObject.GetComponent <Player>().Instantiate(p, 0);
            }
        }
        else
        {
            //4 joueurs
            playerInfosList.Sort((a, b) => (a.GetBoatId() != b.GetBoatId())? 1 : 0);
            float offset = 5;
            foreach (PlayerInfos p in playerInfosList)
            {
                GameObject playerObject;
                if (p.GetBoatId() == BLUE_BOAT_ID)
                {
                    playerObject = Instantiate(GetBlueModel(), new Vector3(0, 100, 0), Quaternion.identity);
                }
                else
                {
                    playerObject = Instantiate(GetRedModel(), new Vector3(0, 100, 0), Quaternion.identity);
                }
                playerObject.GetComponent <Player>().Instantiate(p, offset);
                offset = offset - (Mathf.Sign(offset) * 10);
            }
        }
    }