Example #1
0
    /// <summary> If hit by a bullet </summary>
    /// <param name="hit"> The bullet </param>
    public virtual void Hit(Missile hit)
    {
        float dammage = hit.Dammage(Friendly);

        HP -= dammage;
        hit.Destroy();
        hit.Explode();
    }
Example #2
0
    void OnCollisionEnter(Collision other)
    {
        Missile missile = other.collider.GetComponent <Missile> ();

        if (other.collider.CompareTag("Hazard"))
        {
            health.TakeDamage(50);
            if (missile)
            {
                missile.Explode(0);
            }
        }
    }
Example #3
0
    private void OnCollisionEnter2D(Collision2D other)
    {
        EnemyMissile enemy   = other.gameObject.GetComponent <EnemyMissile>();
        Missile      missile = other.gameObject.GetComponent <Missile>();

        if (enemy != null)
        {
            enemy.DestroyEnemyMissile();
        }
        if (missile != null)
        {
            missile.Explode();
        }
    }
Example #4
0
    // Update is called once per frame
    void Update()
    {
        if (Time.timeScale == 0)
        {
            return;
        }

        if (Input.GetButtonDown("Fire1"))
        {
            AudioSource.PlayClipAtPoint(shootSounds[0], transform.position, .25f);

            Vector3    dir = Camera.main.transform.forward;
            RaycastHit hitInfo;

            //int layerMask = (1 << 11) | Physics.kDefaultRaycastLayers;

            if (Physics.Raycast(Camera.main.transform.position, dir, out hitInfo, range, laserMask.value))
            {
                Transform victim = hitInfo.collider.transform;

                Destroyable dest = victim.GetComponent <Destroyable>();
                while (dest == null && victim.parent != null)
                {
                    victim = victim.parent;
                    dest   = victim.GetComponent <Destroyable>();
                }

                if (dest != null)
                {
                    dest.DestroyMe();
                    Score.AddMult();
                }

                Missile missile = victim.GetComponent <Missile>();
                if (missile != null)
                {
                    missile.Explode();
                    Score.AddPoints(10000);
                }

                SpawnLaser(hitInfo.point);
                Instantiate(laserHitPrefab, hitInfo.point, Quaternion.identity);
            }
            else
            {
                SpawnLaser(Camera.main.transform.position + Camera.main.transform.forward * range);
            }
        }
    }
 void OnCollisionEnter(Collision c)
 {
     if (c.collider.name == "Player" && missile.owner == Missile.owners.PLAYER)
     {
         // Dont hit itself.
         return;
     }
     if (missile.type == Missile.types.MISSILE)
     {
         //				missile_explosion = GameObject.FindWithTag ("Explosion");
         //			    Vector3 p = missile.gameObject.transform.position;
         //		        missile_explosion.transform.position = p;
         //				missile_explosion.GetComponent<Detonator> ().Reset ();
         //				missile_explosion.GetComponent<Detonator> ().enabled = true;
         //				missile_explosion.GetComponent<Detonator> ().Explode ();
     }
     missile.Explode(c);
     GameObject.Destroy(missile.gameObject);
 }