PlayMusic() public method

public PlayMusic ( ) : void
return void
Exemplo n.º 1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         musicPlayer.PlayMusic(musicIndex_Enter);
     }
 }
Exemplo n.º 2
0
    public override void HandleSceneChange()
    {
//		while(CurrentScene < 67) {
//			nextScene();
//		}

        if (CurrentScene == 9 ||
            CurrentScene == 18 ||
            CurrentScene == 22 ||
            CurrentScene == 26)
        {
            ScreenFlash.FlashScreen();
            Flashback.renderer.enabled = true;
            Flashback.GetComponent <SpriteRenderer>().sprite = flashbackBGs.Dequeue();
            playSound(FlashbackSound);
            startTimer();
        }

        if (CurrentScene == 9)
        {
            mus.PlayMusic(EvilMusic, true);
        }

        if (CurrentScene == 69)
        {
            mus.PlayMusic(FinalBossMusic, true);
            Background.GetComponent <SpriteFlicker>().enabled = false;
            ((SpriteRenderer)Background.renderer).color       = Color.white;
            Background2.renderer.enabled = false;
            startTimer();
        }
    }
    //checks score and sets level accordingly
    private void Level()
    {
        if (score < 25 && !startGame)
        {
            level = 0;
            musicPlayer.PlayMusic();
        }

        if (score < 25 && startGame)
        {
            level = 1;
            musicPlayer.PlayMusic();
        }

        if (score >= 25 && score < 60)
        {
            level = 2;
            musicPlayer.PlayMusic();
        }

        if (score >= 60)
        {
            level = 3;
            musicPlayer.PlayMusic();
        }
    }
Exemplo n.º 4
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            Background = new SolidColorBrush(Colors.Black);

            _wakeUpDetector = new WakeUpDetector();
            _wakeUpDetector.WakeUpConfirmedEvent += WakeUpDetectorOnWakeUpConfirmedEvent;
            _wakeUpDetector.WakeUpProgressEvent  += WakeUpDetectorOnWakeUpProgressEvent;

            _musicPlayer = new MusicPlayer();

            var request = new ForecastIORequest("1151936ce22897f529d08c57a1e8bb71", 40.579219f, -111.999608f, Unit.us);

            _forecast = request.Get();

            StartClock();

            if (_wakeUpDetector.StartDetection())
            {
                Background = new SolidColorBrush(Colors.Black);

                //Begin playing alarm clock sound on loop
                _musicPlayer.InitAudioAsset("AlarmClock.wav", true);
                _musicPlayer.PlayMusic();
            }
            else //Could not load Kinect Sensor. Just skip it.
            {
                _wakeUpDetector.Dispose();
                DoWakeupRoutine();
            }
        }
Exemplo n.º 5
0
 public override void HandleSceneChange()
 {
     if (CurrentScene == 6)
     {
         Daria.rigidbody2D.AddForce(Vector2.right * -500);
     }
     else if (CurrentScene == 11)
     {
         LMFB.rigidbody2D.AddForce(new Vector2(1.0f, 0.5f) * 200);
         bc.StartBattle();
         mus.PlayMusic(DariasTheme, true);
     }
     else if (CurrentScene == 15)
     {
         bc.ResumeBattle();
     }
     else if (CurrentScene == 17)
     {
         LMFB.rigidbody2D.AddForce(new Vector2(1.0f, 0.5f) * -150);
         nextScene();
     }
     else if (CurrentScene == 20)
     {
         Daria.rigidbody2D.AddForce(Vector2.right * 500);
     }
     else if (CurrentScene == 25)
     {
         FadeAndNext(Color.white, 1.0f, "6-07 Fiddling contest", false);
     }
 }
Exemplo n.º 6
0
        private void OnInitialized(bool success)
        {
            if (!success)
            {
                return;
            }

            // Hide loading image
            _LoadingImage.SetActive(false);

            // Open the main menu
            MainMenuPopup.Create().Show();

            // Play menu music
            MusicPlayer.PlayMusic("Plymth22");

            // TEST: Animations
            animations = new OP2Animation_UGUI[2079];
            for (int i = 0; i < 2079; ++i)
            {
                OP2Animation_UGUI animation = OP2Animation_UGUI.Create(AssetManager.GetAnimation(i));
                animation.gameObject.SetActive(false);
                animation.transform.SetParent(GameObject.Find("CanvasBackground").transform);
                animation.transform.localScale = Vector3.one;
                animation.GetComponent <RectTransform>().anchoredPosition = Vector3.zero;

                animations[i] = animation;
            }
        }
