Пример #1
0
 public World(Viewer viewer)
 {
     Viewer = viewer;
     PerformanceInitialViewingDistance = Viewer.Settings.ViewingDistance;
     PerformanceInitialLODBias         = Viewer.Settings.LODBias;
     // Control stuff first.
     WeatherControl = new WeatherControl(viewer);
     // Then drawers.
     if (viewer.Settings.UseMSTSEnv)
     {
         MSTSSky = new MSTSSkyDrawer(viewer);
     }
     else
     {
         Sky = new SkyViewer(viewer);
     }
     Precipitation = new PrecipitationViewer(viewer, WeatherControl);
     Terrain       = new TerrainViewer(viewer);
     Scenery       = new SceneryDrawer(viewer);
     Trains        = new TrainDrawer(viewer);
     RoadCars      = new RoadCarViewer(viewer);
     // Then sound.
     if (viewer.Settings.SoundDetailLevel > 0)
     {
         // Keep it silent while loading.
         ALSoundSource.MuteAll();
         // TODO: This looks kinda evil; do something about it.
         GameSounds = new SoundSource(viewer, Events.Source.MSTSInGame, viewer.Simulator.RoutePath + "\\Sound\\ingame.sms", true);
         Viewer.SoundProcess.AddSoundSources(GameSounds.SMSFolder + "\\" + GameSounds.SMSFileName, new List <SoundSourceBase>()
         {
             GameSounds
         });
         Sounds = new WorldSounds(viewer);
     }
 }
Пример #2
0
 public World(Viewer viewer, double gameTime)
 {
     Viewer = viewer;
     PerformanceInitialViewingDistance = Viewer.Settings.ViewingDistance;
     PerformanceInitialLODBias         = Viewer.Settings.LODBias;
     // Control stuff first.
     // check if weather file is defined
     if (string.IsNullOrEmpty(viewer.Simulator.UserWeatherFile))
     {
         WeatherControl = new WeatherControl(viewer);
     }
     else
     {
         WeatherControl = new AutomaticWeather(viewer, viewer.Simulator.UserWeatherFile, gameTime);
     }
     // Then drawers.
     if (viewer.Settings.UseMSTSEnv)
     {
         MSTSSky = new MSTSSkyDrawer(viewer);
     }
     else
     {
         Sky = new SkyViewer(viewer);
     }
     Precipitation = new PrecipitationViewer(viewer, WeatherControl);
     Terrain       = new TerrainViewer(viewer);
     Scenery       = new SceneryDrawer(viewer);
     Trains        = new TrainDrawer(viewer);
     RoadCars      = new RoadCarViewer(viewer);
     // Then sound.
     if (viewer.Settings.SoundDetailLevel > 0)
     {
         // Keep it silent while loading.
         ALSoundSource.MuteAll();
         // TODO: This looks kinda evil; do something about it.
         GameSounds = new SoundSource(viewer, SoundEventSource.InGame, viewer.Simulator.RouteFolder.SoundFile("ingame.sms"), true);
         Viewer.SoundProcess.AddSoundSources(GameSounds.SMSFolder + "\\" + GameSounds.SMSFileName, new List <SoundSourceBase>()
         {
             GameSounds
         });
         Sounds = new WorldSounds(viewer);
     }
 }
Пример #3
0
    public override void LiveUpdate()
    {
        // steering facing direction
        var lookAngle = Quaternion.LookRotation(aimAt - primaryWeapon.GetShootPointsCentre());

        yawTarget          = Mathf.LerpAngle(yawTarget, lookAngle.eulerAngles.y, 5f * Time.deltaTime);
        transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0f, yawTarget, 0f), 25f * Time.deltaTime);

        Speed += acceleration * Time.deltaTime;

        transform.position += Speed * Vector3.down * Time.deltaTime;

        HeadsUpDisplay.Current.HideCrosshair();
        var        hitRay = new Ray(transform.position, Vector3.down);
        RaycastHit hit;

        if (Physics.Raycast(hitRay, out hit, 20f, LayerMask.GetMask("Player")))
        {
            var inviisbleDestruct = hit.collider.GetComponentInParent <InvisibleDestruct>();
            if (inviisbleDestruct != null)
            {
                Destroy(inviisbleDestruct.gameObject);
            }
        }

        if (Physics.Raycast(hitRay, out hit, Mathf.Abs(Speed * Time.deltaTime + 0.5f), LayerMask.GetMask("Terrain", "Player")))
        {
            transform.position = hit.point;
            WorldSounds.PlayClipAt(transform.position, LandSounds[Random.Range(0, LandSounds.Count)]);
            Land();
            Instantiate(LandEffectPrefab, transform.position, Quaternion.identity);
            TriggerSpawner.TriggerAndDestroy(VehiclePrefab, WeaponPrefab, 0.3f);
            Targeting.RemoveTargetable(Team.Good, GetComponent <Killable>());
            Destroy(this);
        }
    }
Пример #4
0
 private void Start()
 {
     audio = GetComponent <WorldSounds>();
 }
Пример #5
0
 public void RandomSpeak()
 {
     WorldSounds.PlayClipAt(transform.position + Vector3.up, RandomSpeech[Random.Range(0, RandomSpeech.Count)]);
 }
Пример #6
0
 public void AlertCall()
 {
     WorldSounds.PlayClipAt(transform.position + Vector3.up, AlertCalls[Random.Range(0, AlertCalls.Count)]);
 }
Пример #7
0
 private void HurtCry(Collider hitcollider, Vector3 position, Vector3 direction, float power, float damage, GameObject attacker)
 {
     WorldSounds.PlayClipAt(transform.position + Vector3.up, HurtCries[Random.Range(0, AlertCalls.Count)]);
 }