예제 #1
0
    /// <summary>
    /// Enable / Disable Exhaust Flame Particles.
    /// </summary>
    public static void SetExhaustFlame(VehiclePhysics vehicle, bool state)
    {
        if (!CheckVehicle(vehicle))
        {
            return;
        }

        Exhaust[] exhausts = vehicle.GetComponentsInChildren <Exhaust>();

        foreach (Exhaust exhaust in exhausts)
        {
            exhaust.previewFlames = state;
        }
    }
예제 #2
0
    /// <summary>
    /// Set Headlights Color.
    /// </summary>
    public static void SetHeadlightsColor(VehiclePhysics vehicle, Color color)
    {
        if (!CheckVehicle(vehicle))
        {
            return;
        }

        VehicleLights[] lights = vehicle.GetComponentsInChildren <VehicleLights>();
        vehicle.lowBeamHeadLightsOn = true;

        foreach (VehicleLights l in lights)
        {
            if (l.lightType == VehicleLights.LightType.HeadLight)
            {
                l.GetComponent <Light>().color = color;
            }
        }
    }
예제 #3
0
    /// <summary>
    /// Set Rear Wheel Cambers.
    /// </summary>
    public static void SetRearCambers(VehiclePhysics vehicle, float camberAngle)
    {
        if (!CheckVehicle(vehicle))
        {
            return;
        }

        VehiclePhysicsWheelCollider[] wc = vehicle.GetComponentsInChildren <VehiclePhysicsWheelCollider>();

        foreach (VehiclePhysicsWheelCollider w in wc)
        {
            if (w != vehicle.FrontLeftWheelCollider && w != vehicle.FrontRightWheelCollider)
            {
                w.camber = camberAngle;
            }
        }

        OverrideVehicle(vehicle);
    }
예제 #4
0
    /// <summary>
    /// Set Smoke Color.
    /// </summary>
    public static void SetSmokeColor(VehiclePhysics vehicle, int indexOfGroundMaterial, Color color)
    {
        if (!CheckVehicle(vehicle))
        {
            return;
        }

        VehiclePhysicsWheelCollider[] wheels = vehicle.GetComponentsInChildren <VehiclePhysicsWheelCollider>();

        foreach (VehiclePhysicsWheelCollider wheel in wheels)
        {
            for (int i = 0; i < wheel.allWheelParticles.Count; i++)
            {
                ParticleSystem            ps     = wheel.allWheelParticles[i];
                ParticleSystem.MainModule psmain = ps.main;
                color.a           = psmain.startColor.color.a;
                psmain.startColor = color;
            }
        }
    }
