예제 #1
0
 /// <summary>
 /// Create horizontal split screen with n segments. The number of segments is controlled by the number of cameraControllers passed in.
 /// This should only be called once (it is not possible to change the split screen config at runtime, at least, not right now.
 /// If called twice or more, all but the first method calls are ignored.
 /// </summary>
 /// <param name="game">The game this DisplayController belongs to</param>
 /// <param name="cameraControllers">The cameras to place in the split screen, in order</param>
 /// <param name="totalFOV">The total FOV of the screen</param>
 public static void CreateHorizontalScreens(Game game, List <CameraController> cameraControllers, float totalFOV)
 {
     if (displayController_ == null)
     {
         displayController_ = new DisplayController(game, cameraControllers, totalFOV);
     }
 }
 /// <summary>
 /// Create horizontal split screen with n segments. The number of segments is controlled by the number of cameraControllers passed in.
 /// This should only be called once (it is not possible to change the split screen config at runtime, at least, not right now.
 /// If called twice or more, all but the first method calls are ignored.
 /// </summary>
 /// <param name="game">The game this DisplayController belongs to</param>
 /// <param name="cameraControllers">The cameras to place in the split screen, in order</param>
 /// <param name="totalFOV">The total FOV of the screen</param>
 public static void CreateHorizontalScreens(Game game, List<CameraController> cameraControllers, float totalFOV)
 {
     if (displayController_ == null) displayController_ = new DisplayController(game, cameraControllers, totalFOV);
 }
예제 #3
0
        // private constructor: use factory methods instead
        private Engine(Game game, List <GamerProfile> sortedProfiles,
                       List <KeyConfig> localPlayerInputConfigs, out Dictionary <byte, LinkedList <CarActor> > idCarActorMap)
        {
            this.game = game;

            // create a physics system:
            world = new defaultPhysicsSystem();

            // set it as the current
            Engine.currentWorld = world;

            // setup lists for components, cameras and for networking:
            Components           = new List <GameComponent>();
            DrawableComponents   = new List <DrawableGameComponent>();
            LateDrawComponents   = new List <DrawableGameComponent>();
            OverlayComponents    = new List <DrawableGameComponent>();
            carActors            = new List <CarActor>();
            cameraControllerList = new List <CameraController>();
            idCarActorMap        = new Dictionary <byte, LinkedList <CarActor> >();

            // create the track
            int totalCars = 0;

            foreach (GamerProfile gp in sortedProfiles)
            {
                totalCars += gp.numCars;
            }
            track = TrackManager.CreateTrack(game, totalCars);
            this.AddComponent(track);

            // create the car Actors & players
            int carCount = 0;

            foreach (GamerProfile profile in sortedProfiles)
            {
                LinkedList <CarActor> cars = new LinkedList <CarActor>();

                // create the carActors
                for (int i = 0; i < profile.numCars; i++)
                {
                    // create the carRenderer
                    CarModelRenderer carModelRenderer = new DefaultCarModelRenderer(game, (DefaultCarModelRenderer.TextureColourScheme)(carCount + 2 % (int)(DefaultCarModelRenderer.TextureColourScheme.Count)));

                    // add the car to the list
                    CarActor carActor = new defaultCarActor(game, carModelRenderer, Matrix.Identity); // all start off at origin. Moved at Initialize
                    carActors.Add(carActor);
                    cars.AddLast(carActor);
                    AddComponent(carActor);
                    carCount++;

                    // decorate the carActor with a particle system
                    AddComponent(new ParticleController(game, carActor));

                    //add HUD for player
                    //HUD hud = new HUD(game, carActor);
                    //OverlayComponents.Add(hud);
                    //Components.Add(hud);

                    // if player is local, setup the local cameras and input schemes:
                    if (profile.isLocal)
                    {
                        CameraController c = new CameraController(game, carActor);
                        this.AddComponent(c);
                        //if (cameraControllerList.Count == 0)
                        cameraControllerList.Add(c);
                        CarSoundManager soundManager = new CarSoundManager(carActor, c, game);
                        AddComponent(new Player(game, carActor, localPlayerInputConfigs[i], c));
                        AddComponent(soundManager);
                    }
                }

                // register gamer into map
                idCarActorMap.Add(profile.gamerId, cars);
            }

            // setup split screen
            DisplayController.CreateHorizontalScreens(game, cameraControllerList, MathHelper.PiOver4);
            AddComponent(DisplayController.Display);



            // draw skybox, then bloom, then fps on top
            LateDrawComponents.Add(new SkyBoxActor(game));


            //FrameRateCounter fpsDisplay = new FrameRateCounter(game);
            //OverlayComponents.Add(fpsDisplay);
            //Components.Add(fpsDisplay);
        }