Example #1
0
        private void Window_PreviewKeyDown(object sender, KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Key.Space:
                if (FlappyBird.Margin.Top < 370)
                {
                    AddHeight = 10;
                    if (pipeAnimationTimer == null)
                    {
                        InitializeGame();
                    }
                    if (pipeAnimationTimer.IsEnabled == true)
                    {
                        if (BackgroundSound.IsEnabled == true)
                        {
                            BackgroundSound.Stop();
                        }
                        BackgroundSound.Source = new Uri(@"Resources\Camera_Shutter.wav", UriKind.Relative);
                        BackgroundSound.Play();
                    }
                }
                break;

            case Key.N:
                new MainWindow().Show();
                this.Close();
                break;
            }
        }
Example #2
0
 public void PlayMusic(BackgroundSound song)
 {
     if (Options.Entries["Music"]) {
         switch(song)
         {
         case BackgroundSound.MenuSong:
             audio.clip = menuSound;
             audio.Play();
             break;
         case BackgroundSound.RandomSong:
             audio.clip = randomSound;
             audio.Play();
             break;
         case BackgroundSound.BlueSong:
             audio.clip = blueSound;
             audio.Play();
             break;
         case BackgroundSound.GreenSong:
             audio.clip = greenSound;
             audio.Play();
             break;
         case BackgroundSound.RedSong:
             audio.clip = redSound;
             audio.Play();
             break;
         case BackgroundSound.BossSong:
             audio.clip = bossSound;
             audio.Play();
             break;
         }
         audio.loop = true;
     }
 }
	/// <summary>
	/// Initializes a new instance of the <see cref="AudioController"/> class.
	/// </summary>
	/// <param name="background">Background.</param>
	/// <param name="sound">Sound.</param>
	/// <param name="soundEffectsMuted">If set to <c>true</c> sound effects muted.</param>
	/// <param name="backgroundSoundMuted">If set to <c>true</c> background sounds muted.</param>
	/// <param name="configSettings">Config settings.</param>
	public AudioController(BackgroundSound background, SoundEffects sound, bool soundEffectsMuted, bool backgroundSoundMuted, ConfigurableSettings configSettings)
	{
		configurableSettings = configSettings;
		backgroundSound = background;
		soundEffects = sound;
		SoundEffectsMuted = soundEffectsMuted;
		BackgroundSoundMuted = backgroundSoundMuted;
		if(!BackgroundSoundMuted) backgroundSound.PlayOnStart = true;
	}
 public void RemoveBGSound(BackgroundSound sound)
 {
     if (sound != null)
     {
         sound.Stop();
         sound.Destroy();
         CommonObjectPools.Despawn(sound);
         m_ListBGAudio.Remove(sound);
     }
 }
Example #5
0
 void DontDestryOnChooseScene()
 {
     instance = this;
     DontDestroyOnLoad(this);
     audioSource = this.GetComponent <AudioSource> ();
     if (!audioSource.isPlaying)
     {
         loadClip();
     }
 }
    private void Awake()
    {
        if (bgSoundInstance != null && bgSoundInstance != this)
        {
            Destroy(this.gameObject);
            return;
        }

        bgSoundInstance = this;
        DontDestroyOnLoad(this);
    }
Example #7
0
 void Start()
 {
     if (instance == null)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(this.gameObject);
     }
     DontDestroyOnLoad(instance); //ilk instance asla yok olmuyor
 }
 // Start is called before the first frame update
 void Start()
 {
     if (!instance)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(this.gameObject);  // her sahnede yeniden oluşturulmasın yoket
     }
     DontDestroyOnLoad(instance);   // dontDestroy ile sahne yüklendiğinde objelerin yokolmasını engelleyebilir.
 }
 // Start is called before the first frame update
 void Start()
 {
     if (!instance)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(this.gameObject);
     }
     DontDestroyOnLoad(this.gameObject);
 }
Example #10
0
 // Start is called before the first frame update
 void Start()
 {
     if (!instance)
     {
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(this.gameObject); //oluşan her sahnede yenisini oluşturmuyor
     }
     DontDestroyOnLoad(instance);
 }
Example #11
0
        public static Sound CreateSound(Game i_Game, eSoundType i_eSoundType)
        {
            SoundsManager m_soundManager = SpaceInvadersServices.GetSoundManager(i_Game);
            Sound         sound          = null;

            switch (i_eSoundType)
            {
            case eSoundType.BackgroundMusic:
                sound = new BackgroundSound(i_Game, k_BackgroundMusicAsset);
                break;

            case eSoundType.BarrierHit:
                sound = new SoundEffect(i_Game, k_BarrierHitAsset);
                break;

            case eSoundType.EnemyGunShot:
                sound = new SoundEffect(i_Game, k_EnemyGunShotAsset);
                break;

            case eSoundType.EnemyKill:
                sound = new SoundEffect(i_Game, k_EnemyKillAsset);
                break;

            case eSoundType.GameOver:
                sound = new SoundEffect(i_Game, k_GameOverAsset);
                break;

            case eSoundType.LevelWin:
                sound = new SoundEffect(i_Game, k_LevelWinAsset);
                break;

            case eSoundType.LifeDie:
                sound = new SoundEffect(i_Game, k_LifeDieAsset);
                break;

            case eSoundType.MenuMove:
                sound = new SoundEffect(i_Game, k_MenuMoveAsset);
                break;

            case eSoundType.MotherShipKill:
                sound = new SoundEffect(i_Game, k_MotherShipKillAsset);
                break;

            case eSoundType.SSGunShot:
                sound = new SoundEffect(i_Game, k_SSGunShotAsset);
                break;
            }

            m_soundManager.SetSoundByInstanceType(sound);
            m_soundManager.AddSound(sound);
            return(sound);
        }
