Beispiel #1
0
    private void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);

            library = GetComponent <SoundLibrary>();

            musicSources = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject newMusicSource = new GameObject("Music source " + (i + 1));
                musicSources[i] = newMusicSource.AddComponent <AudioSource>();
                newMusicSource.transform.parent = transform;
                newMusicSource.GetComponent <AudioSource>().loop = true;
            }

            GameObject newSoundEffect2Dsource = new GameObject("2D sfx source");
            sfx2Dsource = newSoundEffect2Dsource.AddComponent <AudioSource>();
            newSoundEffect2Dsource.transform.parent = transform;

            masterVolumePercent      = PlayerPrefs.GetFloat("master vol", 0);
            soundEffectVolumePercent = PlayerPrefs.GetFloat("soundEffect vol", 0);
            musicVolumePercent       = PlayerPrefs.GetFloat("music vol", 0);
        }
    }
Beispiel #2
0
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);

            library      = GetComponent <SoundLibrary>();
            musicSources = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject newMusicSource = new GameObject("Music Source " + (i + 1));
                musicSources[i] = newMusicSource.AddComponent <AudioSource>();
                newMusicSource.transform.parent = transform;
            }

            masterVolumePercent = PlayerPrefs.GetFloat("Master vol", masterVolumePercent);
            sfxVolumePercent    = PlayerPrefs.GetFloat("Sfx vol", sfxVolumePercent);
            musicVolumePercent  = PlayerPrefs.GetFloat("Music vol", musicVolumePercent);
        }
    }
    void Update()
    {
        // 諸々の解析
        float hertz = SoundLibrary.AnalyzeSound(mic[1], 1024 * 8, 0.04f);

        if (hertz > 0)
        {
            float  scale = SoundLibrary.ConvertHertzToScale(hertz);
            string s     = SoundLibrary.ConvertScaleToString(scale);
            Debug.Log(hertz + "Hz, Scale:" + scale + ", " + s);
            // 波形描画
            wave[wave_count] = scale;
        }
        else if (wave_count != 0)
        {
            wave[wave_count] = wave[wave_count - 1];
            Debug.Log("No input.");
        }
        SoundLibrary.ScaleWave(wave, wave_count, line);
        wave_count++;
        if (wave_count >= wave_num)
        {
            wave_count = 0;
        }
    }
Beispiel #4
0
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);

            library  = GetComponent <SoundLibrary>();
            aSources = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject newAudioSource = new GameObject("Audio source " + (i + 1));
                aSources[i] = newAudioSource.AddComponent <AudioSource>();
                newAudioSource.transform.parent = transform;
            }

            GameObject newSfx2DSource = new GameObject("2D Sfx source ");
            sfx2DSource = newSfx2DSource.AddComponent <AudioSource>();
            newSfx2DSource.transform.parent = transform;

            audiolistener   = FindObjectOfType <AudioListener>().transform;
            playerTransform = FindObjectOfType <Player>().transform;

            masterVolumePercent = PlayerPrefs.GetFloat("Master volume", masterVolumePercent);
            sfxVolumePercent    = PlayerPrefs.GetFloat("SFX volume", sfxVolumePercent);
            musicVolumePercent  = PlayerPrefs.GetFloat("Music volume", musicVolumePercent);
        }
    }
