public void OnPedestrianHit(Pedestrian ped, Vehicle vehicle) { vehicle.LastRunOverPedTime = GameEngine.TotalSeconds; if (ped.IsHit) { SoundCache.Play(SoundIds.PedSquelch, vehicle, true); return; } NbrDeadPeds++; ped.OnHit(vehicle); if (vehicle == PlayerVehicle) { int time = GeneralSettingsFile.Instance.TimePerPedKill[GameVars.SkillLevel]; RaceTime.TimeRemaining += time; MessageRenderer.Instance.PostTimerMessage(time); } if (NbrDeadPeds == Peds.Count) { GameMode.Current = new RaceCompletedMode(CompletionType.Peds); RaceTime.IsOver = true; } }
public void Exit(Vehicle vehicle) { if (ExitSoundId > 0) { SoundCache.Play(ExitSoundId, vehicle, true); } }
public void Update() { _model.Update(); Audio.Update(); if (CurrentSpecialVolume.Count > 0) { CurrentSpecialVolume.Peek().Update(this); } Chassis.Update(); float maxlat = 0; foreach (VehicleWheel wheel in Chassis.Wheels) { if (Math.Abs(wheel.LatSlip) > maxlat) { maxlat = Math.Abs(wheel.LatSlip); } if (wheel.ShouldPlaySkidSound) { SoundCache.PlaySkid(this, wheel.LatSlip); break; } } Vector3 pos = Vector3.Transform(_damagePosition, GameVars.ScaleMatrix * Chassis.Actor.GlobalPose); DamageSmokeEmitter.Update(pos); }
internal void Repair() { if (_damage > 0) { MessageRenderer.Instance.PostHeaderMessage("Repair Cost: " + (int)_damage * 20, 2); SoundCache.Play(SoundIds.Repair, this, false); if (_deformableModel != null) { _deformableModel.Repair(); } _damage = Chassis.Motor.Damage = 0; DamageSmokeEmitter.Enabled = false; } }
public void OnCollision(float force, Vector3 position, Vector3 normal, bool deform) { float product = Math.Abs(Vector3.Dot(Chassis.Actor.GlobalPose.Forward, normal)); if (Chassis.LastSpeeds.GetMax() > 7) { int particles = Math.Min(8, (int)force / 150000); if (force > 50000) { _vehicleBitsEmitter.DumpParticles(position, particles, Vector3.Zero); GameConsole.WriteEvent("dump particles " + particles); } //else // _vehicleBitsEmitter.Update(position); if (force > 400) { GameVars.SparksEmitter.DumpParticles(position, 6, Vector3.Zero); } if (Driver is PlayerDriver) { if (product < 0.3f) { SoundCache.PlayScrape(this); } else if (force > 50) { SoundCache.PlayCrash(this, force); } } } if (deform && _deformableModel != null) { _deformableModel.OnContact(position, force, normal); } // if this is a CPU driven car, only damage if the player has something to do with it. Stops cars killing themselves if (Driver is CpuDriver && ((CpuDriver)Driver).LastPlayerTouchTime + 0.3f > Engine.TotalSeconds) { Damage(force, position); } else if (Driver is PlayerDriver) { Damage(force, position); } }
public void Update() { TotalTime += Engine.ElapsedSeconds; if (IsOver) { return; } if (IsStarted) { TimeRemaining -= Engine.ElapsedSeconds; if (TimeRemaining < 0) { TimeRemaining = 0; IsOver = true; GameMode.Current = new RaceCompletedMode(CompletionType.TimeUp); } else if (TimeRemaining < 10) { int second = (int)TimeRemaining; if (second != _lastSecond) { SoundCache.Play(SoundIds.TimeBuzzer, null, false); } _lastSecond = second; } } if (CountingDown) { CountdownTime += Engine.ElapsedSeconds; if (CountdownTime > 5) { IsStarted = true; foreach (IDriver driver in Race.Current.Drivers) { driver.OnRaceStart(); } } if (CountdownTime > 6) { CountingDown = false; } } }
public void OnCheckpointHit(Checkpoint checkpoint) { if (checkpoint.Number == NextCheckpoint) { SoundCache.Play(SoundIds.Checkpoint, PlayerVehicle, false); NextCheckpoint++; if (NextCheckpoint == ConfigFile.Checkpoints.Count) { CurrentLap++; NextCheckpoint = 0; } MessageRenderer.Instance.PostMainMessage("checkpnt.pix", 3, 0.7f, 0.003f, 1.4f); } else { SoundCache.Play(SoundIds.WrongCheckpoint, PlayerVehicle, false); } }
public void Render() { if (CountingDown) { int second = (int)CountdownTime; if (second > _lastSecond) { ISound sound = SoundCache.Play(_countdownSoundIds[second], null, false); if (sound != null) { sound.Volume = -1600; } MessageRenderer.Instance.PostMainMessage(_countdownTextures[second], 0.7f, 0.24f, 0.003f, 0); } _lastSecond = second; } }
public void OnHit(Vehicle vehicle) { IsHit = true; _groundHeight = Position.Y; float speed = Math.Min(140, vehicle.Chassis.Speed); if (speed > 90) { _hitSpinSpeed = speed * Engine.Random.Next(0.07f, 0.13f); if (Engine.Random.Next() % 2 == 0) { _hitSpinSpeed *= -1; } _hitUpSpeed = speed * 0.10f; _hitSpeed = speed * Behaviour.Acceleration * 10000; if (!IsPowerup) { PedestrianGibsController.AddGibs(Position + new Vector3(0, 1.2f, 0), vehicle.Chassis.Actor.LinearVelocity, speed); } } else { if (!IsPowerup && speed > 30) { PedestrianGibsController.AddGibs(Position + new Vector3(0, 0.5f, 0), vehicle.Chassis.Actor.LinearVelocity, speed); } _hitSpeed = speed * Behaviour.Acceleration * 19000; } _direction = Vector3.Normalize(vehicle.Chassis.Actor.LinearVelocity); if (float.IsNaN(_direction.X)) { _direction = Vector3.Zero; } SetAction(Behaviour.FatalImpact, true); if (Behaviour.ExplodingSounds.Length > 0) { SoundCache.Play(Behaviour.ExplodingSounds[0], Race.Current.PlayerVehicle, true); } }
public void SetAction(PedestrianAction action, bool force) { if (_currentAction == action) { return; } if (_currentSequence != null && !_currentSequence.Collide && !force) { return; } if (action == null) { return; } _currentAction = action; SetSequence(Behaviour.Sequences[_currentAction.Sequences[0].SequenceIndex]); if (_currentAction.Sounds.Length > 0) { SoundCache.Play(_currentAction.Sounds[Engine.Random.Next(_currentAction.Sounds.Length)], Race.Current.PlayerVehicle, true); } }
public void Enter(Vehicle vehicle) { if (Gravity < 1) { vehicle.Chassis.Actor.RaiseBodyFlag(StillDesign.PhysX.BodyFlag.DisableGravity); } else { vehicle.Chassis.Actor.ClearBodyFlag(StillDesign.PhysX.BodyFlag.DisableGravity); } vehicle.Audio.SetSound(EngineSoundIndex); //vehicle.Chassis.Motor.MaxPower = vehicle.Config.EnginePower / (Viscosity / 35f); //vehicle.Chassis.Body.LinearDamping = Viscosity / 200f; //vehicle.Chassis.Body.AngularDamping = Viscosity / 80f; //vehicle.Chassis.Body.SetCenterOfMassOffsetLocalPosition(new Vector3(0, 0.25f, 0)); //vehicle.Chassis.Body.Mass = vehicle.Config.Mass * Gravity; if (EntrySoundId > 0) { SoundCache.Play(EntrySoundId, vehicle, true); } }
public VehicleAudio(Vehicle vehicle) { _vehicle = vehicle; if (vehicle.Driver is CpuDriver) { return; } _engineSounds = new List <ISound>(); foreach (int id in vehicle.Config.EngineSoundIds) { ISound sound = SoundCache.CreateInstance(id, true); if (sound != null) { sound.MinimumDistance = 20; sound.MaximumDistance = 100; _engineSounds.Add(sound); } } if (_engineSounds.Count > 0) { _sound = _engineSounds[0]; } }
public CopDriver() : base() { _siren = SoundCache.CreateInstance(SoundIds.CopSiren, true); }
public void Update() { if (_stopUpdating) { return; } float angle = Helpers.GetSignedAngleBetweenVectors(Engine.Camera.Orientation, _direction, false); angle = MathHelper.ToDegrees(angle); if (angle < 0) { angle += 360; } if (float.IsNaN(angle)) { angle = 0; } int seq = 0; foreach (PedestrianActionSequenceMap seqMap in _currentAction.Sequences) { if (angle < seqMap.MaxBearing) { seq = seqMap.SequenceIndex; SetSequence(Behaviour.Sequences[seqMap.SequenceIndex]); break; } } _frameTime += Engine.ElapsedSeconds; if (_frameTime > _frameRate) { _frameIndex++; _frameTime = 0; if (!_inLoopingFrames) { if (_frameIndex >= _currentSequence.InitialFrames.Count) { if (_currentSequence.LoopingFrames.Count > 0) { _inLoopingFrames = true; _frameIndex = 0; } else { _frameIndex--; _frameTime = -1; //stop animating } } } else { if (_frameIndex >= _currentSequence.LoopingFrames.Count) { _frameIndex = 0; _frameTime = 0; UpdateFrameRate(); } } } if (IsHit) { Position += _direction * _hitSpeed * Engine.ElapsedSeconds; if (_hitSpinSpeed != 0) { Position.Y += _hitUpSpeed * Engine.ElapsedSeconds; _hitUpSpeed -= Engine.ElapsedSeconds * 45; _hitSpeed -= Engine.ElapsedSeconds * 10; if (Position.Y <= _groundHeight) { Position.Y = _groundHeight; _hitCurrentSpin = _hitSpinSpeed = _hitUpSpeed = 0; _hitSpeed = 0; _stopUpdating = true; } _hitCurrentSpin += _hitSpinSpeed * Engine.ElapsedSeconds; } else { if (_frameTime == -1) { _stopUpdating = true; //if were not spining the ped, stop them as soon as anim is finished } } if (float.IsNaN(Position.X)) { } _physXActor.GlobalPosition = Position; } else if (_isRunning) { Vector3 target = Instructions[_currentInstruction].Position; _direction = target - Position; if (float.IsNaN(_direction.X)) { } if (_direction != Vector3.Zero) { _direction.Normalize(); Position += _direction * RunningSpeed * Engine.ElapsedSeconds; if (float.IsNaN(_direction.X)) { } if (Instructions[_currentInstruction].AutoY) { StillDesign.PhysX.RaycastHit hit = PhysX.Instance.Scene.RaycastClosestShape(new StillDesign.PhysX.Ray(Position + new Vector3(0, 10, 0), Vector3.Down), StillDesign.PhysX.ShapesType.Static); target.Y = hit.WorldImpact.Y; float fallDist = Position.Y - hit.WorldImpact.Y; if (fallDist > 10) { SetAction(Behaviour.NonFatalFalling, true); if (!_isFalling) { SoundCache.Play(Behaviour.FallingNoise, Race.Current.PlayerVehicle, true); } _isFalling = true; } if (fallDist > 0.5f) { Position.Y -= Engine.ElapsedSeconds * 20; } else { Position.Y = hit.WorldImpact.Y; if (_isFalling) { OnHit(Race.Current.PlayerVehicle); return; } } } _physXActor.GlobalPosition = Position; } if (Vector3.Distance(Position, target) < 0.5f) { if (Instructions[_currentInstruction].Reverse) { _instructionDirection *= -1; } _currentInstruction += _instructionDirection; if (_currentInstruction == -1) { _currentInstruction = 0; _instructionDirection *= -1; } } } }