예제 #5
0
    /// <summary>
    /// Save all stats with PlayerPrefs.
    /// </summary>
    public static void SaveStats(VehiclePhysics vehicle)
    {
        if (!CheckVehicle(vehicle))
        {
            return;
        }

        PlayerPrefs.SetFloat(vehicle.transform.name + "_FrontCamber", vehicle.FrontLeftWheelCollider.camber);
        PlayerPrefs.SetFloat(vehicle.transform.name + "_RearCamber", vehicle.RearLeftWheelCollider.camber);

        PlayerPrefs.SetFloat(vehicle.transform.name + "_FrontSuspensionsDistance",
                             vehicle.FrontLeftWheelCollider.wheelCollider.suspensionDistance);
        PlayerPrefs.SetFloat(vehicle.transform.name + "_RearSuspensionsDistance",
                             vehicle.RearLeftWheelCollider.wheelCollider.suspensionDistance);

        PlayerPrefs.SetFloat(vehicle.transform.name + "_FrontSuspensionsSpring",
                             vehicle.FrontLeftWheelCollider.wheelCollider.suspensionSpring.spring);
        PlayerPrefs.SetFloat(vehicle.transform.name + "_RearSuspensionsSpring",
                             vehicle.RearLeftWheelCollider.wheelCollider.suspensionSpring.spring);

        PlayerPrefs.SetFloat(vehicle.transform.name + "_FrontSuspensionsDamper",
                             vehicle.FrontLeftWheelCollider.wheelCollider.suspensionSpring.damper);
        PlayerPrefs.SetFloat(vehicle.transform.name + "_RearSuspensionsDamper",
                             vehicle.RearLeftWheelCollider.wheelCollider.suspensionSpring.damper);

        PlayerPrefs.SetFloat(vehicle.transform.name + "_MaximumSpeed", vehicle.maxspeed);
        PlayerPrefs.SetFloat(vehicle.transform.name + "_MaximumBrake", vehicle.brakeTorque);
        PlayerPrefs.SetFloat(vehicle.transform.name + "_MaximumTorque", vehicle.engineTorque);

        PlayerPrefs.SetString(vehicle.transform.name + "_DrivetrainMode", vehicle._wheelTypeChoise.ToString());

        PlayerPrefs.SetFloat(vehicle.transform.name + "_GearShiftingThreshold", vehicle.gearShiftingThreshold);
        PlayerPrefs.SetFloat(vehicle.transform.name + "_ClutchingThreshold", vehicle.clutchInertia);

        SaveData.SetBool(vehicle.transform.name + "_CounterSteering", vehicle.applyCounterSteering);

        foreach (VehicleLights _light in vehicle.GetComponentsInChildren <VehicleLights>())
        {
            if (_light.lightType == VehicleLights.LightType.HeadLight)
            {
                SaveData.SetColor(vehicle.transform.name + "_HeadlightsColor",
                                  _light.GetComponentInChildren <Light>().color);
                break;
            }
        }

        ParticleSystem ps = vehicle.RearLeftWheelCollider.allWheelParticles[0];

        ParticleSystem.MainModule psmain = ps.main;

        SaveData.SetColor(vehicle.transform.name + "_WheelsSmokeColor", psmain.startColor.color);
        SaveData.SetColor(vehicle.transform.name + "_BodyColor", vehicle.carProperties.carMaterial.color);
        SaveData.SetColor(vehicle.transform.name + "_RimColor", ChangableWheels.Instance.wheels[wheelIndex].material.color);
        PlayerPrefs.SetFloat(vehicle.transform.name + "_Metallic",
                             vehicle.carProperties.carMaterial.GetFloat("_Metallic"));
        PlayerPrefs.SetFloat(vehicle.transform.name + "_Glossiness",
                             vehicle.carProperties.carMaterial.GetFloat("_Glossiness"));
        PlayerPrefs.SetFloat(vehicle.transform.name + "_RIMMetallic",
                             ChangableWheels.Instance.wheels[wheelIndex].material.GetFloat("_Metallic"));
        PlayerPrefs.SetFloat(vehicle.transform.name + "_RIMGlossiness",
                             ChangableWheels.Instance.wheels[wheelIndex].material.GetFloat("_Glossiness"));

        SaveData.SetBool(vehicle.transform.name + "_ABS", vehicle.ABS);
        SaveData.SetBool(vehicle.transform.name + "_ESP", vehicle.ESP);
        SaveData.SetBool(vehicle.transform.name + "_TCS", vehicle.TCS);
        SaveData.SetBool(vehicle.transform.name + "_SH", vehicle.steeringHelper);

        SaveData.SetBool(vehicle.transform.name + "NOS", vehicle.useNOS);
        SaveData.SetBool(vehicle.transform.name + "Turbo", vehicle.useTurbo);
        SaveData.SetBool(vehicle.transform.name + "ExhaustFlame", vehicle.useExhaustFlame);
        SaveData.SetBool(vehicle.transform.name + "RevLimiter", vehicle.useRevLimiter);
        SaveData.SetBool(vehicle.transform.name + "ClutchMargin", vehicle.useClutchMarginAtFirstGear);

        PlayerPrefs.SetInt(vehicle.transform.name + "Spoiler", spoilerIndex);
        PlayerPrefs.SetInt(vehicle.transform.name + "WheelIndex", wheelIndex);
        PlayerPrefs.SetInt(vehicle.transform.name + "WheelSizeIndex", wheelSizeIndex);
        PlayerPrefs.SetInt(vehicle.transform.name + "TyreIndex", tyreIndex);
        PlayerPrefs.SetInt(vehicle.transform.name + "Front Bumper", frontBumperIndex);
    }