Beispiel #5
0
    private void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
            return;
        }

        instance = this;
        DontDestroyOnLoad(gameObject);

        library = GetComponent <SoundLibrary>();

        musicSources = new AudioSource[2];

        for (int i = 0; i < 2; i++)
        {
            GameObject newAudioSource = new GameObject("Audio " + (i + 1));
            newAudioSource.transform.parent = transform;
            musicSources[i] = newAudioSource.AddComponent <AudioSource>();
        }

        GameObject sfxAudioSource = new GameObject("SFX Audio Source");

        sfxAudioSource.transform.parent = transform;
        sfx2DSource = sfxAudioSource.AddComponent <AudioSource>();

        masterVolumePercent = PlayerPrefs.GetFloat("Master volume", masterVolumePercent);
        musicVolumePercent  = PlayerPrefs.GetFloat("Music volume", musicVolumePercent);
        sfxVolumePercent    = PlayerPrefs.GetFloat("SFX volume", sfxVolumePercent);
    }
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(this);
            library = GetComponent <SoundLibrary>();

            musicSources = new AudioSource[2];
            for (int i = 0; i < 2; ++i)
            {
                GameObject newMusicSource = new GameObject("Music source " + (i + 1));
                musicSources[i] = newMusicSource.AddComponent <AudioSource>();
                newMusicSource.transform.parent = transform;
            }

            GameObject newSfx2DSource = new GameObject("Sfx 2D Source");
            sfx2DSource = newSfx2DSource.AddComponent <AudioSource>();
            sfx2DSource.transform.parent = transform;

            audioListener = FindObjectOfType(typeof(AudioListener)) as Transform;
            playerT       = FindObjectOfType(typeof(Player)) as Transform;

            masterVolumePercent = PlayerPrefs.GetFloat("master volume", 1);
            sfxVolumePercent    = PlayerPrefs.GetFloat("sfx volume", 1);
            musicVolumePercent  = PlayerPrefs.GetFloat("music volume", 1);
        }
    }
Beispiel #7
0
    void Awake()
    {
        if (instance != null)            //인스턴스 초기화
        {
            Destroy(gameObject);         // 없으면 삭제
        }
        else
        {
            instance = this;                                             // 아니라면 instance = this;

            DontDestroyOnLoad(gameObject);                               //로드시에도 사라지지 않음
            library = GetComponent <SoundLibrary>();                     // 사운드 라이브러리 스크립트를 가져옴

            GameObject newMusicSource = new GameObject("Music source "); // 하나의 배경음악을 담음
            musicSources = newMusicSource.AddComponent <AudioSource>();
            newMusicSource.transform.parent = transform;

            GameObject newSfx2DSource = new GameObject("2D sfx source ");   // 사운드 이팩트를 담음
            sfx2DSource = newSfx2DSource.AddComponent <AudioSource>();
            newSfx2DSource.transform.parent = transform;

            masterVolumePercent = PlayerPrefs.GetFloat("master vol", 1);     //볼륨 값을 가져옴 없으면 기본값 1
            sfxVolumePercent    = PlayerPrefs.GetFloat("sfx vol", 1);
            musicVolumePercent  = PlayerPrefs.GetFloat("music vol", 1);
        }
    }
Beispiel #8
0
    public void HandleDamage(Collider co)
    {
        SoundLibrary.ResetPitch(GetComponent <AudioSource>());


        if (!IsDead())
        {
            if (Time.time >= damageTimeStamp)
            {
                if (!gameObject.GetComponent <Player>())
                {
                    SoundLibrary.varySoundPitch(GetComponent <AudioSource>(), 0.05f);
                }
                Bullet projGo = co.GetComponentInParent <Bullet>();
                SetHealth(GetHealth() - projGo.GetDamage());
                damageTimeStamp = Time.time + damageIFrameRate;

                if (!gameObject.CompareTag("Player") && gameObject.GetComponent <Unit>())
                {
                    GetComponent <AudioSource>().PlayOneShot(hurt);
                    StartCoroutine(DamageFlicker());
                }
                else if (gameObject.CompareTag("Player") && gameObject.GetComponent <Unit>())
                {
                    GetComponent <AudioSource>().PlayOneShot(sl.ChoosePlayerHurt());
                }
                HandleDeath(co);
            }
        }
    }
Beispiel #9
0
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
            SceneManager.sceneLoaded += OnSceneLoad;

            musicSources = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject newMusicSource = new GameObject("Music Source " + (i + 1));
                musicSources[i] = newMusicSource.AddComponent <AudioSource>();
                newMusicSource.transform.parent = transform;
            }
            GameObject newSfx2DSource = new GameObject("2D SFX Source");
            sfx2DSource = newSfx2DSource.AddComponent <AudioSource>();
            sfx2DSource.transform.parent = transform;

            audioListener = FindObjectOfType <AudioListener>().transform;
            AssignPlayerT();
            library = GetComponent <SoundLibrary>();

            masterVolumePercent = PlayerPrefs.GetFloat("Master Volume", 1);
            musicVolumePercent  = PlayerPrefs.GetFloat("Music Volume", 1);
            sfxVolumePercent    = PlayerPrefs.GetFloat("SFX Volume", 1);
        }
    }
