Esempio n. 1
0
    public virtual void OnCollisionEnter(Collision collision)
    {
        //Debug.Log("Hit something " + collision.collider.name);

        ShipReference hitShip = null;

        //Debug.Log(collision.collider.name);


        hitShip = collision.collider.GetComponent <ShipReference>();



        if (hitShip != null)
        {
            if (hitShip.ParentShip == Attacker)
            {
                return;
            }
            else
            {
                //Debug.Log("Hit shield");
                ShieldBase shield = hitShip.Shield.GetComponent <ShieldBase>();

                if (shield.ParentShip == Attacker)
                {
                    return;
                }
                if (Damage.DamageType != DamageType.Shock)
                {
                    Damage.ShieldAmount *= DamageMultiplier;
                    Damage.HullAmount   *= DamageMultiplier;
                }
                if (Attacker == GameManager.Inst.PlayerControl.PlayerShip)
                {
                    GameManager.Inst.SoundManager.PlayUISoundRateLimited("HitMarkerSoft", 0.1f);
                }

                Damage.HitLocation = collision.contacts[0].point;
                Damage             = shield.ProcessDamage(Damage);
                if (Damage.HullAmount <= 1f)
                {
                    GameObject.Destroy(this.gameObject);
                    return;
                }

                hitShip.ParentShip.ProcessHullDamage(Damage, Attacker);


                GameObject.Destroy(this.gameObject);
            }
        }
        else
        {
            GameObject.Destroy(this.gameObject);
        }
    }
Esempio n. 2
0
    void OnParticleCollision(GameObject other)
    {
        ParticleSystem part = other.GetComponent <ParticleSystem>();
        List <ParticleCollisionEvent> collisionEvents = new List <ParticleCollisionEvent>();
        int numCollisionEvents = part.GetCollisionEvents(this.gameObject, collisionEvents);

        int i = 0;

        while (i < numCollisionEvents)
        {
            Vector3 pos    = collisionEvents[i].intersection;
            Damage  damage = new Damage();
            damage.ShieldAmount = 10;
            damage.HullAmount   = 0;
            damage.HitLocation  = pos;
            damage.DamageType   = DamageType.Kinetic;

            Shield.ProcessDamage(damage);
            i++;
        }
    }