예제 #1
0
 private void FireLaser()
 {
     if (Time.time > _canFire)
     {
         _fireRate = Random.Range(3f, 5f);
         _canFire  = Time.time + _fireRate;
         laser     = Instantiate(_enemyLaserPrefab, transform.position + new Vector3(0, _laserInstantiateLoc, 0), Quaternion.identity);
         Enemy_Laser _laser = laser.GetComponent <Enemy_Laser>();
         if (_laserInstantiateLoc == 0.6f)
         {
             _laser.FireUp();
         }
         else if (_laserInstantiateLoc == -0.6f)
         {
             _laser.FireDown();
         }
     }
 }
예제 #2
0
    void OnTriggerEnter2D(Collider2D col)
    {
        Enemy_Laser    eLaser = col.gameObject.GetComponent <Enemy_Laser> ();
        TurretBehavior turret = col.gameObject.GetComponent <TurretBehavior> ();
        AsteroidBig    big    = col.gameObject.GetComponent <AsteroidBig> ();
        AsteroidMed    med    = col.gameObject.GetComponent <AsteroidMed> ();
        AsteroidSmall  small  = col.gameObject.GetComponent <AsteroidSmall> ();

        if (eLaser)
        {
            eLaser.Hit();
            Destroy(gameObject);
            AudioSource.PlayClipAtPoint(destroyed, this.transform.position);
            Instantiate(debris, this.transform.position, Quaternion.identity);
        }

        if (big || med || small || turret || col.tag == "Wall")
        {
            Destroy(gameObject);
            AudioSource.PlayClipAtPoint(destroyed, this.transform.position);
            Instantiate(debris, this.transform.position, Quaternion.identity);
        }
    }