Beispiel #10
0
    void Start()
    {
        if (parent)
        {
            if (GetComponent <Homing>() && parent.GetComponent <BasicAI>())
            {
                GetComponent <Homing>().SetTarget(parent.GetComponent <BasicAI>().GetTarget());
            }
            aso       = GetComponent <AudioSource>();
            playeraso = GameObject.Find("Player").GetComponent <AudioSource>();
            tr        = GetComponentInChildren <TrailRenderer>();


            if (parent == FindObjectOfType <Player>().gameObject || parent == FindObjectOfType <Player>().gameObject)
            {
                //quad damage
                damage *= FindObjectOfType <Player>().GetDamageModifier();
                if (FindObjectOfType <Player>().GetDamageModifier() > 1)
                {
                    if (GameObject.Find("Shotgun"))
                    {
                        playeraso.PlayOneShot(FindObjectOfType <SoundLibrary>().GetQuadBullet(), 0.15f);
                    }
                    else if (FindObjectOfType <Crucifier>())
                    {
                        playeraso.PlayOneShot(FindObjectOfType <SoundLibrary>().GetQuadBullet());
                    }
                    else
                    {
                        playeraso.PlayOneShot(FindObjectOfType <SoundLibrary>().GetQuadBullet(), 0.33f);
                    }
                    if (tr && tr.time < 0.5f)
                    {
                        GetComponentInChildren <TrailRenderer>().time = 0.5f;
                    }
                }
            }
            //ignore collisions between parent and bullet
            if (parent.gameObject.GetComponentInChildren <Collider>() && gameObject.GetComponentInChildren <Collider>())
            {
                Physics.IgnoreCollision(gameObject.GetComponentInChildren <Collider>(), parent.gameObject.GetComponentInChildren <Collider>(), true);
            }

            if (parent.gameObject.GetComponentInChildren <CharacterController>() && gameObject.GetComponentInChildren <Collider>())
            {
                Physics.IgnoreCollision(parent.gameObject.GetComponentInChildren <CharacterController>(), gameObject.GetComponentInChildren <Collider>(), true);
            }

            if (hasInaccurateFire)
            {
                transform.forward += (new Vector3(Random.Range(-inaccuracyOffset, inaccuracyOffset), Random.Range(-inaccuracyOffset, inaccuracyOffset), Random.Range(-inaccuracyOffset, inaccuracyOffset)));
                transform.Rotate(new Vector3(0, 0, Random.Range(0, 180)));
            }
            if (aso)
            {
                SoundLibrary.varySoundPitch(aso, 0.2f);
            }
            Destroy(gameObject, projDecay);
        }
    }
        public static Component create_soundeffects_component()
        {
            var effectlib = new SoundLibrary();

            effectlib.Library = new Dictionary <string, Component>();

            effectlib.Library.Add("rockslide_small", new Fab5SoundEffect("sound/effects/rockslide_smallcombo", "rockslide_small"));
            effectlib.Library.Add("thrust", new Fab5SoundEffect("sound/effects/thrust", "thrust"));
            effectlib.Library.Add("bang", new Fab5SoundEffect("sound/effects/bang1", "bang"));
            effectlib.Library.Add("bang2", new Fab5SoundEffect("sound/effects/bang2", "bang2"));
            effectlib.Library.Add("BatmanPunch", new Fab5SoundEffect("sound/effects/BatmanPunch", "BatmanPunch"));
            effectlib.Library.Add("LaserBlaster", new Fab5SoundEffect("sound/effects/LaserBlaster", "LaserBlaster"));
            effectlib.Library.Add("LaserBlaster2", new Fab5SoundEffect("sound/effects/LaserBlaster2", "LaserBlaster2"));
            effectlib.Library.Add("menu_click", new Fab5SoundEffect("sound/effects/click", "menu_click"));
            effectlib.Library.Add("begin_game", new Fab5SoundEffect("sound/effects/air_horn", "begin_game"));
            effectlib.Library.Add("menu_positive", new Fab5SoundEffect("sound/effects/menu_positive", "menu_positive"));
            effectlib.Library.Add("knock1m", new Fab5SoundEffect("sound/effects/knock1m", "knock1m"));
            effectlib.Library.Add("laser_impact", new Fab5SoundEffect("sound/effects/laser_impact", "laser_impact"));
            effectlib.Library.Add("small_explosion", new Fab5SoundEffect("sound/effects/small_explosion", "small_explosion"));
            effectlib.Library.Add("pickup", new Fab5SoundEffect("sound/effects/pickup", "pickup"));
            effectlib.Library.Add("turret", new Fab5SoundEffect("sound/effects/turret", "turret"));
            effectlib.Library.Add("spawn", new Fab5SoundEffect("sound/effects/spawn", "spawn"));
            effectlib.Library.Add("use_powerup", new Fab5SoundEffect("sound/effects/userpowerup", "use_powerup"));
            effectlib.Library.Add("nextpowerup", new Fab5SoundEffect("sound/effects/nextpowerup", "nextpowerup"));
            effectlib.Library.Add("explosion", new Fab5SoundEffect("sound/effects/explosion", "explosion"));


            return((Component)effectlib);
        }
