示例#1
0
 /// <summary>
 /// Play a pre-loaded sound
 /// </summary>
 /// <param name="sound"></param>
 public void PlaySound(UISound sound)
 {
     if (sound != null)
     {
         Bass.BASS_ChannelPlay(sound.ThisChannel, false);
     }
 }
示例#2
0
        private IEnumerator PlaySound(UISound sound)
        {
            yield return(new WaitForSeconds(sound.Delay));

            MasterAudio.PlaySoundAndForget(sound.SoundGroupName);
            CompleteTask();
        }
示例#3
0
 public override bool OnClick(TouchEvent touch, UISound uiSound)
 {
     if (m_main.Check(m_alphabet))
     {
         RootTransform.Find("Button").gameObject.SetActive(false);
     }
     return(true);
 }
示例#4
0
        // Update is called once per frame
        private void Update()
        {
            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                string countdownText     = "";
                int    countdownFontSize = 60;

                countdown--;
                switch (countdown)
                {
                case 4:
                    countdownText     = "READY";
                    countdownFontSize = 80;
                    UISound.Play(countdown1);
                    break;

                case 3:
                    countdownText     = "STEADY";
                    countdownFontSize = 100;
                    UISound.Play(countdown1);
                    break;

                case 2:
                    countdownText     = "GET SET";
                    countdownFontSize = 120;
                    UISound.Play(countdown1);
                    break;

                case 1:
                    countdownText     = "GO FAST";
                    countdownFontSize = 160;
                    UISound.Play(countdown2);
                    if (OnCountdownFinished != null)
                    {
                        OnCountdownFinished(this, new System.EventArgs());
                    }
                    break;

                case 0:
                    Destroy(gameObject);
                    break;
                }

                countdownLabel.text = countdownText;
                targetFontSize      = countdownFontSize;

                timer = 1f;
                if (countdown == 1)
                {
                    timer = 2f;
                }
            }

            currentFontSize         = Mathf.Lerp(currentFontSize, targetFontSize, Time.deltaTime * 10);
            countdownLabel.fontSize = (int)currentFontSize;
        }
示例#5
0
 public static void Play(AudioClip clip, float volume = 1f)
 {
     if (Object.op_Equality((Object)clip, (Object)null))
     {
         return;
     }
     UISound.GetAudioSource().set_volume((float)((double)volume * (double)Audio.master * 0.400000005960464));
     UISound.GetAudioSource().PlayOneShot(clip);
 }
示例#6
0
 public static void Play(AudioClip clip, float volume = 1f)
 {
     if (clip == null)
     {
         return;
     }
     UISound.GetAudioSource().volume = volume * Audio.master * 0.4f;
     UISound.GetAudioSource().PlayOneShot(clip);
 }
示例#7
0
        private void TargetPlayer_Respawned(object sender, EventArgs e)
        {
            UISound.Play(respawnSound);

            checkpointTimeField.text = "Respawn lap time penalty";
            checkpointTimeField.GetComponent <ToggleCanvasGroup>().ShowTemporarily(2f);

            checkpointTimeDiffField.color = Color.red;
            checkpointTimeDiffField.text  = "+" + Utils.GetTimeString(TimeSpan.FromSeconds(5));
            checkpointTimeDiffField.GetComponent <ToggleCanvasGroup>().ShowTemporarily(2f);
        }
