Beispiel #1
0
 public void Pause()
 {
     ButtonClickSound.playSound();
     Pausemenu.SetActive(true);
     PauseButton.SetActive(false);
     Time.timeScale = 0;
 }
        private void AddButtonClickSound(GameObject candidate)
        {
            ButtonClickSound buttonClickSound = candidate.AddComponent <ButtonClickSound>();

            AssignClickSound(buttonClickSound);
            EditorUtility.SetDirty(candidate);
        }
 public void OnPointerClick(PointerEventData eventData)
 {
     if (buttonText != null)
     {
         buttonText.color = Color.gray;
     }
     ButtonClickSound.Play();
 }
        private void DrawButtonSettings(GameObject candidate)
        {
            GUILayout.BeginHorizontal();

            MarkSelectedCandidate(candidate);

            ButtonClickSound clickSound = candidate.GetComponent <ButtonClickSound>();

            if (clickSound == null)
            {
                GUILayout.Label("No any click sound!", EditorStyles.whiteLabel, GUILayout.Width(225));

                if (GUILayout.Button(new GUIContent("Add", "Add 'ButtonClickSound' component to button."), GUILayout.Width(50)))
                {
                    AddButtonClickSound(candidate);
                    SelectButton(candidate);
                }
            }
            else
            {
                clickSound.ClickSound = EditorGUILayout.ObjectField(clickSound.ClickSound, typeof(AudioClip), false, GUILayout.Width(200)) as AudioClip;
                if (GUILayout.Button(new GUIContent("X", "Remove 'ButtonClickSound' component from button."), GUILayout.Width(20)))
                {
                    DestroyImmediate(clickSound);
                    SelectButton(candidate);
                }

                bool hasErrors = clickSound.AudioSource == null || clickSound.ClickSound == null;
                if (hasErrors)
                {
                    if (GUILayout.Button("Fix", GUILayout.Width(50)))
                    {
                        if (clickSound.AudioSource == null)
                        {
                            clickSound.AudioSource = _audioSource;
                        }

                        if (clickSound.ClickSound == null)
                        {
                            clickSound.ClickSound = _clickSound;
                        }

                        EditorUtility.SetDirty(clickSound);
                    }
                }
                else
                {
                    if (GUILayout.Button(new GUIContent("Play", "Test assigned AudioClip."), GUILayout.Width(50)))
                    {
                        clickSound.AudioSource.PlayOneShot(clickSound.ClickSound);
                        SelectButton(candidate);
                    }
                }
            }

            GUILayout.EndHorizontal();
        }
 void Awake()
 {
     if (buttonClickSound == null)
     {
         DontDestroyOnLoad(gameObject);
         buttonClickSound = this;
     }
     else if (buttonClickSound != this)
     {
         Destroy(gameObject);
     }
 }
