本文整理汇总了C#中Vehicle类的典型用法代码示例。如果您正苦于以下问题:C# Vehicle类的具体用法?C# Vehicle怎么用?C# Vehicle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vehicle类属于命名空间,在下文中一共展示了Vehicle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenAddingReminder_ThenUpdatesServiceReminder
public void WhenAddingReminder_ThenUpdatesServiceReminder()
{
const int newReminderId = 456;
var vehicle = new Vehicle { VehicleId = DefaultVehicleId, Name = "vehicle" };
_vehicleRepository
.Setup(r => r.GetVehicle(DefaultUserId, DefaultVehicleId))
.Returns(vehicle);
_reminderRepository
.Setup(r => r.Create(DefaultVehicleId, It.IsAny<Reminder>()))
.Callback(new Action<int, Reminder>((vehicleId, reminder) =>
{
// represents the entity created internally
reminder.ReminderId = newReminderId;
reminder.VehicleId = DefaultVehicleId;
}));
var formModel = new ReminderFormModel();
var handler = new AddReminderToVehicle(_vehicleRepository.Object, _reminderRepository.Object);
handler.Execute(DefaultUserId, DefaultVehicleId, formModel);
Assert.Equal(newReminderId, formModel.ReminderId);
Assert.Equal(DefaultVehicleId, formModel.VehicleId);
}
示例2: SimulationStep
public override void SimulationStep(ushort vehicleID, ref Vehicle vehicleData, ref Vehicle.Frame frameData, ushort leaderID, ref Vehicle leaderData, int lodPhysics)
{
if ((CSLTraffic.Options & OptionsManager.ModOptions.UseRealisticSpeeds) == OptionsManager.ModOptions.UseRealisticSpeeds)
{
if (CustomCarAI.sm_speedData[vehicleID].speedMultiplier == 0 || CustomCarAI.sm_speedData[vehicleID].currentPath != vehicleData.m_path)
{
CustomCarAI.sm_speedData[vehicleID].currentPath = vehicleData.m_path;
CustomCarAI.sm_speedData[vehicleID].SetRandomSpeedMultiplier(0.65f, 1.05f);
}
CustomCarAI.sm_speedData[vehicleID].ApplySpeedMultiplier(this.m_info);
}
if ((vehicleData.m_flags & Vehicle.Flags.Stopped) != Vehicle.Flags.None)
{
vehicleData.m_waitCounter += 1;
if (this.CanLeave(vehicleID, ref vehicleData))
{
vehicleData.m_flags &= ~Vehicle.Flags.Stopped;
vehicleData.m_flags |= Vehicle.Flags.Leaving;
vehicleData.m_waitCounter = 0;
}
}
CustomCarAI.SimulationStep(this, vehicleID, ref vehicleData, ref frameData, leaderID, ref leaderData, lodPhysics);
if ((vehicleData.m_flags & Vehicle.Flags.GoingBack) == Vehicle.Flags.None && this.ShouldReturnToSource(vehicleID, ref vehicleData))
{
this.SetTransportLine(vehicleID, ref vehicleData, 0);
}
if ((CSLTraffic.Options & OptionsManager.ModOptions.UseRealisticSpeeds) == OptionsManager.ModOptions.UseRealisticSpeeds)
{
CustomCarAI.sm_speedData[vehicleID].RestoreVehicleSpeed(this.m_info);
}
}
示例3: CockpitView
public CockpitView(Vehicle vehicle, string cockpitFile)
{
_vehicle = vehicle;
if (GameVars.Emulation == EmulationMode.Demo)
cockpitFile = Path.GetDirectoryName(cockpitFile) + "\\blkeagle.txt";
else if (GameVars.Emulation == EmulationMode.SplatPackDemo)
cockpitFile = Path.GetDirectoryName(cockpitFile) + "\\neweagle.txt";
else if (!File.Exists(cockpitFile))
cockpitFile = Path.GetDirectoryName(cockpitFile) + "\\blkeagle.txt";
if (File.Exists(cockpitFile))
{
_cockpitFile = new CockpitFile(cockpitFile);
ActFile actFile = new ActFile(vehicle.Config.BonnetActorFile);
if (!actFile.Exists)
actFile = new ActFile("EBONNET.ACT");
_actors = actFile.Hierarchy;
DatFile modelsFile = new DatFile(_actors.Root.ModelName);
_actors.AttachModels(modelsFile.Models);
_actors.ResolveTransforms(false, null);
//move head back
_vehicle.Config.DriverHeadPosition.Z += 0.11f;
}
_camera = new SimpleCamera();
_camera.FieldOfView = MathHelper.ToRadians(55.55f);
}
示例4: SimulationStep
public override void SimulationStep(ushort vehicleID, ref Vehicle data, Vector3 physicsLodRefPos)
{
var bc = blockCounter[vehicleID];
if (data.m_blockCounter == 0)
{
bc = 0;
}
else if (data.m_blockCounter > 1)
{
bc = (byte)Mathf.Min(bc + 1, 0xff);
}
if ((data.m_flags & Vehicle.Flags.Congestion) != Vehicle.Flags.None)
{
bc = (byte)Mathf.Min(bc + 5, 0xff);
data.m_flags &= ~Vehicle.Flags.Congestion;
}
data.m_blockCounter = 1;
blockCounter[vehicleID] = bc;
if (bc == 0xff)
{
blockCounter[vehicleID] = 0;
Singleton<VehicleManager>.instance.ReleaseVehicle(vehicleID);
}
else
{
base.SimulationStep(vehicleID, ref data, physicsLodRefPos);
}
}
示例5: OnBeforeCalloutDisplayed
private LHandle pursuit; // an API pursuit handle
/// <summary>
/// OnBeforeCalloutDisplayed is where we create a blip for the user to see where the pursuit is happening, we initiliaize any variables above and set
/// the callout message and position for the API to display
/// </summary>
/// <returns></returns>
public override bool OnBeforeCalloutDisplayed()
{
//Set our spawn point to be on a street around 300f (distance) away from the player.
SpawnPoint = World.GetNextPositionOnStreet(Game.LocalPlayer.Character.Position.Around(300f));
//Create our ped in the world
myPed = new Ped("a_m_y_mexthug_01", SpawnPoint, 0f);
//Create the vehicle for our ped
myVehicle = new Vehicle("DUKES2", SpawnPoint);
//Now we have spawned them, check they actually exist and if not return false (preventing the callout from being accepted and aborting it)
if (!myPed.Exists()) return false;
if (!myVehicle.Exists()) return false;
//If we made it this far both exist so let's warp the ped into the driver seat
myPed.WarpIntoVehicle(myVehicle, -1);
// Show the user where the pursuit is about to happen and block very close peds.
this.ShowCalloutAreaBlipBeforeAccepting(SpawnPoint, 15f);
this.AddMinimumDistanceCheck(5f, myPed.Position);
// Set up our callout message and location
this.CalloutMessage = "Example Callout Message";
this.CalloutPosition = SpawnPoint;
//Play the police scanner audio for this callout (available as of the 0.2a API)
Functions.PlayScannerAudioUsingPosition("CITIZENS_REPORT CRIME_RESIST_ARREST IN_OR_ON_POSITION", SpawnPoint);
return base.OnBeforeCalloutDisplayed();
}
示例6: Calculate
/// <summary>
/// Calculcates the metrics.
/// </summary>
/// <param name="vehicle"></param>
/// <param name="p"></param>
/// <returns></returns>
public override Dictionary<string, double> Calculate(Vehicle vehicle, AggregatedPoint p)
{
Dictionary<string, double> result = new Dictionary<string, double>();
result.Add(DISTANCE_KEY, 0);
result.Add(TIME_KEY, 0);
Aggregated next = p;
while (next != null)
{
if (next is AggregatedPoint)
{
AggregatedPoint point = (next as AggregatedPoint);
this.CalculatePointMetrics(vehicle, result, point);
}
if (next is AggregatedArc)
{
AggregatedArc arc = (next as AggregatedArc);
this.CalculateArcMetrics(vehicle, result, arc);
}
next = next.GetNext();
}
return result;
}
示例7: SimulationStep
public override void SimulationStep(ushort vehicleID, ref Vehicle data, Vector3 physicsLodRefPos)
{
// Logger.dbgLog("called .");
byte bc = blockCounter[vehicleID];
if (data.m_blockCounter == 0)
{
bc = 0;
blockCounter[vehicleID] = 0;
}
else if (data.m_blockCounter > 1)
{
bc = (byte)Mathf.Min(bc + 1, 255);
WBResidentAI6.AddCommuteWait(data, 1);
}
if ((data.m_flags & Vehicle.Flags.Congestion) != Vehicle.Flags.None)
{
bc = (byte)Mathf.Min(bc + 5, 255);
data.m_flags &= ~Vehicle.Flags.Congestion;
}
data.m_blockCounter = 1;
blockCounter[vehicleID] = bc;
if (bc == 255)
{
blockCounter[vehicleID] = 0;
Singleton<VehicleManager>.instance.ReleaseVehicle(vehicleID);
}
else
{
base.SimulationStep(vehicleID, ref data, physicsLodRefPos);
}
}
示例8: DrawContainerFront
private void DrawContainerFront(Canvas canvas, Container container, Vehicle currentVehicle)
{
var length = container.Width/Scale;
var height = container.Length/Scale;
var x = container.FirstPoint.X/Scale;
var z = (container.FirstPoint.Y - currentVehicle.FirstPoint.Y)/Scale;
var r = new Rectangle();
r.Width = length;
r.Height = height;
Brush brush = new SolidColorBrush();
brush = Brushes.White;
r.Stroke = new SolidColorBrush(Colors.Black);
r.Fill = brush;
Canvas.SetLeft(r, x);
Canvas.SetTop(r, z);
canvas.Children.Add(r);
var t = new TextBlock();
t.Text = Math.Round(container.Mass) + " кг";
t.FontSize = 12;
Canvas.SetLeft(t, x + 2);
var delta = 2;
Canvas.SetTop(t, z + 2);
canvas.Children.Add(t);
t = new TextBlock {Text = container.ShortName, FontSize = 12};
Canvas.SetLeft(t, x + 2);
delta = delta + 15;
Canvas.SetTop(t, z + delta);
canvas.Children.Add(t);
}
示例9: SimulationStep
public override void SimulationStep(ushort vehicleID, ref Vehicle vehicleData, ref Vehicle.Frame frameData, ushort leaderID, ref Vehicle leaderData, int lodPhysics)
{
if ((TrafficMod.Options & OptionsManager.ModOptions.UseRealisticSpeeds) == OptionsManager.ModOptions.UseRealisticSpeeds)
{
var speedData = CarSpeedData.Of(vehicleID);
if (speedData.SpeedMultiplier == 0 || speedData.CurrentPath != vehicleData.m_path)
{
speedData.CurrentPath = vehicleData.m_path;
speedData.SetRandomSpeedMultiplier(0.7f, 1.15f);
}
m_info.ApplySpeedMultiplier(CarSpeedData.Of(vehicleID));
}
base.SimulationStep(vehicleID, ref vehicleData, ref frameData, leaderID, ref leaderData, lodPhysics);
if ((vehicleData.m_flags & Vehicle.Flags.Stopped) != 0 && this.CanLeave(vehicleID, ref vehicleData))
{
vehicleData.m_flags &= ~Vehicle.Flags.Stopped;
vehicleData.m_flags |= Vehicle.Flags.Leaving;
}
if ((vehicleData.m_flags & (Vehicle.Flags.TransferToSource | Vehicle.Flags.GoingBack)) == Vehicle.Flags.TransferToSource && this.ShouldReturnToSource(vehicleID, ref vehicleData))
{
this.SetTarget(vehicleID, ref vehicleData, 0);
}
if ((TrafficMod.Options & OptionsManager.ModOptions.UseRealisticSpeeds) == OptionsManager.ModOptions.UseRealisticSpeeds)
{
m_info.RestoreVehicleSpeed(CarSpeedData.Of(vehicleID));
}
}
示例10: CalculateTargetSpeed
protected override float CalculateTargetSpeed(ushort vehicleID, ref Vehicle data, float speedLimit, float curve)
{
if ((data.m_flags & Vehicle.Flags.Emergency2) == Vehicle.Flags.None)
return base.CalculateTargetSpeed(vehicleID, ref data, speedLimit, curve);
return Mathf.Min(base.CalculateTargetSpeed(vehicleID, ref data, speedLimit * 2, curve * 0.5f), m_info.m_maxSpeed * 2);
}
示例11: DrawContainerUp
private void DrawContainerUp(Canvas canvas, Container container, Vehicle currentVehicle)
{
var length = container.Width/Scale;
var height = container.Height/Scale;
var x = (container.FirstPoint.X - currentVehicle.FirstPoint.X)/Scale;
var z = container.FirstPoint.Z/Scale;
var rectangle = new Rectangle();
rectangle.Width = length;
rectangle.Height = height;
Brush brush = new SolidColorBrush();
brush = Brushes.White;
rectangle.Stroke = new SolidColorBrush(Colors.Black);
rectangle.Fill = brush;
Canvas.SetLeft(rectangle, x);
Canvas.SetTop(rectangle, canvas.Height - height - z);
canvas.Children.Add(rectangle);
var textBlock = new TextBlock {Text = Math.Round(container.Mass) + " кг", FontSize = 12};
Canvas.SetLeft(textBlock, x + 2);
var delta = 2;
Canvas.SetTop(textBlock, canvas.Height - height - z + 2);
canvas.Children.Add(textBlock);
textBlock = new TextBlock {Text = container.ShortName, FontSize = 12};
Canvas.SetLeft(textBlock, x + 2);
delta = delta + 15;
Canvas.SetTop(textBlock, canvas.Height - height - z + delta);
canvas.Children.Add(textBlock);
}
示例12: ArriveAtTarget
private bool ArriveAtTarget(ushort vehicleID, ref Vehicle data)
{
VehicleManager instance = Singleton<VehicleManager>.instance;
ushort num = data.m_firstCargo;
data.m_firstCargo = 0;
int num2 = 0;
while (num != 0)
{
ushort nextCargo = instance.m_vehicles.m_buffer [(int)num].m_nextCargo;
instance.m_vehicles.m_buffer [(int)num].m_nextCargo = 0;
instance.m_vehicles.m_buffer [(int)num].m_cargoParent = 0;
VehicleInfo info = instance.m_vehicles.m_buffer [(int)num].Info;
if (data.m_targetBuilding != 0)
{
info.m_vehicleAI.SetSource (num, ref instance.m_vehicles.m_buffer [(int)num], data.m_targetBuilding);
info.m_vehicleAI.SetTarget (num, ref instance.m_vehicles.m_buffer [(int)num], instance.m_vehicles.m_buffer [(int)num].m_targetBuilding);
}
num = nextCargo;
if (++num2 > 65536)
{
CODebugBase<LogChannel>.Error (LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);
break;
}
}
data.m_waitCounter = 0;
data.m_flags |= Vehicle.Flags.WaitingLoading;
return false;
}
示例13: Operator
Operator IOperatorProfile.GetOperator(string operatorName, string trafficFileNumber)
{
Operator operatorFormWeb = new Operator();
try
{
handHeldService.HandHeldService service = new VSDApp.handHeldService.HandHeldService();
handHeldService.AuthHeader authorize = new VSDApp.handHeldService.AuthHeader();
authorize.password = AppProperties.empPassword;
authorize.userName = AppProperties.empUserName;
service.authHeader = authorize;
handHeldService.InquireCompanyProfileResponseItem responseItem = new VSDApp.handHeldService.InquireCompanyProfileResponseItem();
operatorFormWeb = new Operator();
responseItem = service.inquireCompanyProfile("H-PS-ICP-1", trafficFileNumber, null);
if (responseItem.response.code.Equals("1000", StringComparison.CurrentCultureIgnoreCase))
{
operatorFormWeb.OperatorOVRRScore = responseItem.company.riskRating.riskRatingName;
operatorFormWeb.OperatorName = responseItem.company.ownerName;
operatorFormWeb.OperatorNameAr = responseItem.company.ownerNameArabic;
operatorFormWeb.TrafficFileNumber = responseItem.company.trafficFileNumber;
Vehicle[] copyResponseVehicles = new Vehicle[responseItem.company.vehicles.Length];
int count = 0;
foreach (handHeldService.Vehicle responseVehicles in responseItem.company.vehicles)
{
copyResponseVehicles[count] = new Vehicle();
copyResponseVehicles[count].RiskRating = responseVehicles.riskRating.riskRatingName;
copyResponseVehicles[count].PlateNumber = responseVehicles.plateDetails.number;
copyResponseVehicles[count].PlateCode = responseVehicles.plateDetails.code;
copyResponseVehicles[count].PlateCategory = responseVehicles.plateDetails.category;
copyResponseVehicles[count].Emirate = ((IDBDataLoad)DBDataLoadManager.GetInstance()).GetPlateEmirate(responseVehicles.plateDetails.source);
copyResponseVehicles[count].PlateSource = responseVehicles.plateDetails.source;
count++;
}
operatorFormWeb.TopViolatingVehicles = copyResponseVehicles;
}
else if (responseItem.response.code.Equals("2000"))
{
AppProperties.businessError = true;
AppProperties.errorMessageFromBusiness = responseItem.response.message;
}
else
{
AppProperties.NotFoundError = true;
AppProperties.errorMessageFromBusiness = responseItem.response.message;
// System.Windows.Forms.MessageBox.Show(responseItem.response.message);
return null;
}
}
catch (Exception ex)
{
AppProperties.IsException = true;
AppProperties.errorMessageFromBusiness = ex.InnerException.Message;
CommonUtils.WriteLog(ex.StackTrace);
return null;
}
return operatorFormWeb;
}
示例14: Start
public void Start(Vehicle vechicle)
{
// Send details to Administrator
// Print
Console.WriteLine("Race Vehicle started, Name : {0} | Model : {1} | Driver : {2}", vechicle.Name, vechicle.Model, vechicle.DriverName);
}
示例15: TrafficManagerSimulationStep
/// <summary>
/// Lightweight simulation step method.
/// This method is occasionally being called for different cars.
/// </summary>
/// <param name="vehicleId"></param>
/// <param name="vehicleData"></param>
/// <param name="physicsLodRefPos"></param>
public void TrafficManagerSimulationStep(ushort vehicleId, ref Vehicle vehicleData, Vector3 physicsLodRefPos) {
if ((vehicleData.m_flags & Vehicle.Flags.WaitingPath) != 0) {
PathManager instance = Singleton<PathManager>.instance;
byte pathFindFlags = instance.m_pathUnits.m_buffer[(int)((UIntPtr)vehicleData.m_path)].m_pathFindFlags;
if ((pathFindFlags & 4) != 0) {
vehicleData.m_pathPositionIndex = 255;
vehicleData.m_flags &= ~Vehicle.Flags.WaitingPath;
vehicleData.m_flags &= ~Vehicle.Flags.Arriving;
this.PathfindSuccess(vehicleId, ref vehicleData);
this.TrySpawn(vehicleId, ref vehicleData);
} else if ((pathFindFlags & 8) != 0) {
vehicleData.m_flags &= ~Vehicle.Flags.WaitingPath;
Singleton<PathManager>.instance.ReleasePath(vehicleData.m_path);
vehicleData.m_path = 0u;
this.PathfindFailure(vehicleId, ref vehicleData);
return;
}
} else if ((vehicleData.m_flags & Vehicle.Flags.WaitingSpace) != 0) {
this.TrySpawn(vehicleId, ref vehicleData);
}
try {
CustomVehicleAI.HandleVehicle(vehicleId, ref Singleton<VehicleManager>.instance.m_vehicles.m_buffer[vehicleId], true, true);
} catch (Exception e) {
Log.Error("CarAI TrafficManagerSimulationStep Error: " + e.ToString());
}
Vector3 lastFramePosition = vehicleData.GetLastFramePosition();
int lodPhysics;
if (Vector3.SqrMagnitude(physicsLodRefPos - lastFramePosition) >= 1210000f) {
lodPhysics = 2;
} else if (Vector3.SqrMagnitude(Singleton<SimulationManager>.instance.m_simulationView.m_position - lastFramePosition) >= 250000f) {
lodPhysics = 1;
} else {
lodPhysics = 0;
}
this.SimulationStep(vehicleId, ref vehicleData, vehicleId, ref vehicleData, lodPhysics);
if (vehicleData.m_leadingVehicle == 0 && vehicleData.m_trailingVehicle != 0) {
VehicleManager instance2 = Singleton<VehicleManager>.instance;
ushort num = vehicleData.m_trailingVehicle;
int num2 = 0;
while (num != 0) {
ushort trailingVehicle = instance2.m_vehicles.m_buffer[(int)num].m_trailingVehicle;
VehicleInfo info = instance2.m_vehicles.m_buffer[(int)num].Info;
info.m_vehicleAI.SimulationStep(num, ref instance2.m_vehicles.m_buffer[(int)num], vehicleId, ref vehicleData, lodPhysics);
num = trailingVehicle;
if (++num2 > 16384) {
CODebugBase<LogChannel>.Error(LogChannel.Core, "Invalid list detected!\n" + Environment.StackTrace);
break;
}
}
}
int privateServiceIndex = ItemClass.GetPrivateServiceIndex(this.m_info.m_class.m_service);
int num3 = (privateServiceIndex == -1) ? 150 : 100;
if ((vehicleData.m_flags & (Vehicle.Flags.Spawned | Vehicle.Flags.WaitingPath | Vehicle.Flags.WaitingSpace)) == 0 && vehicleData.m_cargoParent == 0) {
Singleton<VehicleManager>.instance.ReleaseVehicle(vehicleId);
} else if ((int)vehicleData.m_blockCounter == num3 && Options.enableDespawning) {
Singleton<VehicleManager>.instance.ReleaseVehicle(vehicleId);
}
}