示例#1
0
    private void InitializeLevel()
    {
        IInputController[] inputControllers = InputControllerManager.CreateControllers(configuration.playerCount);
        players = new PlayerController[configuration.playerCount];

        var viewRects = GetViewRects(configuration.playerCount);

        // Find spawn points and hide them from view. We can't unactivate them from elsewhere before used here.
        spawnPoints = FindObjectsOfType <PlayerSpawnPoint>();
        for (int i = 0; i < spawnPoints.Length; i++)
        {
            spawnPoints[i].gameObject.SetActive(false);
        }

        for (int i = 0; i < configuration.playerCount; i++)
        {
            OrbitCameraTP orbitCamera = Instantiate(
                orbitCameraPrefab,
                spawnPoints[i].Position + Vector3.left * 200f,
                spawnPoints[i].Orientation
                );

            orbitCamera.SetInputController(inputControllers[i]);
            orbitCamera.GetCamera().rect = viewRects[i];

            PlayerHudScript hud = Instantiate(
                hudPrefab,
                hudCanvas.transform
                );

            hud.viewportRect = viewRects[i];
            hud.Rebuild();

            players[i] = Instantiate(playerPrefab);

            // Get controller, camera, hud, random color, etc
            players[i].Initialize(
                new PlayerHandle(i),
                orbitCamera,
                inputControllers[i],
                playerColors [i],
                hud
                );

            players[i].Spawn(spawnPoints[i].Position, spawnPoints[i].Forward);
        }

        musicManager.PlayStart();


        judge       = new Judge(players, rules, StartPlayerWinRoutine);
        judge.rules = configuration.rules;
        GameStart();
    }