Beispiel #1
0
 void Update()
 {
     if (Input.GetKeyDown(Keycode.Space))
     {
         MusicSource.Play();
     }
 }
Beispiel #2
0
        private void ShowSelectedPanel(int p)
        {
            switch (p)
            {
            case 1:
                VideoSource.Stop();
                MusicSource.Stop();

                MusicBox.Visibility    = Visibility.Collapsed;
                PhotoSource.Visibility = Visibility.Visible;
                VideoBox.Visibility    = Visibility.Collapsed;
                break;

            case 2:
                VideoSource.Stop();

                MusicBox.Visibility    = Visibility.Visible;
                PhotoSource.Visibility = Visibility.Collapsed;
                VideoBox.Visibility    = Visibility.Collapsed;

                MusicSource.Play();
                break;

            case 3:
                MusicSource.Stop();
                MusicBox.Visibility    = Visibility.Collapsed;
                PhotoSource.Visibility = Visibility.Collapsed;
                VideoBox.Visibility    = Visibility.Visible;

                VideoSource.Play();
                break;
            }
        }
Beispiel #3
0
 async void receiver_SourceChangeRequested(PlayToReceiver sender, SourceChangeRequestedEventArgs args)
 {
     if (args.Stream != null)
     {
         if (args.Stream.ContentType.Contains("image"))
         {
             await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
             {
                 BitmapImage bmp = new BitmapImage();
                 bmp.SetSource(args.Stream);
                 PhotoSource.Source = bmp;
                 ShowSelectedPanel(1);
             });
         }
         else if (args.Stream.ContentType.Contains("video"))
         {
             await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
             {
                 VideoSource.SetSource(args.Stream, args.Stream.ContentType);
                 ShowSelectedPanel(3);
             });
         }
         else if (args.Stream.ContentType.Contains("audio"))
         {
             await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
             {
                 MusicSource.SetSource(args.Stream, args.Stream.ContentType);
                 ShowSelectedPanel(2);
                 MusicSource.Play();
             });
         }
     }
 }
Beispiel #4
0
 async void receiver_PlayRequested(PlayToReceiver sender, object args)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.High, () =>
     {
         MusicSource.Play();
         VideoSource.Play();
         receiver.NotifyPlaying();
     });
 }
    /// <summary>
    /// Plays a music clip.
    /// </summary>
    /// <param name="music">The music to play.</param>
    /// <param name="volume">The relative volume to play the clip at.</param>
    /// <param name="replayIfSame">If true, will play the clip even if it's the same music is currently being played.</param>
    public void PlayMusic(AudioClip music, float volume = 1f, bool replayIfSame = false)
    {
        if (replayIfSame == false && MusicSource.clip == music && MusicSource.isPlaying == true)
        {
            return;
        }

        MusicSource.clip = music;
        //Multiply this volume by the global music volume to get a relative volume
        MusicSource.volume = volume * musicVolume;
        MusicSource.Play();
    }
Beispiel #6
0
    public void PlayMusic(AudioClip music, float atVolume)
    {
        if (MusicSource.isPlaying)
        {
            MusicSource.Stop();
        }

        //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);

        MusicSource.volume = atVolume;
        MusicSource.clip   = music;
        MusicSource.Play();
    }
Beispiel #7
0
    public static void PlaySFX(string TypeOfSound, Transform position)
    {
        AudioSource MusicSource;

        MusicSource = Instantiate(prefabAudioSource, position.position, Quaternion.identity);

        if (TypeOfSound == "Spawn")
        {
            MusicSource.clip = SoundVFX[0];
            MusicSource.Play();
        }
        if (TypeOfSound == "Shoot")
        {
            MusicSource.clip   = SoundVFX[1];
            MusicSource.volume = 0.1f;
            MusicSource.Play();
        }
        if (TypeOfSound == "Die")
        {
            MusicSource.clip = SoundVFX[2];
            MusicSource.Play();
        }
        if (TypeOfSound == "SpawnCry")
        {
            MusicSource.clip = SoundVFX[3];
            MusicSource.Play();
        }
        if (TypeOfSound == "Step")
        {
            MusicSource.clip = SoundVFX[4];
            MusicSource.Play();
        }
        if (TypeOfSound == "Despawn")
        {
            MusicSource.clip = SoundVFX[5];
            MusicSource.Play();
        }
        if (TypeOfSound == "Item")
        {
            MusicSource.clip = SoundVFX[6];
            MusicSource.Play();
        }
    }
Beispiel #8
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;
    }
Beispiel #9
0
 public void PlayMenuMusic()
 {
     LevelMusicSource.Stop();
     MusicSource.Play();
     status = true;
 }
Beispiel #10
0
 private void PlayMusic_Click(object sender, RoutedEventArgs e)
 {
     MusicSource.Play();
 }