コード例 #1
0
    private void Fire()
    {
        shotCounter -= Time.deltaTime;

        if (shotCounter <= 0)
        {
            GameObject newEnemyShot = Instantiate(enemyLaser, transform.position + new Vector3(0, -0.65f, 0), Quaternion.identity);
            newEnemyShot.transform.parent = enemySpawner.CleanUpContainer();
            AudioSource.PlayClipAtPoint(laserAudioClip, Camera.main.transform.position, 0.1f);
            shotCounter = Random.Range(minShotTime, maxShotTime);
        }
    }
コード例 #2
0
 IEnumerator Refire()
 {
     while (true)
     {
         GameObject newLaser = Instantiate(laserPrefab, transform.position + new Vector3(0, 0.65f, 0), Quaternion.identity);
         newLaser.transform.parent = enemySpawner.CleanUpContainer();
         AudioSource.PlayClipAtPoint(laserAudioClip, Camera.main.transform.position, 0.1f);
         yield return(new WaitForSeconds(firerate));
     }
 }
コード例 #3
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        DamageDealer damaging = other.GetComponent <DamageDealer>();

        if (damaging)
        {
            health -= damaging.Damage();

            if (health <= 0)
            {
                GameObject newLExplosionVFX = Instantiate(laserExplosionVFX, transform.position, Quaternion.identity);
                newLExplosionVFX.transform.parent = enemySpawner.CleanUpContainer();
                Destroy(newLExplosionVFX, 1f);
                Destroy(this.gameObject);
            }
        }
    }