Beispiel #12
0
    public void TargetEndGame(NetworkConnection target, bool winner)
    {
        TextMeshProUGUI endGameText = GameObject.Find("GameOverText").GetComponent <TextMeshProUGUI>();

        endGameText.text = winner ? "VICTORY" : "DEFEAT";
        SoundLibrary.PlaySound(winner ? "victory" : "defeat");
    }
Beispiel #13
0
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
            return;
        }
        instance = this;
        DontDestroyOnLoad(gameObject);

        listener     = transform.GetComponentInChildren <AudioListener> ().gameObject;
        soundLibrary = transform.GetComponent <SoundLibrary> ();

        musicSources = new AudioSource[2];
        for (int i = 0; i < musicSources.Length; i++)
        {
            GameObject newMusicSource = new GameObject("Music source " + (i + 1));
            musicSources[i] = newMusicSource.AddComponent <AudioSource> ();
            //musicSources [i].loop = true;
            newMusicSource.transform.parent = transform;
        }

        GameObject newSource2D = new GameObject("SFX source 2D");

        sfxSource2D = newSource2D.AddComponent <AudioSource> ();
        newSource2D.transform.parent = transform;

        masterVolume = PlayerPrefs.GetFloat("MasterVolume", 1);
        musicVolume  = PlayerPrefs.GetFloat("MusicVolume", 1);
        sfxVolume    = PlayerPrefs.GetFloat("SFXVolume", 1);
    }
Beispiel #14
0
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject); //destroys duplicate sound managers however to stop overlapping of same noise
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject); //this is to make sure audio manager keeps playing between scene changes

            library     = GetComponent <SoundLibrary>();
            musicScores = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject newMusicSource = new GameObject("Music source " + (i + 1));
                musicScores[i] = newMusicSource.AddComponent <AudioSource>();
                newMusicSource.transform.parent = transform;
            }
            GameObject newSfx2DSource = new GameObject("2D sfx source ");
            sfx2Dsource = newSfx2DSource.AddComponent <AudioSource>();
            newSfx2DSource.transform.parent = transform;

            audioListener = FindObjectOfType <AudioListener>().transform;
            if (FindObjectOfType <Player>() != null)
            {
                playerPos = FindObjectOfType <Player>().transform;
            }

            masterVolumePercent = PlayerPrefs.GetFloat("master volume", 1);
            sfxVolumePercent    = PlayerPrefs.GetFloat("sfx volume", 1);
            musicVolumePercent  = PlayerPrefs.GetFloat("music volume", 1);
            PlayerPrefs.Save();
        }
    }
