Ejemplo n.º 1
0
    void Start()
    {
        SpawnVehicle();

        engine         = newVehicle.GetComponentInChildren <Motor>();
        propertySetter = newVehicle.GetComponent <PropertyToggleSetter>();

        stuntText.gameObject.SetActive(stuntMode);
        scoreText.gameObject.SetActive(stuntMode);
    }
Ejemplo n.º 2
0
        public void SpawnVehicle(int vehicle)
        {
            this.newVehicle = Instantiate(this.vehicles[vehicle],
                                          this.spawnPoint,
                                          Quaternion.LookRotation(this.spawnRot, GlobalControl.worldUpDir));
            this.cam.target = this.newVehicle.transform;
            this.cam.Initialize();
            this.vp = this.newVehicle.GetComponent <VehicleParent>();

            this.trans = this.newVehicle.GetComponentInChildren <Transmission>();
            if (this.trans)
            {
                this.trans.automatic = this.autoShift;
                this.newVehicle.GetComponent <VehicleParent>().brakeIsReverse = this.autoShift;

                if (this.trans is GearboxTransmission)
                {
                    this.gearbox = this.trans as GearboxTransmission;
                }
                else if (this.trans is ContinuousTransmission)
                {
                    this.varTrans = this.trans as ContinuousTransmission;

                    if (!this.autoShift)
                    {
                        this.vp.brakeIsReverse = true;
                    }
                }
            }

            if (this.newVehicle.GetComponent <VehicleAssist>())
            {
                this.newVehicle.GetComponent <VehicleAssist>().enabled = this.assist;
            }

            if (this.newVehicle.GetComponent <FlipControl>() && this.newVehicle.GetComponent <StuntDetect>())
            {
                this.newVehicle.GetComponent <FlipControl>().flipPower =
                    this.stuntMode && this.assist ? new Vector3(10, 10, -10) : Vector3.zero;
                this.newVehicle.GetComponent <FlipControl>().rotationCorrection =
                    this.stuntMode ? Vector3.zero : (this.assist ? new Vector3(5, 1, 10) : Vector3.zero);
                this.newVehicle.GetComponent <FlipControl>().stopFlip = this.assist;
                this.stunter = this.newVehicle.GetComponent <StuntDetect>();
            }

            this.engine         = this.newVehicle.GetComponentInChildren <Motor>();
            this.propertySetter = this.newVehicle.GetComponent <PropertyToggleSetter>();

            this.stuntText.gameObject.SetActive(this.stuntMode);
            this.scoreText.gameObject.SetActive(this.stuntMode);
        }
Ejemplo n.º 3
0
    public void SpawnVehicle(int vehicle = 0)
    {
        //newVehicle = Instantiate(vehicles[vehicle], spawnPoint, Quaternion.LookRotation(spawnRot, GlobalControl.worldUpDir)) as GameObject;
        //cam.target = newVehicle.transform;
        //cam.Initialize();
        vp = newVehicle.GetComponent <VehicleParent>();

        trans = newVehicle.GetComponentInChildren <Transmission>();
        if (trans)
        {
            trans.automatic = autoShift;
            //newVehicle.GetComponent<VehicleParent>().brakeIsReverse = autoShift;

            if (trans is GearboxTransmission)
            {
                gearbox = trans as GearboxTransmission;
            }
            else if (trans is ContinuousTransmission)
            {
                varTrans = trans as ContinuousTransmission;
                if (!autoShift)
                {
                    vp.brakeIsReverse = true;
                }
            }
        }

        if (newVehicle.GetComponent <VehicleAssist>())
        {
            newVehicle.GetComponent <VehicleAssist>().enabled = assist;
        }

        if (newVehicle.GetComponent <FlipControl>() && newVehicle.GetComponent <StuntDetect>())
        {
            newVehicle.GetComponent <FlipControl>().flipPower          = stuntMode && assist ? new Vector3(10, 10, -10) : Vector3.zero;
            newVehicle.GetComponent <FlipControl>().rotationCorrection = stuntMode ? Vector3.zero : (assist ? new Vector3(5, 1, 10) : Vector3.zero);
            newVehicle.GetComponent <FlipControl>().stopFlip           = assist;
            //stunter = newVehicle.GetComponent<StuntDetect>();
        }

        engine         = newVehicle.GetComponentInChildren <Motor>();
        propertySetter = newVehicle.GetComponent <PropertyToggleSetter>();

        stuntText.gameObject.SetActive(stuntMode);
        scoreText.gameObject.SetActive(stuntMode);
    }