Exemplo n.º 7
0
 public override void HandleSceneChange()
 {
     if (CurrentScene == 3)
     {
         ChefTony.GetComponent <PlayerFreeze>().UnFreeze();
     }
     else if (CurrentScene == 5)
     {
         James.transform.position      = new Vector3(8.3f, 0, 0);
         James.rigidbody2D.isKinematic = false;
         James.GetComponent <JamesGasBehavior>().EnableFlightMode();
         James.rigidbody2D.AddForce(Vector2.right * 250.0f);
     }
     else if (CurrentScene == 4)
     {
         mus.StopMusic(3.0f);
     }
     else if (CurrentScene == 9)
     {
         mus.PlayMusic(EvilEmergesTheme, false);
         GetComponent <CutsceneController>().textSpeed = 15;
         startTimer();
     }
     else if (CurrentScene == 10)
     {
         startTimer();
     }
 }
Exemplo n.º 8
0
 /**
  * Game state that is triggered if the user's answer was incorrect. Prompts the user to play again or quit.
  */
 void gameOver()
 {
     Debug.Log("Game over");
     MusicPlayer.PlayMusic(MusicTrack.GameOverJingle);
     playable = false;
     GameOverPanel.SetActive(true);
 }
Exemplo n.º 9
0
    //private void replaySystem()     //Not using
    //{
    //    if (currentLevel == 0)
    //    {
    //        spots = 5;
    //        FindingTimer.timeLeft = 40;
    //        Debug.Log("Spots = " + spots);
    //    }

    //    isLose = false;
    //    isWin = false;
    //    playable = true;

    //    FindingTimer.StartGame();       //Restart timer.
    //    ClickMistake.StartClicks();     ////Zero mistake clicks.
    //}

    //Actions when losing level, called in Update()
    public void losingGame()
    {
        Debug.Log("Game over");
        MusicPlayer.PlayMusic(MusicTrack.GameOverJingle);
        playable = false;
        losingPanel.SetActive(true);
    }
Exemplo n.º 10
0
 private void Awake()
 {
     GetComponent <Behavior>().OnGainTarget.AddListener(() =>
     {
         MusicPlayer.PlayMusic(Music);
     });
 }
Exemplo n.º 11
0
    private void playMusic()
    {
        switch (currentScene)
        {
        case "RocketGame":
            MusicPlayer.PlayMusic(MusicTrack.WinterForestMarathonCutscene);
            break;

        case "WordQuiz":
            MusicPlayer.PlayMusic(MusicTrack.MysticCardsCutscene);
            break;

        case "DifferenceGame":
            MusicPlayer.PlayMusic(MusicTrack.BubbleWarehouseCutscene);
            break;

        default:
            Debug.Log("Scene doesn't exist");
            break;
        }
        if (sceneProgression == "EndScene" && cutScenesWatched < 3)
        {
            MusicPlayer.PlayMusic(MusicTrack.EndingCutscene);
        }
    }
Exemplo n.º 12
0
    public override void HandleSceneChange()
    {
        if (CurrentScene == 4)
        {
            Daria.rigidbody2D.AddForce(Vector2.right * -600);
            mus.PlayMusic(DariasTheme, true);
        }
        else if (CurrentScene == 18)
        {
            foreach (Rigidbody2D ball in balls)
            {
                ball.AddForce(Vector2.right * -200);
            }

            startTimer();
        }
        else if (CurrentScene == 30)
        {
            foreach (Rigidbody2D ball in balls)
            {
                ball.AddForce(new Vector2(-100, -20));
            }

            startTimer();
        }
    }
Exemplo n.º 13
0
 private void Update()
 {
     if (!flag)
     {
         MusicPlayer.PlayMusic(MusicEnum.Menu);
         flag = true;
     }
 }
Exemplo n.º 14
0
 void Start()
 {
     gameMusic = GetComponent <MusicPlayer>();
     //Starts playing the game music
     gameMusic.PlayMusic();
     time = KeyDirectory.Timer.getNewTimer();
     DontDestroyOnLoad(gameObject);
 }
Exemplo n.º 15
0
    // Use this for initialization
    void Start()
    {
        MusicPlayer music = GameObject.Find("Music").GetComponent <MusicPlayer>();

        if (music.CurrentMusic() == "None" || music.CurrentMusic() != "Main")
        {
            music.PlayMusic("Main");                                                            ////Plays main menu screen music
        }
    }
