void OnCollisionEnter(Collision col)
    {
        if (canBounce)
        {
            BulletBouncer bb = col.transform.GetComponent <BulletBouncer> ();
            if (bb != null && bb.active)
            {
                if (bb.target != null)
                {
                    Rigidbody br = transform.GetComponent <Rigidbody> ();
                    br.velocity = (bb.target.position - transform.position).normalized * br.velocity.magnitude;
                }
                return;
            }
        }
        ExplosionGenerator eg = GetComponent <ExplosionGenerator> ();

        if (eg != null)
        {
            eg.Detonate(col.transform);
        }
        if (dp != null)
        {
            dp.ProvideDamage(col.transform);
        }
        Destroy(gameObject);
    }
Exemple #2
0
 void Start()
 {
     saber     = GetComponentInChildren <LightsaberManager> ();
     attack    = GetComponentInChildren <MeleeAttackManager>();
     bouncer   = GetComponent <BulletBouncer>();
     attackKey = this.GetComponent <PlayerBlaster>().key;
 }