当前位置: 首页>>代码示例>>C#>>正文


C# OpenBve.TrainManager类代码示例

本文整理汇总了C#中OpenBve.TrainManager的典型用法代码示例。如果您正苦于以下问题:C# TrainManager类的具体用法?C# TrainManager怎么用?C# TrainManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TrainManager类属于OpenBve命名空间,在下文中一共展示了TrainManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: UnloadPlugin

 /// <summary>Unloads the currently loaded plugin, if any.</summary>
 /// <param name="train">Unloads the plugin for the specified train.</param>
 internal static void UnloadPlugin(TrainManager.Train train)
 {
     if (train.Plugin != null) {
         train.Plugin.Unload();
         train.Plugin = null;
     }
 }
开发者ID:sladen,项目名称:openbve,代码行数:9,代码来源:PluginManager.cs

示例2: CurrentAspect

 /// <summary>This method returns the current aspect of the selected section</summary>
 /// <param name="Train">The train for which we wish to get the section index</param>
 /// <param name="SectionIndex">The section to get the aspect for</param>
 /// <param name="IsPartOfTrain">Defines whether we wish to get the section index for the selected train, or for when placed via a .SigF command</param>
 /// <returns>The aspect of the selected signal</returns>
 public static int CurrentAspect(TrainManager.Train Train, int SectionIndex, bool IsPartOfTrain)
 {
     if (IsPartOfTrain)
     {
         int nextSectionIndex = Train.CurrentSectionIndex + 1;
         if (nextSectionIndex >= 0 & nextSectionIndex < Game.Sections.Length)
         {
             int a = Game.Sections[nextSectionIndex].CurrentAspect;
             if (a >= 0 & a < Game.Sections[nextSectionIndex].Aspects.Length)
             {
                 return Game.Sections[nextSectionIndex].Aspects[a].Number;
             }
             return 0;
         }
     }
     else if (SectionIndex >= 0 & SectionIndex < Game.Sections.Length)
     {
         int a = Game.Sections[SectionIndex].CurrentAspect;
         if (a >= 0 & a < Game.Sections[SectionIndex].Aspects.Length)
         {
             return Game.Sections[SectionIndex].Aspects[a].Number;
         }
     }
     return 0;
 }
开发者ID:leezer3,项目名称:OpenBVE,代码行数:30,代码来源:Scripting.cs

示例3: ParseSoundConfig

		// parse sound config
		internal static void ParseSoundConfig(string TrainPath, System.Text.Encoding Encoding, TrainManager.Train Train) {
			string FileName = OpenBveApi.Path.CombineFile(TrainPath, "sound.cfg");
			if (System.IO.File.Exists(FileName)) {
				LoadBve4Sound(FileName, TrainPath, Encoding, Train);
			} else {
				LoadBve2Sound(TrainPath, Train);
			}
		}
开发者ID:JakubVanek,项目名称:openBVE-1,代码行数:9,代码来源:SoundCfgParser.cs

示例4: numberOfCars

 /// <summary>Returns the number of cars in this train</summary>
 /// <param name="Train">The selected train</param>
 /// <returns>The number of cars</returns>
 public static int numberOfCars(TrainManager.Train Train)
 {
     if (Train != null)
     {
         return Train.Cars.Length;
     }
     return 0;
 }
开发者ID:leezer3,项目名称:OpenBVE,代码行数:11,代码来源:Scripting.cs

示例5: Trigger

			internal override void Trigger(int Direction, EventTriggerType TriggerType, TrainManager.Train Train, int CarIndex) {
				if (TriggerType == EventTriggerType.Camera) {
					if (Direction < 0) {
						BackgroundManager.TargetBackground = this.PreviousBackground;
					} else if (Direction > 0) {
						BackgroundManager.TargetBackground = this.NextBackground;
					}
				}
			}
开发者ID:leezer3,项目名称:OpenBVE,代码行数:9,代码来源:TrackManager.cs

示例6: LoadDefaultPlugin

 /// <summary>Loads the default plugin for the specified train.</summary>
 /// <param name="train">The train to attach the plugin to.</param>
 /// <param name="trainFolder">The train folder.</param>
 /// <returns>Whether the plugin was loaded successfully.</returns>
 internal static bool LoadDefaultPlugin(TrainManager.Train train, string trainFolder)
 {
     string file = OpenBveApi.Path.CombineFile(Program.FileSystem.GetDataFolder("Plugins"), "OpenBveAts.dll");
     bool success = LoadPlugin(train, file, trainFolder);
     if (success) {
         train.Plugin.IsDefault = true;
         SoundCfgParser.LoadDefaultPluginSounds(train, trainFolder);
     }
     return success;
 }
开发者ID:sladen,项目名称:openbve,代码行数:14,代码来源:PluginManager.cs