Exemplo n.º 16
0
    public void PlayMusic(AudioClip musicClip)
    {
        if (musicClip == null)
        {
            return;
        }

        _musicPlayer.PlayMusic(musicClip);
    }
Exemplo n.º 17
0
    public void StartGame()
    {
        GameObject       player  = SpawnPrefab(playerPrefab);
        PlayerController playerS = player.GetComponent <PlayerController>();

        playerS.ChangeGun(defaultGunPrefab);
        cameraC.target = player.transform;
        ui.SetActivePlayerHealthBar(true);
        ui.UpdateBar(playerS.health, playerS.maxHealth);
        music.PlayMusic(MusicToPlay.Main);

        SpawnPrefab(slimePrefab);
        SpawnPrefab(slimePrefab);

        SpawnPrefab(boxPrefab);

        isInMenu = false;
    }
Exemplo n.º 18
0
    static public void Play(int id, bool immediatelyPlay)
    {
        if (currentMusicData != null && currentMusicData.Id == id)
        {
            return;
        }
        currentMusicData = FindMusic(id);
        if (currentMusicData == null)
        {
            return;
        }
        if (musicPlayer == null)
        {
            return;
        }
        if (musicPlayer.audioSource == null)
        {
            return;
        }
        AudioClip sound = null;

        if (currentMusicData.sound != null)
        {
            sound = currentMusicData.sound;
        }
        else
        {
            sound = UniGameResources.currentUniGameResources.LoadResource_AudioClip(currentMusicData.resourceName);
        }
        if (sound == null)
        {
            return;
        }
        musicPlayer.audioSource.Stop();
        musicPlayer.audioSource.clip = sound;
        if (workMode == MusicPlayerWorkMode.Mode_Standby)
        {
            musicPlayer.audioSource.volume = currentMusicData.volume * UniGameOptionsDefine.StandByMusicVolume;
        }
        else
        {
            musicPlayer.audioSource.volume = currentMusicData.volume;
        }
        //标记是否在下载一个资源loading的时候不卸载
        musicPlayer.IsCurrentAudioUnLoad = currentMusicData.isunload;
        if (immediatelyPlay)
        {
            musicPlayer.audioSource.Play();
        }
        else
        {
            musicPlayer.PlayMusic();
        }
    }
Exemplo n.º 19
0
 /// <summary>
 /// 音乐开关
 /// </summary>
 /// <param name="IsNo"></param>
 public void MusicController(bool IsOn)
 {
     if (IsOn)
     {
         MPlayer.PauseMusic();
     }
     else
     {
         MPlayer.PlayMusic();
     }
 }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            var player = new MusicPlayer();

            player.PlayMusic();

            //Console.WriteLine($"Hello World!");



            //Console.WriteLine($"This is my 2nd note: {myOtherNote.Name}, freq: {myOtherNote.Pitch}");
        }
Exemplo n.º 21
0
 public override void HandleSceneChange()
 {
     if (CurrentScene == 14)
     {
         mp.PlayMusic(evilMusic, false);
     }
     else if (CurrentScene == 28)
     {
         playSound(hangupSound);
         FadeAndNext(Color.black, 2, "2-04 France 2", true);
     }
 }
Exemplo n.º 22
0
        private void DoWakeupRoutine()
        {
            ProgressBar.BeginAnimation(OpacityProperty, new DoubleAnimation(1.0, 0, TimeSpan.FromSeconds(2)));
            //Fade out progress bar

            _musicPlayer.InitAudioAsset("Intro.wav", false); //Init intro music.
            _musicPlayer.PlayMusic();                        //Play

            LoadBackgroundImages();

            LoadWeatherTiles();
        }
Exemplo n.º 23
0
        private async void LoadWeatherTiles()
        {
            const int numTiles = 7;
            var       division = Math.Floor(this.ActualWidth / numTiles);

            var tileWidth = Math.Floor(division * 0.8);
            var margin    = Math.Floor(division * 0.1);

            var beepPlayer = new MusicPlayer();

            beepPlayer.InitAudioAsset("Beep.wav", false);

            await Task.Delay(TimeSpan.FromMilliseconds(2000));

            var counter = 0;

            var timer = new DispatcherTimer(DispatcherPriority.Render)
            {
                Interval = TimeSpan.FromMilliseconds(300)
            };

            timer.Tick += (sender, args) =>
            {
                if (counter >= numTiles)
                {
                    beepPlayer.Dispose();
                    timer.Stop();
                    Speak();
                }
                else
                {
                    beepPlayer.PlayMusic();

                    var rect = new Rectangle
                    {
                        Width   = tileWidth,
                        Height  = 200,
                        Fill    = new SolidColorBrush(Colors.White),
                        Opacity = 0.0
                    };

                    rect.BeginAnimation(OpacityProperty, new DoubleAnimation(0, 0.6, TimeSpan.FromSeconds(0.8)));

                    MainCanvas.Children.Add(rect);
                    Canvas.SetBottom(rect, margin);
                    Canvas.SetLeft(rect, ((margin + tileWidth + margin) * counter) + margin);
                }

                counter++;
            };
            timer.Start();
        }
