Exemplo n.º 1
0
 async void receiver_PauseRequested(PlayToReceiver sender, object args)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
     {
         MusicSource.Pause();
         VideoSource.Pause();
         receiver.NotifyPaused();
     });
 }
Exemplo n.º 2
0
    public void PlayMusicTemporarly(AudioClip music, float atVolume)
    {
        //Don't interupt the music.
        MusicSource.Pause();
        TempSource.clip = music;

        //Enforce volume standards.
        if (!(0 >= atVolume && 1 <= atVolume))
        {
            Debug.LogWarning("Recieved volume is not within the acceptable volume ranges. Clamping it..", gameObject);
        }

        atVolume = Mathf.Clamp(atVolume, 0, 1);

        TempSource.volume = atVolume;
        TempSource.Play();
    }
Exemplo n.º 3
0
    void Update()
    {
        if (UIRestartSignal.activeSelf)
        {
            Restart();
        }
        if (UIIntroSignal.activeSelf)
        {
            playercontroller.forceRespawn();
            //playercontroller.setAble(false);
            return;
        }
        if (!start)
        {
            start = true;
            SetPostProcessing(postfxon);
            playercontroller.playBGMusic();
            playercontroller.setAble(true);
        }

        if (Input.GetKeyDown("f"))
        {
            if (!Screen.fullScreen)
            {
                Screen.SetResolution(Screen.resolutions[Screen.resolutions.Length - 1].width, Screen.resolutions[Screen.resolutions.Length - 1].height, true);
                Screen.fullScreen = true;
            }
            else
            {
                Screen.fullScreen = !Screen.fullScreen;
            }
        }
        if (Input.GetKeyDown("r") && !halt)
        {
            StartRestart();
        }

        if (endscreen)
        {
            if (Input.GetKeyDown("space") && !halt)
            {
                StartRestart();
            }
            if (Input.GetKeyDown("escape") && !halt)
            {
                ReturnToMenu();
            }
        }

        // SOUND
        music_volume         = MusicSlider.value;
        sfx_volume           = SfxSlider.value;
        MusicText.text       = "Music: " + (int)(music_volume * 100);
        SfxText.text         = "Sfx: " + (int)(sfx_volume * 100);
        bgmusic.audio.volume = bgmusic.realVolume * music_volume;

        if (!game)
        {
            // PAUSE MENU
            if (Input.GetKeyDown("escape"))
            {
                if (!paused)
                {
                    paused = !paused;
                    Pause_Menu.SetActive(true);
                    bgmusic.Pause();
                    Time.timeScale = 0;
                }
                else if (paused)
                {
                    if (Menu1.activeSelf)
                    {
                        paused = !paused;
                        Pause_Menu.SetActive(false);
                        Time.timeScale = 1;
                        bgmusic.Play();
                    }
                    else
                    {
                        Menu1.SetActive(true);
                        Menu2.SetActive(false);
                    }
                }
            }

            // UI TEXT
            deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;

            milli = (int)(time * 1000) % 1000;
            sec   = (int)(time);
            min   = (int)(sec / 60);

            milli -= (1000 * m);
            sec   -= (60 * s);

            if (milli == 1000)
            {
                m++;
            }
            ;
            if (sec == 60)
            {
                s++;
            }
            ;

            ManaCount.text    = "x" + mana_count;
            DiamondCount.text = "x" + diamond_count;
            Timer.text        = "Time: " + min + " : " + (sec < 10 ? "0" : "") + sec + " : " + (milli < 100 ? "0" : "") + (milli < 10 ? "0" : "") + milli;
            FPS.text          = Mathf.RoundToInt((1 / deltaTime)) + " FPS\n" + Time.timeScale + "x speed";

            ManaScore.text    = ManaCount.text;
            DiamondScore.text = DiamondCount.text;
            TimeScore.text    = min + " : " + (sec < 10 ? "0" : "") + sec + " : " + (milli < 100 ? "0" : "") + (milli < 10 ? "0" : "") + milli;

            time += Time.deltaTime;
        }

        /*if(!Input.GetMouseButton(0))
         * {
         *  if (prev_height != Screen.height && !Screen.fullScreen)
         *  {
         *      int remainder = Screen.height % 9;
         *      int newHeight = Screen.height - remainder;
         *
         *      Screen.SetResolution((int)(newHeight * aspectratio), newHeight, true);
         *      Screen.fullScreen = false;
         *
         *      prev_height = newHeight;
         *      prev_width = Screen.width;
         *  }
         *  else if (prev_width != Screen.width && !Screen.fullScreen)
         *  {
         *      int remainder = Screen.width % 16;
         *      int newWidth = Screen.width - remainder;
         *
         *      Screen.SetResolution(newWidth, (int)(newWidth * (1 / aspectratio)), true);
         *      Screen.fullScreen = false;
         *
         *      prev_height = Screen.height;
         *      prev_width = newWidth;
         *  }
         * }*/

        //Debug.Log(coin_count[0] + ", " + coin_count[1] + ", " + coin_count[2]);



        // PLAYROOM

        /*
         * if (Input.GetKeyDown("c"))
         * {
         *  playercontroller.Respawn();
         * }
         * if (Input.GetKeyDown("5"))
         * {
         *  playercontroller.setSpeed(0);
         *  playercontroller.playSpeedParticles(0);
         * }
         * if (Input.GetKeyDown("1"))
         * {
         *  playercontroller.setSpeed(1);
         *  playercontroller.playSpeedParticles(1);
         * }
         * if (Input.GetKeyDown("2"))
         * {
         *  playercontroller.setSpeed(2);
         *  playercontroller.playSpeedParticles(2);
         * }
         * if (Input.GetKeyDown("3"))
         * {
         *  playercontroller.setSpeed(3);
         *  playercontroller.playSpeedParticles(3);
         * }
         * if (Input.GetKeyDown("4"))
         * {
         *  playercontroller.setSpeed(4);
         *  playercontroller.playSpeedParticles(4);
         * }
         * if (Input.GetKeyDown("m"))
         * {
         *  playercontroller.setMini(!playercontroller.getMini());
         * }
         * if (Input.GetKeyDown("t"))
         * {
         *  if (Time.timeScale == 1.0f)
         *      Time.timeScale = .3f;
         *  else
         *      Time.timeScale = 1.0f;
         * }
         * if (Input.GetKey(KeyCode.Backspace))
         * {
         *  float h, s, v;
         *  Color.RGBToHSV(Background.color, out h, out s, out v);
         *
         *  Background.color = Color.HSVToRGB(h+.01f, s, v);
         * }
         * if (Input.GetKeyDown("e"))
         * {
         *  editorTrail.Clear();
         *  editorTrail.emitting = !editorTrail.emitting;
         * }
         * if (Input.GetKeyDown(KeyCode.Tab))
         * {
         *  bgmusic.Play();
         * }
         * //*/

        /*
         * if (shortcuts_enabled)
         * {
         *  if (Input.GetKeyDown("p"))
         *  {
         *      effects.SetActive(!effects.activeSelf);
         *      Debug.Log(main_camera_brain.ActiveVirtualCamera.VirtualCameraGameObject.GetComponent<CinemachineVolumeSettings>() == null);
         *      postfxon = !postfxon;
         *      if (postfxon && main_camera_brain.ActiveVirtualCamera.VirtualCameraGameObject.GetComponent<CinemachineVolumeSettings>() != null)
         *      {
         *          main_camera_brain.ActiveVirtualCamera.VirtualCameraGameObject.GetComponent<CinemachineVolumeSettings>().enabled = true;
         *      }
         *      else
         *      {
         *          main_camera_brain.ActiveVirtualCamera.VirtualCameraGameObject.GetComponent<CinemachineVolumeSettings>().enabled = false;
         *      }
         *  }
         *
         *  if (Input.GetKeyDown("l"))
         *  {
         *      globallight.SetActive(!globallight.activeSelf);
         *      playerlight.SetActive(!globallight.activeSelf);
         *  }
         *
         *  if (Input.GetKeyDown("t"))
         *  {
         *      if (Time.timeScale == 1.0f)
         *          Time.timeScale = .3f;
         *      else
         *          Time.timeScale = 1.0f;
         *  }
         * }
         *
         * if (Input.GetKeyDown("o"))
         * {
         *  if(DevTools.color == Color.clear)
         *  {
         *      DevTools.color = Color.white;
         *      shortcuts_enabled = true;
         *  }
         *  else
         *  {
         *      DevTools.color = Color.clear;
         *      shortcuts_enabled = false;
         *  }
         * }//*/

        /*
         * if(postfxon)
         * {
         *  //bool volume_enabled = main_camera_brain.ActiveVirtualCamera.VirtualCameraGameObject.GetComponent<CinemachineVolumeSettings>().enabled;
         *  main_camera_brain.ActiveVirtualCamera.VirtualCameraGameObject.GetComponent<CinemachineVolumeSettings>().enabled = true;
         * }
         * else
         * {
         *  main_camera_brain.ActiveVirtualCamera.VirtualCameraGameObject.GetComponent<CinemachineVolumeSettings>().enabled = false;
         * }*/

        prev_height = Screen.height;
        prev_width  = Screen.width;
    }
 public void PauseMusic()
 {
     MusicSource.Pause();
 }
Exemplo n.º 5
0
 private void PauseMusic_Click(object sender, RoutedEventArgs e)
 {
     MusicSource.Pause();
 }