Example #12
0
    // Start is called before the first frame update
    void Start()
    {
        if (!instance)  //muzik yoksa instance yi this(muzik objesi) yap
        {
            instance = this;
        }
        else if (instance != this) //muzik ilk nesne degilse farklı yeniden yaratılıyosa sil
        {
            Destroy(this.gameObject);
        }

        DontDestroyOnLoad(this.gameObject); //muzigi tekrar baslatma
    }
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
Example #14
0
 // Use this for initialization
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
         source   = GetComponent <AudioSource>();
     }
     else
     {
         Destroy(gameObject);
     }
     DontDestroyOnLoad(gameObject);
 }
Example #15
0
    private IEnumerator FadeDownBackgroundRoutine()
    {
        var t   = Time.time;
        var vol = BackgroundAudioSource.volume;

        while (BackgroundAudioSource.volume > 0)
        {
            BackgroundAudioSource.volume = vol * (1 - (Time.time - t) / fadeDownTime);

            yield return(new WaitForFixedUpdate());
        }
        BackgroundAudioSource.Stop();
        currentBackground = BackgroundSound.NoSound;
    }
Example #16
0
        private void Awake()
        {
            // Store the start rotation.
            m_StartRotation  = m_Rigidbody.rotation;
            speed            = 15;
            sitting          = false;
            originalPosition = transform.position;

            SoundManager = GameObject.Find("SoundManager");
            bgScript     = SoundManager.GetComponent <BackgroundSound> ();

            SystemObject = GameObject.Find("System");
            dbscript     = SystemObject.GetComponent <DatabaseScript>();
        }
Example #17
0
    private void Awake()
    {
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
            return;
        }
        else
        {
            instance = this;
        }

        DontDestroyOnLoad(this.gameObject);
        AudioSource.volume = MenuSlider.value;
    }
Example #18
0
    public static void SetBackgroundSound(BackgroundSound background, bool loop = false, float volume = 0.05f)
    {
        if (instance.currentBackground == background)
        {
            return;
        }

        instance.currentBackground = background;

        instance.BackgroundAudioSource.volume = volume;
        instance.BackgroundAudioSource.loop   = loop;

        instance.BackgroundAudioSource.clip = instance.backgroundSounds[background];

        instance.BackgroundAudioSource.Play();
    }
Example #19
0
    static BackgroundSound instance;        //static bir örnek oluşturduk;

    void Start()                            // Start is called before the first frame update
    {
        //eğer bu nesne yok ise, oluştur, this->bu clastan demek;
        if (!instance)
        {
            instance = this;
        }
        //eğer örnek bu klastan değilse = yani yeni üretilmişse yok et;
        //yani yeni ses dosyası üretilmeyecek aynı dosya üzerinden işler devam edecek;
        else if (instance != this)
        {
            Destroy(this.gameObject);
        }
        //bu method her sahne yenilendiğinde istemediğiniz objeleri yok etmenizi engeller;
        //mesela burada bu kodu kullanmadığımız takdirde player her düştüğünde müzik en baştan başlıyor
        //ve sıkıcı bir hal alıyor;
        DontDestroyOnLoad(instance);
    }
    /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~背景声音~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
    /**背景声音*/
    public BackgroundSound PlayBGSound(string fileName, bool loop)
    {
        if (m_IsCloseBGSound)
        {
            return(null);
        }
        if (string.IsNullOrEmpty(fileName))
        {
            return(null);
        }

        BackgroundSound sound = CommonObjectPools.Spawn <BackgroundSound>();

        sound.Setup(fileName, Vector3.zero, null, 0, 0, loop ? int.MaxValue : 1);
        sound.LoadResource();
        m_ListBGAudio.Add(sound);

        return(sound);
    }
Example #21
0
 private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (FlappyBird.Margin.Top < 370)
     {
         AddHeight = 10;
     }
     if (pipeAnimationTimer == null)
     {
         InitializeGame();
     }
     if (pipeAnimationTimer.IsEnabled == true)
     {
         if (BackgroundSound.IsEnabled == true)
         {
             BackgroundSound.Stop();
         }
         BackgroundSound.Source = new Uri(@"Resources\Camera_Shutter.wav", UriKind.Relative);
         BackgroundSound.Play();
     }
 }
