Exemplo n.º 1
0
 public void Delete()
 {
     if (OnDelete != null)
     {
         OnDelete.Invoke(VehicleBehaviour);
     }
     Destroy(gameObject);
 }
Exemplo n.º 2
0
        private void GenerateVehicle(VehicleBehaviour prefab, Vehicle vehicle)
        {
            var behaviour = Instantiate(prefab);

            behaviour.Vehicle = vehicle;
            if (onVehicleGenerated != null)
            {
                onVehicleGenerated.Invoke(behaviour);
            }
        }
Exemplo n.º 3
0
    IEnumerator Explode()
    {
        destroying = true;
        bodyMesh.gameObject.SetActive(false);
        explosionParticles.Play();

        yield return(new WaitUntil(() => explosionParticles.isStopped));

        OnDestroyed.Invoke(this);
        Destroy(gameObject);
    }
Exemplo n.º 4
0
 private IEnumerator LoopCoroutine()
 {
     while (true)
     {
         if (vehicleBehaviours.Any(x => x.DistanceFromStart < racetrackBehaviour.Racetrack.Length))
         {
             foreach (var behaviour in vehicleBehaviours.Where(x => x.DistanceFromStart < racetrackBehaviour.Racetrack.Length))
             {
                 if (behaviour.BlowoutTimer > 0)
                 {
                     behaviour.BlowoutTimer -= refreshRate;
                 }
                 else
                 {
                     if (Random.Range(0, 100) <= behaviour.Vehicle.TireBlowoutChance)
                     {
                         behaviour.BlowoutTimer += blowoutTimeout;
                         if (onTireBlowout != null)
                         {
                             onTireBlowout.Invoke(behaviour);
                         }
                     }
                     else
                     {
                         behaviour.DistanceFromStart += behaviour.Vehicle.GetSpeed();
                         racetrackBehaviour.SetToWorldPosition(behaviour.DistanceFromStart, behaviour.transform);
                         if (behaviour.DistanceFromStart >= racetrackBehaviour.Racetrack.Length)
                         {
                             behaviour.Place = lastPlace;
                             lastPlace++;
                         }
                     }
                 }
             }
         }
         else
         {
             EndLoop();
             yield break;
         }
         yield return(new WaitForSeconds(refreshRate));
     }
 }