Ejemplo n.º 1
0
    public static void PlayBg(string str, bool bLoop = true)
    {
        if (string.IsNullOrEmpty(str))
        {
            return;
        }
                #if true
        AudioClip clip = null;

        clip = Resources.Load("Sounds/" + str) as AudioClip;
        if (clip == null)
        {
            //if (Config.a.IsSoundDebug)
            Debug.LogError("Can't Find SoundClip = " + str);
        }

        if (bgMusic == null)
        {
            bgMusic           = soundObject.AddComponent <SoundBehaviour>();
            bgMusic.IsBgSound = true;
        }
        bgMusic.SetSound(
            clip,
            bLoop,
            Pitch,
            Sound.IsMute);
        bgMusic.Volume = 1f;
#else
        if (bAssetBundle)
        {
            AssetBundleManager.a.GetAssetAsync <AudioClip>("Sounds/" + str + ".mp3").completed += (a) => {
                AudioClip ac = ((AssetBundleRequest)a).asset as AudioClip;
                if (ac != null)
                {
                    AsyncPlay(ac, bLoop, true);
                }
                else
                {
                    AssetBundleManager.a.GetAssetAsync <AudioClip>("Sounds/" + str + ".wav").completed += (b) => {
                        ac = ((AssetBundleRequest)b).asset as AudioClip;
                        if (ac != null)
                        {
                            AsyncPlay(ac, bLoop, true);
                        }
                    };
                }
            };
        }
        else
        {
            Resources.LoadAsync <AudioClip>("Sounds/" + str).completed += (a) => {
                AudioClip ac = ((ResourceRequest)a).asset as AudioClip;
                if (ac != null)
                {
                    AsyncPlay(ac, bLoop, true);
                }
            };
        }
#endif
    }
Ejemplo n.º 2
0
    void Start()
    {
        SetResultText();

        sound = SoundBehaviour.FindInstance();
        sound.PlayBGM(menuBGM);
    }
Ejemplo n.º 3
0
    public static void Stop()
    {
        //if (Config.a.IsSoundDebug)
        Debug.Log("StopAll ");
        SourceController(t => {
            t.Stop();
        });

        bgMusic = null;
    }
Ejemplo n.º 4
0
 public static void StopBg()
 {
     //if(Config.a.IsSoundDebug)
     Debug.Log("Stop Bg ");
     if (bgMusic)
     {
         bgMusic.Stop();
         bgMusic = null;
     }
 }
Ejemplo n.º 5
0
    void Start()
    {
        lastMenuIndex = LastMenuIndexBehaviour.FindInstance();

        menus = new MenuBehaviour[] { startMenu, resultsMenu, quitMenu };
        menuI = lastMenuIndex.GetIndex();
        UpdateMenu();

        sound = SoundBehaviour.FindInstance();
        sound.PlayBGM(menuBGM);
    }
Ejemplo n.º 6
0
 public static void PlayBg(AudioSource audioSource, bool bLoop = true)
 {
     if (bgMusic == null)
     {
         bgMusic           = soundObject.AddComponent <SoundBehaviour>();
         bgMusic.IsBgSound = true;
     }
     bgMusic.SetSound(
         audioSource,
         bLoop,
         Pitch,
         Sound.IsMute);
     bgMusic.Volume = 1f;
 }
Ejemplo n.º 7
0
    void Start()
    {
        screenMinPos = Camera.main.ScreenToWorldPoint(Vector3.zero);
        screenMaxPos = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, Screen.height, 0.0f));

        gameStatus     = GAME_STATUS_STARTED;
        life           = initialLife;
        lifeText.text  = life.ToString();
        score          = 0;
        scoreText.text = score.ToString();

        InvokeRepeating("SpawnNil2", introSec + spawnClockSec, spawnClockSec);
        InvokeRepeating("AccerateSpawnClock", introSec + accerateSpawnClockClockSec, accerateSpawnClockClockSec);

        sound = SoundBehaviour.FindInstance();
        sound.PlayBGMWithRestart(gameBGM);
    }
Ejemplo n.º 8
0
    static void AsyncPlay(AudioClip clip, bool bLoop, bool bBg = false)
    {
        SoundBehaviour sb;

        if (bBg)
        {
            if (bgMusic == null)
            {
                bgMusic = soundObject.AddComponent <SoundBehaviour>();
            }
            bgMusic.IsBgSound = true;
            sb = bgMusic;
        }
        else
        {
            sb = soundObject.AddComponent <SoundBehaviour>();
        }
        sb.SetSound(clip, bLoop, Pitch, Sound.IsMute);
    }
Ejemplo n.º 9
0
 public void ChangeSound(SoundBehaviour newSound)
 {
     Sound      = newSound;
     Sound.Name = this.Name;
 }
Ejemplo n.º 10
0
 public Dog(Dog d)
 {
     Name  = d.Name;
     sound = d.Sound;
     Age   = d.Age;
 }
Ejemplo n.º 11
0
 public Dog(string name, uint age)
 {
     Age   = age;
     Name  = name;
     Sound = new Bark(name, 5);
 }