Beispiel #15
0
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);

            library = GetComponent <SoundLibrary>();

            musicSouces = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject newMusicSource = new GameObject("Music source" + (i + 1));
                musicSouces[i] = newMusicSource.AddComponent <AudioSource>();
                newMusicSource.transform.parent = transform;
            }
            GameObject newSfx2DSource = new GameObject("2D sfx source");
            sfx2DSoruce = newSfx2DSource.AddComponent <AudioSource>();
            newSfx2DSource.transform.parent = transform;

            audiListener = FindObjectOfType <AudioListener>().transform;
            if (FindObjectOfType <PlayerController>() != null)
            {
                playerT = FindObjectOfType <PlayerController>().transform;
            }

            masterVolumePercent = PlayerPrefs.GetFloat("master vol", 1);
            sfxVolumePrecent    = PlayerPrefs.GetFloat("sfx vol", 1);
            musicVolumePercent  = PlayerPrefs.GetFloat("music vol", 1);
        }
    }
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);

            library = GetComponent <SoundLibrary>();

            musicSources = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject newMusicSource = new GameObject("Music source " + (i + 1));
                musicSources[i] = newMusicSource.AddComponent <AudioSource>();
                newMusicSource.transform.parent = transform;
            }
            GameObject newSfx2Dsource = new GameObject("2D sfx source");
            sfx2DSource = newSfx2Dsource.AddComponent <AudioSource>();
            newSfx2Dsource.transform.parent = transform;

            audioListener = FindObjectOfType <AudioListener>().transform;

            AudioSetting audioSetting = GameDataManager.instance.gameData.optionData.audioSetting;
            audioSetting.Load();
            masterVolumePercent = audioSetting.masterVolumePercent;
            musicVolumePercent  = audioSetting.musicVolumePercent;
            sfxVolumePercent    = audioSetting.sfxVolumePercent;
        }
    }
    private void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);

            musicSources = new AudioSource[2];
            for (int i = 0; i < musicSources.Length; i++)
            {
                GameObject newMusicSource = new GameObject("Music source " + (i + 1));
                musicSources[i] = newMusicSource.AddComponent <AudioSource>();
                newMusicSource.transform.parent = transform;
            }
            GameObject newSfx2DSource = new GameObject("2D SFX Source");
            sfx2DSource = newSfx2DSource.AddComponent <AudioSource>();
            DontDestroyOnLoad(newSfx2DSource);
            audioListener = FindObjectOfType <AudioListener>().transform;
            if (FindObjectOfType <Player>() != null)
            {
                playerT = FindObjectOfType <Player>().transform;
            }
            library = GetComponent <SoundLibrary>();

            masterVolumePercent = PlayerPrefs.GetFloat("Master Volume", 1);
            musicVolumePercent  = PlayerPrefs.GetFloat("Music Volume", 1);
            sfxVolumePercent    = PlayerPrefs.GetFloat("SFX Volume", 1);
        }
    }
Beispiel #18
0
 private void OnDestroy()
 {
     if (this == _instance)
     {
         _instance = null;
     }
 }
Beispiel #19
0
    public override bool FireProjectile()
    {
        Vector3 spawnLoc = GetComponentInChildren <SpriteRenderer>().transform.position;

        if (Player.CountFriends("LichSpawn") >= GetMaxSpawns())
        {
            return(false);
        }
        SoundLibrary.ResetPitch(gameObject.GetComponentInChildren <AudioSource>());
        SoundLibrary.varySoundPitch(gameObject.GetComponentInChildren <AudioSource>(), 0.5f);
        gameObject.GetComponentInChildren <AudioSource>().PlayOneShot(laughtrack);
        gameObject.GetComponentInChildren <AudioSource>().PlayOneShot(summontrack);
        GameObject instance = Instantiate(GetProjPrefab(), spawnLoc, Quaternion.identity, GameObject.Find("NecroSpawns").transform);

        instance.tag  = "LichSpawn";
        instance.name = GetProjPrefab().name;
        SetSRTS(Time.time + GetShootRate());
        instance.transform.forward = transform.forward;

        if (gameObject.GetComponentInChildren <Collider>())
        {
            Physics.IgnoreCollision(instance.GetComponentInChildren <Collider>(), gameObject.GetComponentInChildren <Collider>(), true);
        }

        return(true);
    }