Exemplo n.º 24
0
 /**
  * Called after level restart or after beating a level
  * Resets every game state variable to their default value
  */
 private void resetGameState()
 {
     if (currentLevel == 0)
     {
         currentLevel = system.getStartingLevel() - 1;
     }
     fails    = 0;
     corrects = 0;
     tries    = 0;
     isLose   = false;
     isWin    = false;
     playable = true;
     MusicPlayer.PlayMusic(MusicTrack.BubbleWarehouse);
 }
Exemplo n.º 25
0
    // Update is called once per frame
    public void FixedUpdate()
    {
        if (CurrentScene == 32)
        {
            if (elapsedTime > RiftExpansionDelay)
            {
                float animTime = elapsedTime - RiftExpansionDelay;

                if (animTime < RiftExpansionDuration)
                {
                    riftParticles.startLifetime =
                        Mathf.Lerp(InitRiftIntensity, FinalRiftIntensity, animTime / RiftExpansionDuration);
                }
            }

            if (timerIsGreaterThan(5.0f))
            {
                FadeAndNext(Color.white, 10, "6-10a Limbo", false);
                mus.PlayMusic(EpilogMusic, false);
                nextScene();
            }
        }
    }
Exemplo n.º 26
0
    public override void HandleSceneChange()
    {
        if (CurrentScene == 6)
        {
            //basketball interjection
            mus.PlayMusic(LikeMikeMusic, false);

            flyingBasketball.rigidbody2D.AddForce(new Vector2(-150, -10));
        }
        else if (CurrentScene == 19)
        {
            mus.PlayMusic(EvilMusic, false);
        }
        else if (CurrentScene == 25)
        {
            startTimer();
            mus.StopMusic(2.0f);
            // next: fade the background to black like we did before
        }
        else if (CurrentScene == 26)
        {
            flyingBasketball.GetComponent <FBHoverBehavior> ().enabled = false;
        }
    }
Exemplo n.º 27
0
    // Start is called before the first frame update
    void Start()
    {
        if (Instance != null)
        {
            Instance.PlayMusic();

            Destroy(gameObject);
            return;
        }

        Instance = this;
        DontDestroyOnLoad(gameObject);

        Instance.PlayMusic();
    }
Exemplo n.º 28
0
    public static void InterruptMusic()
    {
        if (!AllowMusicInterruption)
        {
            return;
        }
        if (DontInterruptYet)
        {
            return;
        }                                 // the stuff after this is pretty expensive, so we avoid it being called a ton when there are a lot of noisemakers running.

        Instance.musicsource.Stop();
        Instance.StopAllCoroutines();
        Instance.StartCoroutine(Instance.PlayMusic());
    }
 // Initialize everything and start the game
 public void gameStart()
 {
     MusicPlayer.PlayMusic(MusicTrack.WinterForestMarathon);
     destroyObjects();
     player = Instantiate(playerPrefab, new Vector3(0, -340, 0), Quaternion.identity).GetComponent <RocketPlayerScript> ();
     player.transform.SetParent(MainCanvas, false);
     player.togglePlayable();
     isGameOver = false;
     playing    = false;
     loadLevel(system.getStartingLevel());
     randomizeBackgroundObjects();
     countdown.init();
     guaranteedFuelDrop = 0;
     updateFuel(1f);
 }
Exemplo n.º 30
0
    // Update is called once per frame
    void Update()
    {
        if (!flag)
        {
            MusicPlayer.PlayMusic(MusicEnum.GameplayNormal);
            GameTracker.StartTimer(gameTime);
            flag = true;
        }

        currentTime += Time.deltaTime * Time.timeScale;
        if (currentTime >= currentDelay)
        {
            spawnNewHero();
            ResetDalay();
        }
    }