Example #22
0
        public static void Init(ContentManager Content)
        {
            content = Content;

            Font = content.Load <SpriteFont>("Fonts/Font");

            Cell            = content.Load <Texture2D>("Sprites/CellBackground");
            GameOverScreen  = content.Load <Texture2D>("Sprites/Gameover");
            MenuButton      = content.Load <Texture2D>("Sprites/MenuButton");
            PlayButton      = content.Load <Texture2D>("Sprites/PlayButton");
            Destroyer       = content.Load <Texture2D>("Sprites/Destroyer");
            FieldBackground = content.Load <Texture2D>("Sprites/FieldBackground");

            BombSound  = content.Load <SoundEffect>("Sound/bomb");
            MatchSound = content.Load <SoundEffect>("Sound/match");
            ClickSound = content.Load <SoundEffect>("Sound/click");
            LineSound  = content.Load <SoundEffect>("Sound/bonusline");
            TickSound  = content.Load <SoundEffect>("Sound/tick");

            elementsDict.Add(ShapeType.Empty,
                             Enumerable.Repeat(content.Load <Texture2D>("Sprites/BlankCell"), 4).ToArray());

            var memberInfos = typeof(ShapeType).GetMembers(BindingFlags.Public | BindingFlags.Static);

            for (var i = 1; i < memberInfos.Length; i++)
            {
                var type = (ShapeType)Enum.Parse(typeof(ShapeType), memberInfos[i].Name);
                elementsDict.Add(type, buildTexturesByType(type));
            }

            BackgroundSound = content.Load <SoundEffect>("Sound/marimba");
            var backSong = BackgroundSound.CreateInstance();

            backSong.IsLooped = true;
            backSong.Play();
        }
Example #23
0
        void pipeAnimationTimer_Tick(object sender, EventArgs e)
        {
            var flappyBirdMargin = FlappyBird.Margin;

            if (AddHeight > 0)
            {
                AddHeight--;
                flappyBirdMargin.Top += 4;
            }
            else
            {
                flappyBirdMargin.Top -= 3;
            }

            if (flappyBirdMargin.Top <= 0)
            {
                Result.Content    = "Game Over!!" + "\n\nScore : " + score.ToString("000");
                Result.Visibility = System.Windows.Visibility.Visible;
                pipeAnimationTimer.Stop();
                if (BackgroundSound.IsEnabled == true)
                {
                    BackgroundSound.Stop();
                }
                BackgroundSound.Source = new Uri(@"Resources\hit.mp3", UriKind.Relative);
                BackgroundSound.Play();
            }

            FlappyBird.Margin = flappyBirdMargin;
            for (int i = 0; i < 3; i++)
            {
                var pipeMargin = pipe[i].Margin;
                pipeMargin.Left = (pipeMargin.Left + 2.5) % 525;

                pipe[i].Margin = pipeMargin;
                pipeMargin.Top = hole[i].Margin.Top;
                if (pipeMargin.Left == 0)
                {
                    pipe[i].Visibility = System.Windows.Visibility.Visible;
                    pipeMargin.Top     = randomHole.Next(70, 240);
                }

                if (score > 5)
                {
                    if (holeDown[i] == true)
                    {
                        if (pipeMargin.Top > 160)
                        {
                            pipeMargin.Top -= 1;
                        }
                        else
                        {
                            holeDown[i] = false;
                        }
                    }
                    else
                    {
                        if (pipeMargin.Top < 240)
                        {
                            pipeMargin.Top += 1;
                        }
                        else
                        {
                            holeDown[i] = true;
                        }
                    }
                }

                hole[i].Margin = pipeMargin;

                if (pipe[i].Visibility == System.Windows.Visibility.Visible)
                {
                    if (pipeMargin.Left < FlappyBird.Margin.Left + 30 && pipeMargin.Left + 55 > FlappyBird.Margin.Left && !(pipeMargin.Top <= FlappyBird.Margin.Top + 2 && pipeMargin.Top + 80 >= FlappyBird.Margin.Top + 30))
                    {
                        Result.Content    = "Game Over!!" + "\n\nScore : " + score.ToString("000");
                        Result.Visibility = System.Windows.Visibility.Visible;
                        pipeAnimationTimer.Stop();
                        if (BackgroundSound.IsEnabled == true)
                        {
                            BackgroundSound.Stop();
                        }
                        BackgroundSound.Source = new Uri(@"Resources\hit.mp3", UriKind.Relative);
                        BackgroundSound.Play();
                    }
                    else
                    {
                        if (pipeMargin.Left == 205)
                        {
                            Score.Content = "Score : " + (++score).ToString("000");
                        }
                    }
                }
            }
        }
Example #24
0
 protected override void Close()
 {
     BackgroundSound.Stop();
     Dispose(true);
     ScreenManager.Manager.Pop(this);
 }
Example #25
0
 private void Form1_Load(object sender, EventArgs e)
 {
     BackgroundSound.PlayLooping();
     Reset();
 }