示例#1
0
        public void Update(GameTime gameTime)
        {
            carControl = new CarControl(game, models[0].Rotation, speed, carData.MaxSpeed, Turning, UAcceleration, DAcceleration, WheelTurn, gear, CameraInerty);
            carControl.Control();
            models[0].Rotation = carControl.Rotation;
            speed = carControl.speed;
            Turning = carControl.Turning;
            UAcceleration = carControl.UAcceleration;
            DAcceleration = carControl.DAcceleration;
            WheelTurn = carControl.WheelTurn;
            gear = carControl.gear;
            CameraInerty = carControl.CameraInerty;
            CarMoving(gameTime);
            KeyboardState keyboardstate = Keyboard.GetState();

            //Change car;
            if (keyboardstate.IsKeyDown(Keys.D1))
            {
                CarModelName = "Lamborghini Veneno";
                changeCar = true;
            }
            if (keyboardstate.IsKeyDown(Keys.D2))
            {
                CarModelName = "Lamborghini Aventador 2012";
                changeCar = true;
            }
            if (keyboardstate.IsKeyDown(Keys.D3))
            {
                CarModelName = "Audi R8";
                changeCar = true;
            }

            carData = new CarsData(game, CarModelName);
            Car_Scale = carData.Scale_Car;
            Wheel_Scale = carData.Scale_Wheel;
            CarModel = game.Content.Load<Model>(CarPath + CarModelName + carData.CarModelName);
            WheelModel = game.Content.Load<Model>(carData.Model_Wheel);

            models[0] = new Models(game.Content, CarModel, models[0].Position, models[0].Rotation, Car_Scale, graphicsDevice);
            models[1] = new Models(game.Content, WheelModel, models[1].Position, models[1].Rotation, Wheel_Scale, graphicsDevice);
            models[2] = new Models(game.Content, WheelModel, models[2].Position, models[2].Rotation, Wheel_Scale, graphicsDevice);
            models[3] = new Models(game.Content, WheelModel, models[3].Position, models[3].Rotation, Wheel_Scale, graphicsDevice);
            models[4] = new Models(game.Content, WheelModel, models[4].Position, models[4].Rotation, Wheel_Scale, graphicsDevice);

            if (changeCar)
            {
                speed = 0;
                changeCar = false;
            }
            OldSpeed = speed;
            UpdateLight();
        }
示例#2
0
        public void Initialize()
        {
            //Load Car by its name...
            CarModelName = "Audi R8";
            carData = new CarsData(game, CarModelName);
            Car_Scale = carData.Scale_Car;
            Wheel_Scale = carData.Scale_Wheel;
            CarModel = game.Content.Load<Model>(CarPath + CarModelName + carData.CarModelName);
            WheelModel = game.Content.Load<Model>(carData.Model_Wheel);

            //Load Car Components
            models.Add(new Models(game.Content, CarModel, new Vector3(1000f, 0, 10f), new Vector3(0, 0, 0), Car_Scale, graphicsDevice));

            models.Add(new Models(game.Content, WheelModel, new Vector3(0.152f, 0.065f, 0.245f), new Vector3(0, 0, 0), Wheel_Scale, graphicsDevice));//UR
            models.Add(new Models(game.Content, WheelModel, new Vector3(-0.152f, 0.065f, 0.245f), new Vector3(0, MathHelper.Pi, 0), Wheel_Scale, graphicsDevice));//UL
            models.Add(new Models(game.Content, WheelModel, new Vector3(0.152f, 0.065f, -0.245f), new Vector3(0, 0, 0), Wheel_Scale, graphicsDevice));//DR
            models.Add(new Models(game.Content, WheelModel, new Vector3(-0.152f, 0.065f, -0.245f), new Vector3(0, MathHelper.Pi, 0), Wheel_Scale, graphicsDevice));//DL
        }