Beispiel #20
0
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);

            soundsLibrary = GetComponent <SoundLibrary>();
            musicLibrary  = GetComponent <MusicLibrary>();

            musicSource = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject newMusicSource = new GameObject("MusicSource" + (i + 1));
                musicSource[i] = newMusicSource.AddComponent <AudioSource>();
                newMusicSource.transform.parent = transform;
            }

            GameObject newSfxSource = new GameObject("2D sfx source");
            sfxSource = newSfxSource.AddComponent <AudioSource>();
            newSfxSource.transform.parent = transform;

            masterVolumen = PlayerPrefs.GetFloat(AudioChannel.Master.ToString(), 1f);
            sfxVolumen    = PlayerPrefs.GetFloat(AudioChannel.Sfx.ToString(), 1);
            musicVolumen  = PlayerPrefs.GetFloat(AudioChannel.Music.ToString(), 1f);
        }
    }
Beispiel #21
0
    void Update()
    {
        // 諸々の解析
        float hertz = SoundLibrary.AnalyzeSound(mic, 1024 * 8, 0.01f);

        if (hertz > 0)
        {
            float  scale = SoundLibrary.ConvertHertzToScale(hertz);
            string s     = SoundLibrary.ConvertScaleToString(scale);
            Debug.Log("Mic.2 : " + hertz + "Hz, Scale:" + scale + ", " + s);

            scaText.text = s;
            // 波形描画
            wave[wave_count] = scale;
            tone             = scale;
        }
        else
        {
            wave[wave_count] = wave[(wave_count + wave.Length - 1) % wave.Length];
            scaText.text     = "No input";
        }
        SoundLibrary.ScaleWave(wave, wave_count, line);
        wave_count++;
        if (wave_count >= wave_num)
        {
            wave_count = 0;
        }
    }
Beispiel #22
0
    void Awake()
    {
        if (instance != null)
        {
            Debug.Log("destroy obj");
            Destroy(gameObject);
        }

        else
        {
            instance = this;
            library  = GetComponent <SoundLibrary>();

            musicSources = new AudioSource[2];//create our music sources
            for (int i = 0; i < 2; i++)
            {
                GameObject newMusicSource = new GameObject("Music source" + (i));
                musicSources[i] = newMusicSource.AddComponent <AudioSource>();
                newMusicSource.transform.parent = transform;
            }
            GameObject newSfx2Dsource = new GameObject("2D sfx source");
            sfx2DSource = newSfx2Dsource.AddComponent <AudioSource>();


            audioListener       = FindObjectOfType <AudioListener>().transform;
            masterVolumePrecent = PlayerPrefs.GetFloat("master vol", 1);
            sfxVolumePrecent    = PlayerPrefs.GetFloat("sfx vol", 1);
            musicVolumePrecent  = PlayerPrefs.GetFloat("music vol", 1);
        }
    }
Beispiel #23
0
    private void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;

            DontDestroyOnLoad(gameObject); //Não apaga quando troca de scene

            library = GetComponent <SoundLibrary>();

            musicSources = new AudioSource[musicQtd];
            for (int i = 0; i < musicQtd; i++)
            {
                GameObject newMusicSource = new GameObject("Music Source " + (i + 1));
                musicSources[i] = newMusicSource.AddComponent <AudioSource>();
                newMusicSource.transform.parent = transform;
            }

            GameObject newSfx2Dsource = new GameObject("2D sfx source");
            sfx2DSource = newSfx2Dsource.AddComponent <AudioSource>();
            newSfx2Dsource.transform.parent = transform;

            audioListener = FindObjectOfType <AudioListener>().transform;
            playerT       = FindObjectOfType <Player>().transform;

            //Carrega as preferências do player salvas
            masterVolumePercent = PlayerPrefs.GetFloat("master vol", masterVolumePercent);
            sfxVolumePercent    = PlayerPrefs.GetFloat("sfx vol", sfxVolumePercent);
            musicVolumePercent  = PlayerPrefs.GetFloat("music vol", musicVolumePercent);
        }
    }
