本文整理汇总了C#中Train.Topple方法的典型用法代码示例。如果您正苦于以下问题:C# Train.Topple方法的具体用法?C# Train.Topple怎么用?C# Train.Topple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Train
的用法示例。
在下文中一共展示了Train.Topple方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateTopplingCantAndSpring
//.........这里部分代码省略.........
Train.Cars[CarIndex].Specs.CurrentPitchDueToAccelerationTargetAngle = 0.03 * Math.Atan(d);
}
{
double a = 3.0 * (double)Math.Sign(Train.Cars[CarIndex].Specs.CurrentPitchDueToAccelerationTargetAngle - Train.Cars[CarIndex].Specs.CurrentPitchDueToAccelerationAngle);
Train.Cars[CarIndex].Specs.CurrentPitchDueToAccelerationAngularSpeed += a * TimeElapsed;
double s = Math.Abs(Train.Cars[CarIndex].Specs.CurrentPitchDueToAccelerationTargetAngle - Train.Cars[CarIndex].Specs.CurrentPitchDueToAccelerationAngle);
if (Math.Abs(Train.Cars[CarIndex].Specs.CurrentPitchDueToAccelerationAngularSpeed) > s)
{
Train.Cars[CarIndex].Specs.CurrentPitchDueToAccelerationAngularSpeed = s * (double)Math.Sign(Train.Cars[CarIndex].Specs.CurrentPitchDueToAccelerationAngularSpeed);
}
Train.Cars[CarIndex].Specs.CurrentPitchDueToAccelerationAngle += Train.Cars[CarIndex].Specs.CurrentPitchDueToAccelerationAngularSpeed * TimeElapsed;
}
}
// derailment
if (Interface.CurrentOptions.Derailments & !Train.Cars[CarIndex].Derailed)
{
double a = Train.Cars[CarIndex].Specs.CurrentRollDueToTopplingAngle + Train.Cars[CarIndex].Specs.CurrentRollDueToCantAngle;
double sa = (double)Math.Sign(a);
double tc = Train.Cars[CarIndex].Specs.CriticalTopplingAngle;
if (a * sa > tc)
{
Train.Derail(CarIndex, TimeElapsed);
}
}
// toppling roll
if (Interface.CurrentOptions.Toppling | Train.Cars[CarIndex].Derailed)
{
double a = Train.Cars[CarIndex].Specs.CurrentRollDueToTopplingAngle;
double ab = Train.Cars[CarIndex].Specs.CurrentRollDueToTopplingAngle + Train.Cars[CarIndex].Specs.CurrentRollDueToCantAngle;
double h = Train.Cars[CarIndex].Specs.CenterOfGravityHeight;
double s = Math.Abs(Train.Cars[CarIndex].Specs.CurrentSpeed);
double rmax = 2.0 * h * s * s / (Game.RouteAccelerationDueToGravity * Game.RouteRailGauge);
double ta;
Train.Cars[CarIndex].Topples = false;
if (Train.Cars[CarIndex].Derailed)
{
double sab = (double)Math.Sign(ab);
ta = 0.5 * Math.PI * (sab == 0.0 ? Program.RandomNumberGenerator.NextDouble() < 0.5 ? -1.0 : 1.0 : sab);
}
else
{
if (r != 0.0)
{
if (r < rmax)
{
double s0 = Math.Sqrt(r * Game.RouteAccelerationDueToGravity * Game.RouteRailGauge / (2.0 * h));
const double fac = 0.25; // arbitrary coefficient
ta = -fac * (s - s0) * rs;
Train.Topple(CarIndex, TimeElapsed);
}
else
{
ta = 0.0;
}
}
else
{
ta = 0.0;
}
}
double td;
if (Train.Cars[CarIndex].Derailed)
{
td = Math.Abs(ab);
if (td < 0.1) td = 0.1;
}