Ejemplo n.º 4
0
        public override void OnInspectorGUI()
        {
            var boldFoldout = new GUIStyle(EditorStyles.foldout);

            boldFoldout.fontStyle = FontStyle.Bold;
            var targetScript = (PropertyToggleSetter)this.target;
            var allTargets   = new PropertyToggleSetter[this.targets.Length];

            this.isPrefab = PrefabUtility.GetPrefabType(targetScript) == PrefabType.Prefab;

            for (var i = 0; i < this.targets.Length; i++)
            {
                Undo.RecordObject(this.targets[i], "Property Toggle Setter Change");
                allTargets[i] = this.targets[i] as PropertyToggleSetter;
            }

            this.DrawDefaultInspector();

            if (!this.isPrefab && targetScript.gameObject.activeInHierarchy)
            {
                showButtons = EditorGUILayout.Foldout(showButtons, "Quick Actions", boldFoldout);
                EditorGUI.indentLevel++;
                if (showButtons)
                {
                    if (GUILayout.Button("Get Variables"))
                    {
                        foreach (var curTarget in allTargets)
                        {
                            curTarget.steerer              = curTarget.GetComponentInChildren <SteeringControl>();
                            curTarget.transmission         = curTarget.GetComponentInChildren <Transmission>();
                            curTarget.suspensionProperties = curTarget.GetComponentsInChildren <SuspensionPropertyToggle>();
                        }
                    }
                }

                EditorGUI.indentLevel--;
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(targetScript);
            }
        }
    public override void OnInspectorGUI()
    {
        GUIStyle boldFoldout = new GUIStyle(EditorStyles.foldout);
        boldFoldout.fontStyle = FontStyle.Bold;
        PropertyToggleSetter targetScript = (PropertyToggleSetter)target;
        PropertyToggleSetter[] allTargets = new PropertyToggleSetter[targets.Length];
        isPrefab = PrefabUtility.GetPrefabType(targetScript) == PrefabType.Prefab;

        for (int i = 0; i < targets.Length; i++)
        {
            Undo.RecordObject(targets[i], "Property Toggle Setter Change");
            allTargets[i] = targets[i] as PropertyToggleSetter;
        }

        DrawDefaultInspector();

        if (!isPrefab && targetScript.gameObject.activeInHierarchy)
        {
            showButtons = EditorGUILayout.Foldout(showButtons, "Quick Actions", boldFoldout);
            EditorGUI.indentLevel ++;
            if (showButtons)
            {
                if (GUILayout.Button("Get Variables"))
                {
                    foreach (PropertyToggleSetter curTarget in allTargets)
                    {
                        curTarget.steerer = curTarget.GetComponentInChildren<SteeringControl>();
                        curTarget.transmission = curTarget.GetComponentInChildren<Transmission>();
                        curTarget.suspensionProperties = curTarget.GetComponentsInChildren<SuspensionPropertyToggle>();
                    }
                }
            }
            EditorGUI.indentLevel --;
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(targetScript);
        }
    }
Ejemplo n.º 6
0
    public void SpawnVehicle(int vehicle)
    {
        newVehicle = Instantiate(vehicles[vehicle], spawnPoint, Quaternion.LookRotation(spawnRot, GlobalControl.worldUpDir)) as GameObject;
        cam.target = newVehicle.transform;
        cam.Initialize();
        vp = newVehicle.GetComponent<VehicleParent>();

        cam.GetComponent<CameraControlls>().cameraTarget = newVehicle.transform;

        trans = newVehicle.GetComponentInChildren<Transmission>();
        if (trans)
        {
            trans.automatic = autoShift;
            newVehicle.GetComponent<VehicleParent>().brakeIsReverse = autoShift;

            if (trans is GearboxTransmission)
            {
                gearbox = trans as GearboxTransmission;
            }
            else if (trans is ContinuousTransmission)
            {
                varTrans = trans as ContinuousTransmission;

                if (!autoShift)
                {
                    vp.brakeIsReverse = true;
                }
            }
        }

        if (newVehicle.GetComponent<VehicleAssist>())
        {
            newVehicle.GetComponent<VehicleAssist>().enabled = assist;
        }

        if (newVehicle.GetComponent<FlipControl>() && newVehicle.GetComponent<StuntDetect>())
        {
            newVehicle.GetComponent<FlipControl>().flipPower = stuntMode && assist ? new Vector3(10, 10, -10) : Vector3.zero;
            newVehicle.GetComponent<FlipControl>().rotationCorrection = stuntMode ? Vector3.zero : (assist ? new Vector3(5, 1, 10) : Vector3.zero);
            newVehicle.GetComponent<FlipControl>().stopFlip = assist;
            stunter = newVehicle.GetComponent<StuntDetect>();
        }

        engine = newVehicle.GetComponentInChildren<Motor>();
        propertySetter = newVehicle.GetComponent<PropertyToggleSetter>();

        stuntText.gameObject.SetActive(stuntMode);
        scoreText.gameObject.SetActive(stuntMode);
    }