Exemple #1
0
    public void startGame()
    {
        lobbyScript lScript = lobby.GetComponent <lobbyScript> ();

        lScript.hideLobby();
        game                   = MonoBehaviour.Instantiate(gamePrefab) as GameObject;
        gameManager            = game.GetComponentInChildren <GameManager> ();
        gameManager.NumPlayers = lScript.getNumOfPlayers();
        gameManager.lobby      = lScript;
        gameRunning            = true;
    }
Exemple #2
0
    void Start()
    {
        playerNames = new string[4];
        string[] names = lobby.getNames();
        winScore     = lobby.getWinScore();
        scoreReached = false;
        for (int i = 0; i < names.Length; i++)
        {
            if (names[i] != "")
            {
                playerNames[i] = names[i];
            }
            else
            {
                playerNames[i] = "player " + (i + 1);
            }
        }
        prefabInd  = lobby.getPlayerColorInd();
        NumPlayers = lobby.getNumOfPlayers();
        teams      = lobby.getTeams();
        lobby.hideLobby();

        teamScores    = new int[lobby.getTeams().Length];
        LivingPlayers = new List <GameObject> ();
        playerColors  = new List <Color> ();
        playerColors.Add(new Color32(255, 238, 13, 255));
        playerColors.Add(new Color32(232, 94, 12, 255));
        playerColors.Add(new Color32(234, 0, 255, 255));
        playerColors.Add(new Color32(12, 99, 232, 255));
        playerColors.Add(new Color32(0, 255, 69, 255));
        for (int i = 0; i < playerTexts.Length; i++)
        {
            playerTexts [i].color   = playerColors [i];
            playerTexts [i].enabled = false;
            playerTexts [i].text    = "";
        }

        int NumberOfPlayers = NumPlayers;

        for (int i = 0; i < NumberOfPlayers; i++)
        {
            playerTexts [teams [i]].text   += playerNames [i] + ", ";
            playerTexts [teams [i]].enabled = true;
        }
        for (int i = 0; i < NumberOfPlayers; i++)
        {
            if (playerTexts [i].text.EndsWith(", "))
            {
                playerTexts [i].text = playerTexts [i].text.Substring(0, playerTexts [i].text.Length - 2) + ": 0";
            }
        }

        ParticleSystem[] PSS = PhaseInEffect.GetComponentsInChildren <ParticleSystem> ();
        foreach (ParticleSystem PS in PSS)
        {
            if (PS.duration < PhaseInDelay)
            {
                PhaseInDelay = PS.duration;
            }
        }
        if (PhaseInDelay == float.MaxValue)
        {
            PhaseInDelay = 5.0f;
        }
    }