Beispiel #1
0
    void Cough()
    {
        if (masked)
        {
            coughParticles.emission.SetBurst(0, new ParticleSystem.Burst(0.0f, radiusArea * 1));
        }
        else
        {
            coughParticles.emission.SetBurst(0, new ParticleSystem.Burst(0.0f, radiusArea * 10));
        }
        coughParticles.Play();

        Collider[] insideColliders = Physics.OverlapSphere(transform.position, radiusArea);
        foreach (Collider col in insideColliders)
        {
            Contagion script = col.transform.gameObject.GetComponent <Contagion>();
            if (script && script != this)
            {
                if (masked)
                {
                    // Masqué, on n'infecte 1 fois sur 4 en moyenne
                    if (Random.Range(0, chanceToInfectMasked) == 0)
                    {
                        script.GetInfected();
                    }
                }
                else
                {
                    // Non-masqué, on n'infecte 1 fois sur 2 en moyenne
                    if (Random.Range(0, chanceToInfect) == 0)
                    {
                        script.GetInfected();
                    }
                }
            }
        }
        cough = false;
    }
Beispiel #2
0
    void Cough()
    {
        coughParticles.Play();

        Collider[] insideColliders = Physics.OverlapSphere(transform.position, radiusArea);
        foreach (Collider col in insideColliders)
        {
            //ajouter Random.Range() pour ne pas être contaminé forcement à chaque fois
            Contagion script = col.transform.gameObject.GetComponent <Contagion>();
            if (script && script != this)
            {
                script.GetInfected();
            }
        }
        cough = false;
    }