示例7: Trigger

 override internal void Trigger(int Direction, EventTriggerType TriggerType, TrainManager.Train Train, int CarIndex) {
     if (TriggerType == EventTriggerType.Camera) {
         if (Direction < 0) {
             World.TargetBackground = this.PreviousBackground;
             World.TargetBackgroundCountdown = World.TargetBackgroundDefaultCountdown;
         } else if (Direction > 0) {
             World.TargetBackground = this.NextBackground;
             World.TargetBackgroundCountdown = World.TargetBackgroundDefaultCountdown;
         }
     }
 }
开发者ID:noidelsucre,项目名称:OpenBVE,代码行数:11,代码来源:TrackManagerR.cs

示例8: speed

 /// <summary>Returns the speed of the selected car </summary>
 /// <param name="Train">The selected train</param>
 /// <param name="CarIndex">The car for which to get the speed</param>
 /// <returns>The speed in m/s</returns>
 public static double speed(TrainManager.Train Train, int CarIndex)
 {
     if (Train == null)
     {
         return 0;
     }
     if (CarIndex > Train.Cars.Length)
     {
         return Train.Cars[0].Specs.CurrentSpeed;
     }
     return Train.Cars[CarIndex].Specs.CurrentSpeed;
 }
开发者ID:leezer3,项目名称:OpenBVE,代码行数:16,代码来源:Scripting.cs

示例9: LoadDefaultPluginSounds

		internal static void LoadDefaultPluginSounds(TrainManager.Train train, string trainFolder) {
			Vector3D position = new Vector3D(train.Cars[train.DriverCar].DriverX, train.Cars[train.DriverCar].DriverY, train.Cars[train.DriverCar].DriverZ + 1.0);
			const double radius = 2.0;
			train.Cars[train.DriverCar].Sounds.Plugin = new TrainManager.CarSound[] {
				TryLoadSound(OpenBveApi.Path.CombineFile(trainFolder, "ats.wav"), position, radius),
				TryLoadSound(OpenBveApi.Path.CombineFile(trainFolder, "atscnt.wav"), position, radius),
				TryLoadSound(OpenBveApi.Path.CombineFile(trainFolder, "ding.wav"), position, radius),
				TryLoadSound(OpenBveApi.Path.CombineFile(trainFolder, "toats.wav"), position, radius),
				TryLoadSound(OpenBveApi.Path.CombineFile(trainFolder, "toatc.wav"), position, radius),
				TryLoadSound(OpenBveApi.Path.CombineFile(trainFolder, "eb.wav"), position, radius)
			};
		}
开发者ID:JakubVanek,项目名称:openBVE-1,代码行数:12,代码来源:SoundCfgParser.cs

示例10: SoundSource

			// --- constructors ---
			/// <summary>Creates a new sound source.</summary>
			/// <param name="buffer">The sound buffer.</param>
			/// <param name="radius">The effective sound radius.</param>
			/// <param name="pitch">The pitch change factor.</param>
			/// <param name="volume">The volume change factor.</param>
			/// <param name="position">The position. If a train and car are specified, the position is relative to the car, otherwise absolute.</param>
			/// <param name="train">The train this sound source is attached to, or a null reference.</param>
			/// <param name="car">The car this sound source is attached to, or a null reference.</param>
			/// <param name="looped">Whether this sound source plays in a loop.</param>
			internal SoundSource(SoundBuffer buffer, double radius, double pitch, double volume, OpenBveApi.Math.Vector3D position, TrainManager.Train train, int car, bool looped) {
				this.Buffer = buffer;
				this.Radius = radius;
				this.Pitch = pitch;
				this.Volume = volume;
				this.Position = position;
				this.Train = train;
				this.Car = car;
				this.Looped = looped;
				this.State = SoundSourceState.PlayPending;
				this.OpenAlSourceName = 0;
			}
开发者ID:JakubVanek,项目名称:openBVE-1,代码行数:22,代码来源:Sounds.SoundSource.cs

示例11: Perform

			internal double Perform(TrainManager.Train Train, int CarIndex, Vector3 Position, double TrackPosition, int SectionIndex, bool IsPartOfTrain, double TimeElapsed, int CurrentState) {
				ExecuteFunctionScript(this, Train, CarIndex, Position, TrackPosition, SectionIndex, IsPartOfTrain, TimeElapsed, CurrentState);

				//Allows us to pin the result, but keep the underlying figure
				if (this.Minimum != Double.NaN & this.LastResult < Minimum)
				{
					return Minimum;
				}
				if (this.Maximum != Double.NaN & this.LastResult > Maximum)
				{
					return Maximum;
				}
				return this.LastResult;
			}
开发者ID:leezer3,项目名称:OpenBVE,代码行数:14,代码来源:FunctionScripts.cs