Beispiel #24
0
    public void RemoveLibrary(SoundLibrary library)
    {
        List <SoundBank> oldBanks = new List <SoundBank>();

        if (soundLibrary != null)
        {
            oldBanks.AddRange(soundLibrary);
        }

        foreach (SoundBank bank in library.soundLibrary)
        {
            foreach (SoundBank oldBank in oldBanks)
            {
                if (oldBank.name == bank.name)
                {
                    oldBanks.Remove(oldBank);
                    break;
                }
            }
        }

        soundLibrary = oldBanks.ToArray();

        GenerateDictionary();
    }
    private void Awake()
    {
        if (instance != null)       //  allora esiste già, e questo è un duplicato
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;               //  non un'ottima prassi, ma supponiamo che l'audio manager sia unico
            DontDestroyOnLoad(gameObject); //  altrimenti cambiando scena si stopperebbe la musica

            musicSources = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject newMusicSource = new GameObject("Music Source " + (i + 1));
                musicSources[i] = newMusicSource.AddComponent <AudioSource>();
                musicSources[i].transform.parent = transform;
            }

            GameObject newSfx2DSource = new GameObject("2D Sfx Source");
            sfx2DSource = newSfx2DSource.AddComponent <AudioSource>();
            newSfx2DSource.transform.parent = transform;

            audioListener = FindObjectOfType <AudioListener>().transform;
            if (FindObjectOfType <Player>() != null)
            {
                playerT = FindObjectOfType <Player>().transform;
            }
            library = GetComponent <SoundLibrary>();

            masterVolumePerc = PlayerPrefs.GetFloat("MasterVol", .75f);
            sfxVolumePerc    = PlayerPrefs.GetFloat("SfxVol", .75f);
            musicVolumePerc  = PlayerPrefs.GetFloat("MusicVol", .75f);
        }
    }
Beispiel #26
0
    public virtual void Start()
    {
        sl   = FindObjectOfType <SoundLibrary>();
        unit = gameObject.GetComponent <Unit>();
        aso  = GetComponent <AudioSource>();

        switch (unit.name)
        {
        case "Revenant":
            unit.SetDeadClip(sl.GetRevenantDead());
            unit.SetHurtClip(sl.GetRevenantHurt());
            break;

        case "EliteRevenant":
            unit.SetDeadClip(sl.GetRevenantDead());
            unit.SetHurtClip(sl.GetRevenantHurt());
            break;

        case "FriendlyRevenant":
            unit.SetDeadClip(sl.GetRevenantDead());
            unit.SetHurtClip(sl.GetRevenantHurt());
            break;

        case "Necromancer":
            unit.SetDeadClip(sl.GetNecroDead());
            unit.SetHurtClip(sl.GetNecroHurt());
            break;
        }
    }
Beispiel #27
0
    void Awake()
    {
        if (INSTANCE != null)
        {
            Destroy(gameObject);
        }
        else
        {
            INSTANCE = this;
            DontDestroyOnLoad(gameObject);
            Library      = GetComponent <SoundLibrary>();
            MusicSources = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject NewMusicSource = new GameObject("Music source " + (i + 1));
                MusicSources[i] = NewMusicSource.AddComponent <AudioSource>();
                NewMusicSource.transform.parent = transform;
            }

            GameObject NewSoundFX2D = new GameObject("2D sfx source");
            SoundSource2D = NewSoundFX2D.AddComponent <AudioSource>();
            NewSoundFX2D.transform.parent = transform;

            AudioListenerTransform = FindObjectOfType <AudioListener>().transform;
            if (FindObjectOfType <Player>() != null)
            {
                PlayerTransform = FindObjectOfType <Player>().transform;
            }
        }

        MasterVolumePercent = PlayerPrefs.GetFloat("Master Volume", 1);
        MusicVolumePercent  = PlayerPrefs.GetFloat("Music Volume", 1);
        SfxVolumePercent    = PlayerPrefs.GetFloat("Sfx Volume", 1);
    }
    void Awake() {

        if (instance != null) { Destroy(gameObject); }
        else {

            instance = this;
            DontDestroyOnLoad(gameObject);

            library = GetComponent<SoundLibrary>();

            musicSources = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject newMusicSource = new GameObject("Music source " + (i + 1));
                musicSources[i] = newMusicSource.AddComponent<AudioSource>();
                newMusicSource.transform.parent = transform;
                musicSources[i].loop = true;
            }
            GameObject newSfx2Dsource = new GameObject("2D sfx source");
            sfx2DSource = newSfx2Dsource.AddComponent<AudioSource>();
            newSfx2Dsource.transform.parent = transform;

            audioListener = FindObjectOfType<AudioListener>().transform;
            if (FindObjectOfType<Camera>() != null)
            {
                cameraT = FindObjectOfType<Camera>().transform;
            }

            masterVolumePercent = PlayerPrefs.GetFloat("master vol", 1);
            sfxVolumePercent = PlayerPrefs.GetFloat("sfx vol", 1);
            musicVolumePercent = PlayerPrefs.GetFloat("music vol", 1);
        }
    }
