Ejemplo n.º 1
0
 void Awake()
 {
     // Get the SimpleControlVehicle script of the game object.
     vehicleScript = gameObject.GetComponent<SimpleControlVehicle> ();
 }
    void Start()
    {
        vehicle = this;

        // Look all the wheels assigned on the wheels array.
        for (int i = 0; i < wheels.Length; i++) {
            // Verify if all the wheels are assigned
            if(wheels[i] == null){
                wheels = new GameObject[0];
                Debug.Log("Wheel not assigned.");
                return;
            }
            // Verify if all the wheels has a CircleCollider2D
            else if (wheels[i].GetComponent<CircleCollider2D>() == null){
                wheels = new GameObject[0];
                Debug.Log("Circle collider no assigned to the wheel.");
                return;
            }else{
                wheels[i].GetComponent<CircleCollider2D>().sharedMaterial = groundMat;
                addWheelJoint2D(i);
            }
        }
        // Assign the engine audio loop to true to repeat the sound.
        GetComponent<AudioSource>().loop = true;
        GetComponent<AudioSource>().Play ();
        minPitch = 1.0f;
        maxPitch = 4.0f;
        // If the manual transmission is enabled, set the propeties of the first gear.
        if (manualTransmission) {
            acceleration = gears[0].GearAcceleration;
            maxSpeed = gears[0].GearMaxSpeed;
        }
    }
Ejemplo n.º 3
0
    public void carSelection(int index)
    {
        if (index > 0 && carSelectionIndex < 5)
        {
            carSelectionIndex += 1;
            Destroy(actualCar);

            //  carSelectionIndex += index;
            actualCar = Instantiate(carList[carSelectionIndex], instancePlace.transform.position, Quaternion.identity) as GameObject;
            getStats = actualCar.GetComponent<SimpleControlVehicle>();
            power.value = getStats.gears[1].GearMaxSpeed / 17;
            height.value = getStats.gears[1].GearAcceleration* 1.5f;
            grip.value = getStats.backForce / 20f;
        }
        if (index < 0 && carSelectionIndex > 0)
        {
            carSelectionIndex -= 1;
            Destroy(actualCar);
            //  carSelectionIndex += index;
            actualCar = Instantiate(carList[carSelectionIndex], instancePlace.transform.position, Quaternion.identity) as GameObject;
            getStats = actualCar.GetComponent<SimpleControlVehicle>();
            power.value = getStats.gears[1].GearMaxSpeed / 17;
            height.value = getStats.gears[1].GearAcceleration * 1.5f;
            grip.value = getStats.backForce / 20f;
        }
        Debug.Log(carSelectionIndex);
        //text.text = actualCar.name.Split('(')[0] + "\n Max: " + actualCar.GetComponent<SimpleControlVehicle>().maxSpeed * 1.15;
        updaData();
    }
Ejemplo n.º 4
0
 void Awake()
 {
     // Get the SimpleControlVehicle script of the game object.
     vehicleScript = gameObject.GetComponent <SimpleControlVehicle> ();
 }
Ejemplo n.º 5
0
 void Start()
 {
     actualCar = Instantiate(carList[carSelectionIndex], instancePlace.transform.position, Quaternion.identity) as GameObject;
     getStats = actualCar.GetComponent<SimpleControlVehicle>();
     power.value = getStats.gears[1].GearMaxSpeed / 17;
     height.value = getStats.gears[1].GearAcceleration * 1.5f;
     grip.value = getStats.backForce / 20f;
     updaData();
     money = PlayerPrefs.GetInt("Money");
        // text.text += "\n Max: " + actualCar.GetComponent<SimpleControlVehicle>().maxSpeed;
     opacity = new Color(0, 0, 0, 50);
 }