Beispiel #1
0
    void OnTriggerEnter(Collider other)
    {
        PowerupManager powerupManager = other.GetComponent <PowerupManager>();

        if (powerupManager)
        {
            VehicleController_V2 vehicle = other.GetComponent <VehicleController_V2>();
            vehicle.StartCoroutine(vehicle.DisableVehicle(disableDuration));

            StartCoroutine(CleanUp());
        }
    }
    void OnTriggerEnter(Collider other)
    {
        VehicleController_V2 car = other.GetComponent <VehicleController_V2>();

        if (car == null || isTargetFound)
        {
            return;
        }

        if (car.gameObject == ignoreObject)
        {
            return;
        }

        isTargetFound = true;
        target        = other.gameObject;
    }
    void Update()
    {
        if (ignoreObject != null && !rotationSet)
        {
            transform.rotation = Quaternion.Euler(ignoreObject.transform.forward);
            rotationSet        = true;
        }

        if (Time.time > startTime + lifetime && !isTargetFound)
        {
            StartCoroutine(Cleanup());
            return;
        }

        if (!isTargetFound)
        {
            if (ignoreObject != null)
            {
                transform.position = ignoreObject.transform.position + ignoreObject.transform.up * 2.5f + ignoreObject.transform.forward * 5;
                transform.rotation = ignoreObject.transform.rotation;
                objectMesh.transform.RotateAround(ignoreObject.transform.position, ignoreObject.transform.up, -missleSpeed * Time.deltaTime);
            }
        }
        else
        {
            transform.position = Vector3.MoveTowards(transform.position, target.transform.position, missleSpeed * Time.deltaTime);
            transform.LookAt(target.transform);
            missleSpeed += 10 * Time.deltaTime;

            if (Vector3.Distance(transform.position, target.transform.position) < 5f && isActive)
            {
                isActive = false;
                VehicleController_V2 vehicle = target.GetComponent <VehicleController_V2>();
                vehicle.StartCoroutine(vehicle.SlowSpeed(slowSpeed, disableDuration));
                StartCoroutine(Cleanup());
            }
        }
    }
    public override void ActivatePowerup(GameObject playerRef)
    {
        VehicleController_V2 vehicle = playerRef.GetComponent <VehicleController_V2>();

        vehicle.StartCoroutine(vehicle.BoostSpeed(SpeedIncrease, duration));
    }