예제 #1
0
    public void PlayWinSound()
    {
        GameObject ap          = Instantiate(audioPack);
        PlaySfx    audioScript = ap.GetComponent <PlaySfx>();

        audioScript.soundFile = winSound;
        audioScript.Play();
    }
예제 #2
0
    public void PlayButtonClick()
    {
        GameObject ap          = Instantiate(audioPack);
        PlaySfx    audioScript = ap.GetComponent <PlaySfx>();

        audioScript.soundFile = buttonClick;
        audioScript.Play();
    }
예제 #3
0
    public void Spawn(GameObject prefabToSpawn)
    {
        GameObject    spawned      = Instantiate(prefabToSpawn, transform.position, prefabToSpawn.transform.rotation);
        EnemyMovement enemySpawned = spawned.GetComponent <EnemyMovement>();

        enemySpawned.SetDirection(directionToSpawn);

        // Change speed according to level.
        int difficulty = gm.GetDifficulty();

        enemySpawned.SetSpeed(difficulty > 1 ? enemySpawned.GetSpeed() + (difficulty - 1) * 0.75f : enemySpawned.GetSpeed());

        // Play Spawn sfx
        PlaySfx sfx = spawned.GetComponent <PlaySfx>();

        sfx.SetPitch(0, Random.Range(0.85f, 1.15f));
        sfx.Play(0);
    }