public void Resume() { menuUI.DeactivateMenu(); Time.timeScale = 1; for (int i = 0; i < cars.Count; i++) { CarSoundManager soundManager = cars[i].GetComponent <CarSoundManager>(); if (soundManager) { soundManager.Resume(); } } }
public void Pause() { Time.timeScale = 0; for (int i = 0; i < cars.Count; i++) { CarSoundManager soundManager = cars[i].GetComponent <CarSoundManager>(); if (soundManager) { soundManager.Pause(); } } menuUI.ActivatePauseMenu(); }
void Awake() { rigidBody = GetComponent <Rigidbody>(); currentCheckpoint = 0; nextCheckpoint = 0; totalDistance = 0; lap = 0; if (stats) { Init(stats); } carSoundManager = GetComponent <CarSoundManager> (); }
public void DeactivateAllCars() { for (int i = 0; i < cars.Count; i++) { CarAI carAI = cars[i].GetComponent <CarAI>(); if (carAI) { carAI.enabled = false; } CarPlayer carPlayer = cars[i].GetComponent <CarPlayer>(); if (carPlayer) { carPlayer.enabled = false; } // Stop engine sound CarSoundManager soundManager = cars[i].GetComponent <CarSoundManager>(); if (soundManager) { soundManager.StopEngine(); } } }
// 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); }