本文整理汇总了C#中Car.Accelerate方法的典型用法代码示例。如果您正苦于以下问题:C# Car.Accelerate方法的具体用法?C# Car.Accelerate怎么用?C# Car.Accelerate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Car
的用法示例。
在下文中一共展示了Car.Accelerate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseCarsCollisionCheck
public void ParseCarsCollisionCheck(Car carA, Car carB, float deltaTime)
{
Random random = Game1.Singleton.Random;
if (carA.Rect.Intersects(carB.Rect))
{
#region Steering-Related
if (carB.X + carB.Width / 2 <= carA.X + carA.Width / 2)
{
//오른쪽 충돌
if (carB.Weight > carA.Weight)
{
//carB가 carA보다 무거움
carB.Steer(-20 * deltaTime);
carA.Steer(150 * deltaTime);
}
else if (carB.Weight < carA.Weight)
{
//carA가 carB보다 무거움
carB.Steer(20 * deltaTime);
carA.Steer(-150 * deltaTime);
}
else
{
//무게가 같음
carB.Steer(-150 * deltaTime);
carA.Steer(150 * deltaTime);
}
}
else
{
//왼쪽 충돌
if (carB.Weight > carA.Weight)
{
//carB가 carA보다 무거움
carB.Steer(20 * deltaTime);
carA.Steer(-150 * deltaTime);
}
else if (carB.Weight < carA.Weight)
{
//carA가 carB보다 무거움
carB.Steer(-20 * deltaTime);
carA.Steer(150 * deltaTime);
}
else
{
//무게가 같음
carB.Steer(150 * deltaTime);
carA.Steer(-150 * deltaTime);
}
}
#endregion
#region Accelerating-Related
if (carB.Y + carB.Height / 3 <= carA.Y + carA.Height - (carA.Height / 3))
{
//뒷쪽 충돌
carB.Accelerate(200 * deltaTime);
}
else if (carB.Y + carB.Height / 3 >= carA.Y + carA.Height - (carA.Height / 3))
{
//앞쪽 충돌
if (!carA.Panic)
{
carA.Panic = true;
carA.PanicRecoverTime = (float)random.NextDouble() + (float)random.NextDouble();
}
carB.Accelerate(-200 * deltaTime);
}
else
{
carB.Accelerate(-150 * deltaTime);
}
#endregion
}
}
示例2: IVehicle_AccelerateCar_OutputsFourWheelAcceleration
public void IVehicle_AccelerateCar_OutputsFourWheelAcceleration()
{
IVehicle vehicle = new Car();
vehicle.Accelerate();
}
示例3: Main
public static void Main()
{
Console.WriteLine ("***** Delegados para facilitar eventos *****\n");
// Crear un objeto de la clase "Car".
Car c1 = new Car (100, 10);
// Hay que decirle al objeto "c1" cual es el método a llamar (OnCarEngineEvent)
// cuando se nos envíe un mensaje o notificación. Debe cumplir con la firma.
c1.RegisterWithCarEngine (new Car.CarEngineHandler (OnCarEngineEvent));
// Subir velocidad (este es el punto de partida para luego recibir eventos o
// mensajes). (el bucle for no tiene llaves por que tiene una sola linea de
// código y se puede hacer eso)
Console.WriteLine ("***** subir velocidad *****");
for (int i = 0; i < 6; i++)
c1.Accelerate (20);
Console.ReadLine ();
}
示例4: TestCar
static void TestCar()
{
Car c1 = new Car("SlugBug", 100, 10);
c1.RegisterWithCarEngine(new Car.CarEngineHandler(OnCarEngineEvent));
//Car.CarEngineHandler h2 = new Car.CarEngineHandler(OnCarDupEvent);
//c1.RegisterWithCarEngine(h2);
//c1.UnregisterWithCarEngine(h2);
// alternate syntactic sugar
c1.RegisterWithCarEngine(OnCarTripleEvent);
//c1.UnregisterWithCarEngine(OnCarTripleEvent);
Console.WriteLine("speed up..");
for (int i = 0; i < 6; i++) {
c1.Accelerate(20);
}
Console.ReadLine();
}
示例5: Main
public static void Main()
{
int blowCount = 0;
string dude = "wusup homi";
Car c = new Car("Lois", 100, 50);
c.Exploded += Boom;
c.AboutToBlow += CloseCall;
// anonymous method
c.AboutToBlow += delegate
{
blowCount++;
// can access locals of method defining this anonymous delegate
// they are outer variables
Console.WriteLine("Eke! {0} you are going to fast!!!", dude);
};
c.Exploded += delegate(object sender, CarEventArgs e)
{
blowCount++;
Console.WriteLine("Boom boom boom: {0} = {1}", sender, e.msg);
if (sender is Car) {
Car car = (Car) sender;
Console.WriteLine(".....call the coroner {0}", car.CurrentSpeed);
}
};
c.Accelerate(20);
c.Accelerate(20);
c.Accelerate(20);
c.Accelerate(20);
Console.WriteLine("blow count: {0}", blowCount);
}