示例#8
0
 public override bool OnClick(TouchEvent touch, UISound uiSound)
 {
     switch (touch.Listener.name)
     {
     case "HowToPlay": {
         IsScheduleUpdate = false;
         UIController.Instance.AddFront(new UIMiniGameHowToPlay());
         return(true);
     }
     }
     return(false);
 }
 void Start()
 {
     if (instance == null)
     {
         instance = this;
         UiSoundPlayer.Instance.PlayMusic(musicSource, 2.0f);
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
    public void Play(UiClipNames name)
    {
        UISound sound = System.Array.Find(_sounds, s => s.ClipName == name);

        if (sound != null)
        {
            sound.AudioSource.Play();
        }
        else
        {
            Debug.LogError("Wrong name of the clip - " + name);
        }
    }
示例#11
0
    public override bool OnClick(TouchEvent touch, UISound uiSound)
    {
        switch (touch.Listener.name)
        {
        case "HowToPlay": {
            UIController.Instance.AddFront(new UIMiniGameHowToPlay());
            return(true);
        }

        case "Panel": {
            UIController.Instance.Replace(new UIBase[] { new UIMiniGameMain() });
            return(true);
        }
        }
        return(false);
    }
示例#12
0
    public override bool OnClick(TouchEvent touch, UISound uiSound)
    {
        switch (touch.Listener.name)
        {
        case "Title": {
            UIController.Instance.Replace(new UIBase[] { new UIMiniGameTitle() }, new EnumUIGroup[] { EnumUIGroup.Dialog });
            return(true);
        }

        case "Retry": {
            UIController.Instance.Dispatch("retry", null);
            UIController.Instance.Remove(this);
            return(true);
        }
        }
        return(false);
    }
示例#13
0
        private void TargetPlayer_NextCheckpointPassed(object sender, NextCheckpointPassArgs e)
        {
            UISound.Play(checkpointSound);
            checkpointTimeField.text = Utils.GetTimeString(e.CurrentLapTime);
            checkpointTimeField.GetComponent <ToggleCanvasGroup>().ShowTemporarily(2f);

            if (TargetPlayer.LapRecordsEnabled)
            {
                CharacterTier tier      = ActiveData.Characters[targetPlayer.Character].tier;
                string        sceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name;
                int           stage     = ActiveData.Stages.Where(a => a.sceneName == sceneName).First().id;

                float time = (float)e.CurrentLapTime.TotalSeconds;

                RaceRecord bestRecord = ActiveData.RaceRecords
                                        .Where(a => a.Tier == tier && a.Stage == stage && a.GameVersion == GameVersion.AS_FLOAT && a.WasTesting == GameVersion.IS_TESTING)
                                        .OrderBy(a => a.Time)
                                        .FirstOrDefault();

                if (bestRecord != null)
                {
                    float diff = time - bestRecord.CheckpointTimes[e.IndexOfPreviousCheckpoint];

                    bool     faster   = diff < 0;
                    TimeSpan diffSpan = TimeSpan.FromSeconds(Mathf.Abs(diff));

                    checkpointTimeDiffField.text  = (faster ? "-" : "+") + Utils.GetTimeString(diffSpan);
                    checkpointTimeDiffField.color = faster ? Color.blue : Color.red;
                    checkpointTimeDiffField.GetComponent <ToggleCanvasGroup>().ShowTemporarily(2f);

                    if (e.IndexOfPreviousCheckpoint == StageReferences.Active.checkpoints.Length - 1 && faster)
                    {
                        checkpointTimeDiffField.text = "New lap record!";
                    }
                }
                else
                {
                    if (e.IndexOfPreviousCheckpoint == StageReferences.Active.checkpoints.Length - 1)
                    {
                        checkpointTimeDiffField.text  = "Lap record set!";
                        checkpointTimeDiffField.color = Color.blue;
                        checkpointTimeDiffField.GetComponent <ToggleCanvasGroup>().ShowTemporarily(2f);
                    }
                }
            }
        }
示例#14
0
    public void playSound2D(string theSoundName)
    {
        for (int i = 0; i < _allPlayableSound.Count; i++)
        {
            if (_allPlayableSound[i].name == theSoundName)
            {
                GameObject sound = new GameObject("UI Sound");
                sound.transform.position = Vector3.zero;
                UISound sp = sound.AddComponent <UISound>();
                sp.transform.parent = _soundsParent.transform;
                sp.Init();
                sp.Play(_allPlayableSound[i].clip, _allPlayableSound[i].loop);
                return;
            }
        }

        Debug.LogError("Could not find sound " + theSoundName + " to play it 2D");
    }
 public void UiSpeaker(UISound type)
 {
     if (type == UISound.Button)
     {
         center.PlayOneShot(uiSoundButtonDown, effectVolume);
     }
     if (type == UISound.Purchase)
     {
         center.PlayOneShot(uiSoundBuyPlane, effectVolume);
     }
     if (type == UISound.ChangePlane)
     {
         center.PlayOneShot(uiSoundChangePlane, effectVolume);
     }
     if (type == UISound.PurchaseFail)
     {
         center.PlayOneShot(uiSoundPurchaseFail, effectVolume);
     }
     if (type == UISound.OverHeat)
     {
         warningSpeaker.PlayOneShot(uiSoundOverHeat, effectVolume);
     }
 }
示例#16
0
    static void AddAudioSource(Button compomnt, AudioClip audioClip, StringBuilder sb)
    {
        var     imgGo   = compomnt.gameObject;
        Button  btn     = compomnt;
        UISound uiSound = imgGo.GetComponent <UISound>();

        if (uiSound == null)
        {
            uiSound = imgGo.AddComponent <UISound>();
            sb.AppendLine(compomnt.name);
        }
        uiSound.Clip = audioClip;
        AudioSource audio = imgGo.GetComponent <AudioSource>();

//         if (audio == null) {
//             audio = imgGo.AddComponent<AudioSource>();
//             sb.AppendLine(compomnt.name);
//         }

        if (audio.clip == null)
        {
            //audio.clip = audioClip;
            audio.playOnAwake = false;
        }
        else if (audio.playOnAwake)
        {
            audio.playOnAwake = false;
        }
//         UnityEngine.UI.Button.ButtonClickedEvent btClickEvent = btn.onClick;
//         int PersCount = btClickEvent.GetPersistentEventCount();
//         if (PersCount == 0) {
//             UnityEventTools.AddPersistentListener(btClickEvent);
//         }
//         UnityEventTools.RegisterPersistentListener(btClickEvent, 0, audio.Play);

        EditorUtility.SetDirty(imgGo);
    }
示例#17
0
    public void UIPlay(UISound sound, float p_volume = 1f)
    {
        AudioClip clip = collection.GetUISoud(sound.ToString());

        ui_audio_source.PlayOneShot(clip, p_volume * TotalVolume * UIVolume);
    }
示例#18
0
        private void Update()
        {
            timer -= Time.deltaTime;
            if (timer <= 0)
            {
                string countdownText     = "";
                int    countdownFontSize = 60;

                countdown--;
                switch (countdown)
                {
                case 4:
                    countdownText = "READY";
                    if (blue)
                    {
                        countdownText = "I'M";
                    }
                    countdownFontSize = 80;
                    UISound.Play(countdown1);
                    break;

                case 3:
                    countdownText = "STEADY";
                    if (blue)
                    {
                        countdownText = "BLUE";
                    }
                    countdownFontSize = 100;
                    UISound.Play(countdown1);
                    break;

                case 2:
                    countdownText = "GET SET";
                    if (blue)
                    {
                        countdownText = "DA BA DEE";
                    }
                    countdownFontSize = 120;
                    UISound.Play(countdown1);
                    break;

                case 1:
                    countdownText = "GO FAST";
                    if (blue)
                    {
                        countdownText = "DA BA DYE";
                    }
                    countdownFontSize = 160;
                    UISound.Play(countdown2);
                    if (OnCountdownFinished != null)
                    {
                        OnCountdownFinished(this, new System.EventArgs());
                    }
                    if (esport)
                    {
                        esport.StartTheShit();
                    }

                    else if (green)
                    {
                        green.StartTheShit();
                    }
                    else if (blue)
                    {
                        blue.StartTheShit();
                    }
                    else if (red)
                    {
                        red.StartTheShit();
                    }
                    break;

                case 0:
                    Destroy(gameObject);
                    break;
                }

                countdownLabel.text = countdownText;
                targetFontSize      = countdownFontSize;

                timer = 1f;
                if (countdown == 1)
                {
                    timer = 2f;
                }
            }

            currentFontSize         = Mathf.Lerp(currentFontSize, targetFontSize, Time.deltaTime * 10);
            countdownLabel.fontSize = (int)currentFontSize;
        }
示例#19
0
 private void btn_Blue_Click()
 {
     img_Colors.GetComponent <Image>().color = Color.blue;
     UISound.GetComponent <AudioSource>().PlayOneShot(Resources.Load <AudioClip>("Sounds/UI/Spacey Click_Minimal UI Sounds"));
 }
示例#20
0
 internal static void PlaySound(UISound guidePopup)
 {
     throw new NotImplementedException();
 }
示例#21
0
文件: UISound.cs 项目: GameWorthy/G1
	void Awake () {
		Instance = this;
	}