示例12: LoadNoSound

 // load no sound
 internal static void LoadNoSound(TrainManager.Train train)
 {
     // initialize
     for (int i = 0; i < train.Cars.Length; i++) {
         train.Cars[i].Sounds.Run = new TrainManager.CarSound[] { };
         train.Cars[i].Sounds.Flange = new TrainManager.CarSound[] { };
         train.Cars[i].Sounds.Adjust = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.Air = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.AirHigh = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.AirZero = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.Brake = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.BrakeHandleApply = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.BrakeHandleMin = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.BrakeHandleMax = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.BrakeHandleRelease = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.BreakerResume = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.BreakerResumeOrInterrupt = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.CpEnd = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.CpLoop = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.CpStart = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.DoorCloseL = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.DoorCloseR = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.DoorOpenL = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.DoorOpenR = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.EmrBrake = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.Flange = new TrainManager.CarSound[] { };
         train.Cars[i].Sounds.FlangeVolume = new double[] { };
         train.Cars[i].Sounds.Halt = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.Horns = new TrainManager.Horn[] { TrainManager.Horn.Empty, TrainManager.Horn.Empty, TrainManager.Horn.Empty };
         train.Cars[i].Sounds.Loop = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.MasterControllerUp = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.MasterControllerDown = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.MasterControllerMin = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.MasterControllerMax = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.PilotLampOn = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.PilotLampOff = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.PointFrontAxle = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.PointRearAxle = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.ReverserOn = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.ReverserOff = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.Rub = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.Run = new TrainManager.CarSound[] { };
         train.Cars[i].Sounds.RunVolume = new double[] { };
         train.Cars[i].Sounds.SpringL = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.SpringR = TrainManager.CarSound.Empty;
         train.Cars[i].Sounds.Plugin = new TrainManager.CarSound[] { };
     }
 }
开发者ID:sladen,项目名称:openbve,代码行数:49,代码来源:SoundCfgParser.cs

示例13: SimpleHumanDriverAI

 // functions
 internal SimpleHumanDriverAI(TrainManager.Train Train)
 {
     this.TimeLastProcessed = 0.0;
     this.CurrentInterval = 1.0;
     this.BrakeMode = false;
     this.PersonalitySpeedFactor = 0.90 + 0.10 * Program.RandomNumberGenerator.NextDouble();
     this.CurrentSpeedFactor = this.PersonalitySpeedFactor;
     this.PowerNotchAtWhichWheelSlipIsObserved = Train.Specs.MaximumPowerNotch + 1;
     if (Train.Station >= 0 & Train.StationState == TrainManager.TrainStopState.Boarding)
     {
         this.LastStation = Train.Station;
     }
     else
     {
         this.LastStation = -1;
     }
 }
开发者ID:leezer3,项目名称:OpenBVE,代码行数:18,代码来源:AI.cs

示例14: PerformPlugin

 private OpenBveApi.Runtime.AIResponse PerformPlugin(TrainManager.Train Train)
 {
     OpenBveApi.Runtime.AIResponse response = Train.Plugin.UpdateAI();
     if (response == OpenBveApi.Runtime.AIResponse.Short)
     {
         CurrentInterval = 0.2 + 0.1 * Program.RandomNumberGenerator.NextDouble();
     }
     else if (response == OpenBveApi.Runtime.AIResponse.Medium)
     {
         CurrentInterval = 0.4 + 0.2 * Program.RandomNumberGenerator.NextDouble();
     }
     else if (response == OpenBveApi.Runtime.AIResponse.Long)
     {
         CurrentInterval = 0.8 + 0.4 * Program.RandomNumberGenerator.NextDouble();
     }
     return response;
 }
开发者ID:leezer3,项目名称:OpenBVE,代码行数:17,代码来源:AI.cs

示例15: LoadCustomPlugin

 /// <summary>Loads a custom plugin for the specified train.</summary>
 /// <param name="train">The train to attach the plugin to.</param>
 /// <param name="trainFolder">The absolute path to the train folder.</param>
 /// <param name="encoding">The encoding to be used.</param>
 /// <returns>Whether the plugin was loaded successfully.</returns>
 internal static bool LoadCustomPlugin(TrainManager.Train train, string trainFolder, System.Text.Encoding encoding)
 {
     string config = OpenBveApi.Path.CombineFile(trainFolder, "ats.cfg");
     if (!System.IO.File.Exists(config)) {
         return false;
     }
     string[] lines = System.IO.File.ReadAllLines(config, encoding);
     if (lines.Length == 0) {
         return false;
     }
     string file = OpenBveApi.Path.CombineFile(trainFolder, lines[0]);
     string title = System.IO.Path.GetFileName(file);
     if (!System.IO.File.Exists(file)) {
         Interface.AddMessage(Interface.MessageType.Error, true, "The train plugin " + title + " could not be found in " + config);
         return false;
     }
     return LoadPlugin(train, file, trainFolder);
 }
开发者ID:sladen,项目名称:openbve,代码行数:23,代码来源:PluginManager.cs


注:本文中的OpenBve.TrainManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。