Beispiel #29
0
    void Awake()
    {
        if (instance != null)
        {
            Destroy(gameObject);
        }
        else
        {
            instance = this;
            DontDestroyOnLoad(gameObject);

            library = GetComponent <SoundLibrary>();

            musicSources = new AudioSource[2];
            for (int i = 0; i < 2; i++)
            {
                GameObject newMusicSource = new GameObject("Music source " + (i + 1));
                musicSources[i]                 = newMusicSource.AddComponent <AudioSource>();
                musicSources[i].loop            = true;
                newMusicSource.transform.parent = transform;
            }
            GameObject newSfx2Dsource = new GameObject("2D sfx source");
            sfx2DSource = newSfx2Dsource.AddComponent <AudioSource>();
            newSfx2Dsource.transform.parent = transform;

            audioListener = FindObjectOfType <AudioListener>().transform;
        }
    }
 void Awake()
 {
     if (instance != null)
     {
         Debug.LogError("Error Sound Library already exists.");
     }
     instance = FindObjectOfType<SoundLibrary>();
 }
 void AssignSoundToSource(SoundLibrary soundLib, AudioSource source)
 {
     source.clip   = soundLib.GetClip();
     source.volume = soundLib.volume;
     source.pitch  = soundLib.pitch;
     source.loop   = soundLib.loop;
     source.outputAudioMixerGroup = soundLib.mixerGroup ? soundLib.mixerGroup : defaultAudioMixerGroup;
 }
Beispiel #32
0
 private void Start()
 {
     statl  = FindObjectOfType <StatLibrary>();
     altar  = FindObjectOfType <Altar>();
     player = FindObjectOfType <Player>();
     sc     = FindObjectOfType <SpawnController>();
     sl     = FindObjectOfType <SoundLibrary>();
 }
    // Use this for initialization
    void Start()
    {
        yLocation = this.transform.position.y + scrollHeight;
        downYLocation = yLocation - scrollHeight;

        //Inititalizes previous position with the start postition (AAJ)
        previousPosition = transform.position.y;

        CreateBGGraph();

        mainCamera = Camera.main;

        audioSources = this.GetComponents<AudioSource> ();
        audioSources[0].clip = Instrument;
        audioSources[1].clip = Instrument;

        GameObject temp = GameObject.FindGameObjectWithTag ("SoundLibrary");
        if (temp != null) {
            soundLibrary = temp.GetComponent<SoundLibrary> ();
        }//if

        GameObject temp2 = GameObject.FindGameObjectWithTag("Trace");
        if (temp2 != null) {
            tracingScript = temp2.GetComponent<TracingScript> ();
            if(tracingScript == null){
                Debug.LogError("tracing script is null");
            }
        }//if
        else {
            Debug.Log ("Nothing Found");
        }//else
        /*
        GameObject DrawObject = GameObject.FindGameObjectWithTag("Draw");
        if (DrawObject != null) {
            drawLine = DrawObject.GetComponent<DrawLine> ();
        }//if
        else {
            Debug.Log ("Did not find object tagged Draw");
        }//else
        */
        LoadDataForInstrument(tracingScript.GetSprite(),tracingScript.GetLinePoints(),tracingScript.GetFileName());

        graphSuspended.GetComponent<DrawLine> ().UpdateLine (RawData);

        Vector3 setter = new Vector3 (-25, -25, 0);
        //Debug.Log ("here");
        visibleNote = Instantiate (MusicNote, setter, this.transform.rotation) as GameObject;

        playButtonImage.color = invisible;
        pauseButtonImage.color = visible;
        loopButtonImage.color = invisible;
    }