コード例 #1
0
    private void OnParticleCollision(GameObject other)
    {
        ParticleSystem particleSystem = other.GetComponent <ParticleSystem>();

        if (particleSystem != null)
        {
            if (collisionEvents != null)
            {
                int numCollisionEvents = particleSystem.GetCollisionEvents(gameObject, collisionEvents);
                int i = 0;
                while (i < numCollisionEvents)
                {
                    ParticleSystem.Particle[] particles = new ParticleSystem.Particle[particleSystem.main.maxParticles];
                    int numParticlesAlive = particleSystem.GetParticles(particles);
                    for (int j = 0; j < numParticlesAlive; j++)
                    {
                        particles[j].remainingLifetime = 0;
                    }

                    ParticleDamage particleDamage = other.GetComponent <ParticleDamage>();
                    if (particleDamage != null)
                    {
                        health.Damage(particleDamage.damage);
                    }
                    i++;
                }
            }
        }
    }
コード例 #2
0
    private void OnParticleCollision(GameObject other)
    {
        GameObject     parent         = other.GetComponent <ParticleParent>().parent;
        ParticleDamage particleDamage = parent.GetComponent <ParticleDamage>();
        float          damage         = particleDamage.Damage(other.name, parent);

        if (!data.dead)
        {
            TakeDamage(damage, false);
        }
    }
コード例 #3
0
    void Start()
    {
        m_particleSystem = GetComponent<ParticleSystem>();
        m_audio = GetComponent<AudioSource>();
       
        if (!m_particleSystem)
        {
            Debug.Log(GetType().Name + " : No particle system attached. Disabling");
            enabled = false;
        }

        m_particleDamage = GetComponent<ParticleDamage>();
        m_particleDamage.enabled = false;

        Invoke("StartEffect", m_activationDelay);
    }
コード例 #4
0
    void Start()
    {
        m_particleSystem = GetComponent <ParticleSystem>();
        m_audio          = GetComponent <AudioSource>();

        if (!m_particleSystem)
        {
            Debug.Log(GetType().Name + " : No particle system attached. Disabling");
            enabled = false;
        }

        m_particleDamage         = GetComponent <ParticleDamage>();
        m_particleDamage.enabled = false;

        Invoke("StartEffect", m_activationDelay);
    }
コード例 #5
0
    private void OnParticleCollision(GameObject other)
    {
        ParticleSystem particleSystem = other.GetComponent <ParticleSystem>();

        if (particleSystem != null)
        {
            int numCollisionEvents = particleSystem.GetCollisionEvents(gameObject, collisionEvents);
            int i = 0;
            while (i < numCollisionEvents)
            {
                ParticleDamage particleDamage = other.GetComponent <ParticleDamage>();
                if (particleDamage != null)
                {
                    Vector3    hitPosition = collisionEvents[i].intersection;
                    GameObject particle    = Instantiate(particleDamage.damageParticleObject, hitPosition, Quaternion.identity, parentTransform);
                }
                i++;
            }
        }
    }
コード例 #6
0
 // Start is called before the first frame update
 void Start()
 {
     Particle = GunPoint.GetComponent <ParticleSystem>();
     PD       = Particle.gameObject.GetComponent <ParticleDamage>();
 }