Пример #1
0
 private void SetTunningButtons(CameraTarget tractor)
 {
     buttonTuningEng.drivetrain    = tractor.GetComponent <Drivetrain>();
     buttonTuningHand.axles        = tractor.GetComponent <Axles>();
     buttonTuningHand.carDynamics  = tractor.GetComponent <CarDynamics>();
     buttonTuningBrake.axles       = tractor.GetComponent <Axles>();
     buttonTuningBrake.carDynamics = tractor.GetComponent <CarDynamics>();
     buttonTuningEng.TunStep       = enemyCar[currentCar].TunSpeed;
     buttonTuningHand.TunStep      = enemyCar[currentCar].TunHandling;
     buttonTuningBrake.TunStep     = enemyCar[currentCar].TunBrake;
 }
Пример #2
0
        protected override bool Initialize(CameraTarget newTarget)
        {
            Vehicle vehicle = newTarget.GetComponent <Vehicle>();

            if (vehicle == null)
            {
                return(false);
            }

            // If compatible vehicle classes are specified, check that the list contains this vehicle's class.
            if (specifyCompatibleVehicleClasses)
            {
                if (compatibleVehicleClasses.IndexOf(vehicle.VehicleClass) != -1)
                {
                    return(base.Initialize(newTarget));
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(base.Initialize(newTarget));
            }
        }
Пример #3
0
    private void ResetTunning()
    {
        CameraTarget tractor    = character.GetComponentInChildren <CameraTarget>();
        Drivetrain   drivetrain = tractor.GetComponent <Drivetrain>();

        drivetrain.maxPower  = enemyCar[currentCar].MaxPower;
        drivetrain.maxTorque = enemyCar[currentCar].MaxTorque;
        Axles axles = tractor.GetComponent <Axles>();

        axles.frontAxle.sidewaysGripFactor  = enemyCar[currentCar].Sideways;
        axles.rearAxle.sidewaysGripFactor   = enemyCar[currentCar].Sideways;
        axles.frontAxle.brakeFrictionTorque = enemyCar[currentCar].Brake;
        axles.rearAxle.brakeFrictionTorque  = enemyCar[currentCar].Brake;
        foreach (Axle axle in axles.otherAxles)
        {
            axle.sidewaysGripFactor  = enemyCar[currentCar].Sideways;
            axle.brakeFrictionTorque = enemyCar[currentCar].Brake;
        }
        //tractor.GetComponent<Setup>().SaveSetup();
        maxSpeedIndicator.text = enemyCar[currentCar].MaxSpeed.ToString("f0");
    }
Пример #4
0
        public override void SetCameraTarget(CameraTarget target)
        {
            if (targetVehicle != null)
            {
                targetVehicle.onDestroyed.RemoveListener(OnVehicleDestroyed);
            }

            base.SetCameraTarget(target);
            targetVehicle = cameraTarget == null ? null : target.GetComponent <Vehicle>();

            if (targetVehicle != null)
            {
                targetVehicle.onDestroyed.AddListener(OnVehicleDestroyed);
            }

            onTargetVehicleChanged.Invoke(targetVehicle);
        }
Пример #5
0
    void FindTarget()
    {
        CancelOffsetMove();

        m_Target = FindObjectOfType <CameraTarget>();

        if (m_Target != null)
        {
            m_TargetDirection = m_Target.GetComponent <TileDirection>();
            m_FacingLeft      = m_TargetDirection.m_Direction == Direction.LEFT;
            m_Offset          = m_FacingLeft ? m_LeftFacingOffset : m_RightFacingOffset;

            var eventData = new CameraControllerEventData()
            {
                m_CameraTarget = m_Target,
            };

            m_Events.FoundTarget.Invoke(eventData);
        }
    }
Пример #6
0
        /// <summary>
        /// Called when the vehicle camera's camera target changes.
        /// </summary>
        /// <param name="newTarget">The new camera target.</param>
        protected virtual void OnCameraTargetChanged(CameraTarget newTarget)
        {
            if (targetVehicle != null)
            {
                targetVehicle.onDestroyed.RemoveListener(OnVehicleDestroyed);
            }

            if (newTarget != null)
            {
                targetVehicle = newTarget.GetComponent <Vehicle>();
                if (targetVehicle != null)
                {
                    targetVehicle.onDestroyed.AddListener(OnVehicleDestroyed);
                }
            }
            else
            {
                targetVehicle = null;
            }
        }
Пример #7
0
 private void SetTunningButtons(CameraTarget tractor)
 {
   buttonTuningEng.drivetrain = tractor.GetComponent<Drivetrain>();
   buttonTuningHand.axles = tractor.GetComponent<Axles>();
   buttonTuningHand.carDynamics = tractor.GetComponent<CarDynamics>();
   buttonTuningBrake.axles = tractor.GetComponent<Axles>();
   buttonTuningBrake.carDynamics = tractor.GetComponent<CarDynamics>();
   buttonTuningEng.TunStep = enemyCar[currentCar].TunSpeed;
   buttonTuningHand.TunStep = enemyCar[currentCar].TunHandling;
   buttonTuningBrake.TunStep = enemyCar[currentCar].TunBrake;
 }
Пример #8
0
    private void Race()//ButtonRace
    {
        PlayerPrefs.SetInt("CurrentCar", currentCar);
        character.transform.parent = null;
        if (PlayerPrefs.HasKey("StartCarPos"))
        {
            if (first)
            {
                character.transform.position = carLevelPos[PlayerPrefs.GetInt("StartCarPos")].position;
                character.transform.rotation = carLevelPos[PlayerPrefs.GetInt("StartCarPos")].rotation;
                Debug.Log("Start from " + PlayerPrefs.GetInt("StartCarPos") + " town");
            }
            else//Из гаража
            {
                character.transform.position = beforeGaragePosition;
                character.transform.rotation = beforeGarageRotation;
                Debug.Log("Start from Garage");
            }
        }
        else//Первый запуск
        {
            character.transform.position = carLevelPos[0].position;
            character.transform.rotation = carLevelPos[0].rotation;
            Debug.Log("First town");
        }
        //Следы
        Skidmarks skids = character.GetComponentInChildren <Skidmarks>();

        skids.gameObject.SetActive(true);
        skids.transform.position = Vector3.zero;
        skids.transform.rotation = Quaternion.identity;
        carcameras.gameObject.SetActive(true);
        cameraGarage.SetActive(false);
        CameraTarget tractor = character.GetComponentInChildren <CameraTarget>(); //Находим грузовик, на который будет нацелена камера

        if (tractor != null)
        {
            carcameras.target = tractor.transform;
            foreach (var butt in buttonsAddTrailer)
            {
                butt.TruckCar = tractor.transform;
            }
            AxisCarController aCC = tractor.GetComponent <AxisCarController>();
            aCC.On = true;
            steer.axisCarController          = aCC;
            buttonRulRight.axisCarController = aCC;
            buttonRulLeft.axisCarController  = aCC;
            buttonBrake.axisCarController    = aCC;
            buttonNitro.axisCarController    = aCC;
            strelki.drivetrain = tractor.GetComponent <Drivetrain>();

            map.Truck = tractor.transform;

            if (raceStart != null)                                                //Если заходили в гагаж и меню станции
            {
                StartCoroutine(ShowStationMenu(gamePanel.animation.clip.length)); //!!! Должно быть не gamePanel, a Upgrade Panel
                aCC.InStation = true;
                Debug.LogWarning("Continue: raceStart != null");
            }
            else//При первом запуске или перезапуск из гонки активируем Game Menu
            {
                aCC.InStation = false;
                StartCoroutine(ShowGameMenu(gamePanel.animation.clip.length));
                Debug.LogWarning("Continue: raceStart == null");
            }
        }
        gamePanel.enabled = true;
        cameraMap.SetActive(true);
        gragePanel.enabled   = false;
        infoPanel.enabled    = false;
        upgradePanel.enabled = false;
    }