Beispiel #6
0
        public bool LeftClick(MouseState mouseState)
        {
            if (mouseState.LeftButton == ButtonState.Pressed)
            {
                ButtonClickSound.Play(0.5f);
                ButtonClickSound.Wait = true;
            }
            else if (mouseState.LeftButton == ButtonState.Released)
            {
                ButtonClickSound.Wait = false;
            }

            return(ButtonClickSound.Wait);
        }
        private void DrawBottomPanel()
        {
            GUILayout.BeginHorizontal("Box");

            DrawAuthorLink();

            GUILayout.Label("Version 1.2");

            GUILayout.FlexibleSpace();

            EditorGUI.BeginDisabledGroup(_clickSound == null);

            if (GUILayout.Button("Add click sound to ALL"))
            {
                foreach (GameObject candidate in All)
                {
                    ButtonClickSound buttonClickSound = candidate.GetComponent <ButtonClickSound>();
                    if (buttonClickSound == null)
                    {
                        AddButtonClickSound(candidate);
                    }
                    else
                    {
                        AssignClickSound(buttonClickSound);
                    }
                }
            }

            EditorGUI.EndDisabledGroup();

            if (GUILayout.Button("Clear ALL"))
            {
                foreach (GameObject candidate in All)
                {
                    ButtonClickSound buttonClickSound = candidate.GetComponent <ButtonClickSound>();
                    if (buttonClickSound != null)
                    {
                        DestroyImmediate(buttonClickSound);
                        EditorUtility.SetDirty(candidate);
                    }
                }
            }
            GUILayout.EndHorizontal();
        }
        private void DrawButtonSettingsNotificationLine(GameObject candidate)
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(135f);
            ButtonClickSound clickSound = candidate.GetComponent <ButtonClickSound>();

            if (clickSound != null)
            {
                if (clickSound.AudioSource == null)
                {
                    DrawTip("Audio Source is not assigned!");
                }
                else if (clickSound.ClickSound == null)
                {
                    DrawTip("Click Sound is not assigned!");
                }
            }
            GUILayout.EndHorizontal();
        }
        private List <GameObject> GetFilteredCandidates()
        {
            List <GameObject> candidates = _candidates[_candidatesTypeFilter];

            if (_selectedClickSoundFilter == AllClickSoundFilter)
            {
                return(candidates);
            }

            List <GameObject> filteredCandidates = new List <GameObject>();

            foreach (GameObject candidate in candidates)
            {
                ButtonClickSound clickSound       = candidate.GetComponent <ButtonClickSound>();
                bool             isNotAssigned    = (clickSound == null || clickSound.ClickSound == null) && _selectedClickSoundFilter == NotAssignedClickSoundFilter;
                bool             isSoundNameEqual = clickSound != null && clickSound.ClickSound != null && clickSound.ClickSound.name == _selectedClickSoundFilter;
                if (isNotAssigned || isSoundNameEqual)
                {
                    filteredCandidates.Add(candidate);
                }
            }
            return(filteredCandidates);
        }
Beispiel #10
0
 private void Btn_Options_Click(object sender, RoutedEventArgs e)
 {
     ButtonClickSound.Play();
     this.NavigationService.Navigate(new Option());
 }
Beispiel #11
0
 private void Btn_New_How_To_Play_Click(object sender, RoutedEventArgs e)
 {
     ButtonClickSound.Play();
     this.NavigationService.Navigate(new HowToPlay());
 }
Beispiel #12
0
 private void Ranking_Click(object sender, RoutedEventArgs e)
 {
     ButtonClickSound.Play();
     this.NavigationService.Navigate(new Ranking());
 }
Beispiel #13
0
 private void New_game_Click(object sender, RoutedEventArgs e)
 {
     ButtonClickSound.Play();
     this.NavigationService.Navigate(new NewGame());
 }
Beispiel #14
0
 private void Exit_Click(object sender, RoutedEventArgs e)
 {
     ButtonClickSound.Play();
     Application.Current.Shutdown();
 }
        private AudioClip GetFirstClickSound(ButtonClickSound[] clickSounds)
        {
            ButtonClickSound buttonClickSound = clickSounds.FirstOrDefault(_ => _.ClickSound != null);

            return(buttonClickSound == null ? null : buttonClickSound.ClickSound);
        }
        private AudioSource GetFirstAudioSource(ButtonClickSound[] clickSounds)
        {
            ButtonClickSound buttonClickSound = clickSounds.FirstOrDefault(_ => _.AudioSource != null);

            return(buttonClickSound == null ? null : buttonClickSound.AudioSource);
        }
Beispiel #17
0
 public void MainMenu()
 {
     ButtonClickSound.playSound();
     SceneManager.LoadScene("Menu");
     Time.timeScale = 1;
 }
 private void AssignClickSound(ButtonClickSound buttonClickSound)
 {
     buttonClickSound.AudioSource = _audioSource;
     buttonClickSound.ClickSound  = _clickSound;
     EditorUtility.SetDirty(buttonClickSound);
 }
Beispiel #19
0
 public void QuitGame()
 {
     ButtonClickSound.playSound();
     Application.Quit();
 }
Beispiel #20
0
 public void Restart()
 {
     ButtonClickSound.playSound();
     SceneManager.LoadScene("Game");
 }
Beispiel #21
0
 public void Play()
 {
     ButtonClickSound.playSound();
     SceneManager.LoadScene("Game");
     Time.timeScale = 1;
 }