コード例 #1
0
 public void DrawTrack(TrackActor owner)
 {
     foreach (ModelMesh mesh in model.Meshes)
     {
         DrawModelMesh(mesh, this.transforms[mesh.ParentBone.Index] * owner.WorldMatrix, false);
     }
 }
コード例 #2
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);
        }