コード例 #1
0
    //after 10 seconds since game ended, this function will run
    //makes balls unable to move and reloads map from scratch
    public void restartGame(int teamWonInt)
    {
        //make all server scripts run function pausegame()
        serverBallScript[] allServerScripts = FindObjectsOfType(typeof(serverBallScript)) as serverBallScript[];
        int i;

        for (i = 0; i < allServerScripts.Length; i++)
        {
            //psend endgame rpc to clients
            allServerScripts[i].sendEndGame(teamWonInt);
            //pause game on all server scripts
            allServerScripts[i].pauseGameNow();
        }


        //we need to run the function that restarts server after 10 seconds on main server script b/c if player dissconnects it won't run
        serverStart serverScript = GameObject.FindGameObjectWithTag("server").GetComponent <serverStart>();

        //no longer paused
        GameObject.FindGameObjectWithTag("server").GetComponent <serverStart>().gamePaused = false;
        serverScript.restartGame();
    }
コード例 #2
0
	void endGameTime()
	{

		//so this function only runs once
		runEndGameOnce=true;

		//run end game function
		if(GameObject.FindGameObjectWithTag("Player")!=null)
		{
		serverBallScript serverScript = GameObject.FindGameObjectWithTag("Player").GetComponent<serverBallScript>();
		serverScript.restartGame(2);


		}
		else{
			serverStart serverScript = GameObject.FindGameObjectWithTag("server").GetComponent<serverStart>();
			serverScript.restartGame();


		}



	}