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


C# Car.Accelerate方法代码示例

本文整理汇总了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
            }
        }
开发者ID:iAmGhost,项目名称:OverDrive,代码行数:76,代码来源:Normal.cs

示例2: IVehicle_AccelerateCar_OutputsFourWheelAcceleration

 public void IVehicle_AccelerateCar_OutputsFourWheelAcceleration()
 {
     IVehicle vehicle = new Car();
     vehicle.Accelerate();
 }
开发者ID:knguyn90,项目名称:Hangman,代码行数:5,代码来源:PolymorphismTests.cs

示例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 ();
    }
开发者ID:Writkas,项目名称:C-Sharp---Ejercicios-y-ejemplos,代码行数:20,代码来源:Car--Ejemplo.cs

示例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();
    }
开发者ID:walrus7521,项目名称:code,代码行数:17,代码来源:Delegate.cs

示例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);
    }
开发者ID:walrus7521,项目名称:code,代码行数:34,代码来源:Events4.cs


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