Esempio n. 1
0
    void OnNoUseClick(RepeatSection section)
    {
        Debug.Log("挡空了...");

        if (section.simpleClickAudioEffect != null)
        {
            audioSource.PlayOneShot(section.simpleClickAudioEffect);
        }
        player.GetComponent <Animator>().Play("HitFail");
    }
Esempio n. 2
0
    void OnMiss(RepeatSection section)
    {
        Debug.Log("然后被喷射物糊了一脸");

        if (section.missAudioEffect != null)
        {
            audioSource.PlayOneShot(section.missAudioEffect);
        }

        Destroy(throwable);
        player.GetComponent <Animator>().Play("Miss");
        ((RepeatSection)currentSection).miss = true;
    }
Esempio n. 3
0
    void CheckInput(RepeatSection section)
    {
        if (section.currentPlayBeat == null || section.nextHitIndex > section.playBeatList.Count)
        {
            return;
        }

        if (!section.currentPlayBeat.hasClicked && (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space)))
        {
            float offset = Mathf.Abs(audioSource.time - section.currentPlayBeat.time);

            if (offset < section.missRange)
            {
                Debug.Log(string.Format("按下时机准确度:【{0} of 1】", (audioSource.time - section.currentPlayBeat.time) / section.missRange));
                section.currentPlayBeat.hasClicked = true;
                if (offset <= section.hitRange || Input.GetKey(KeyCode.Z))
                {
                    OnHit(section.currentPlayBeat);
                }
                else
                {
                    OnNoUseClick(section);
                }
                return;
            }
            OnNoUseClick(section);
        }

        if (audioSource.time - section.currentPlayBeat.time > section.missRange)
        {
            if (!section.currentPlayBeat.hasHit)
            {
                OnMiss(section);
                //Debug.Log(string.Format("{0} {1} {2}", audioSource.time, section.currentPlayBeat.time, section.nextHitIndex));
            }

            if (section.nextHitIndex >= section.playBeatList.Count)
            {
                //Debug.Log("process to null");
                section.currentPlayBeat = null;
                section.nextHitIndex++;
                //Debug.Log(string.Format("{0} {1}", section.currentPlayBeat, section.currentPlayBeat == null));
            }
            else
            {
                //Debug.Log(string.Format("process to next beat {0}", section.nextHitIndex));
                section.currentPlayBeat = section.playBeatList[section.nextHitIndex++];
            }
        }
    }
Esempio n. 4
0
        private void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (_track.ChapterList.Count == 0)
            {
                return;
            }
            int     playerPosition = mbApiInterface.Player_GetPosition();
            Chapter currentChapter = _track.ChapterList.GetCurrentChapterFromPosition(playerPosition);

            if (!currentChapter.Equals(_currentChapter))
            {
                _mainForm?.Invoke(_mainForm.SetCurrentChapterDelegate, currentChapter);
                _currentChapter = currentChapter;
            }
            // Repeat section
            if (RepeatSection.RepeatCheck(playerPosition))
            {
                mbApiInterface.Player_SetPosition(RepeatSection.A.Position);
            }
        }
Esempio n. 5
0
    void Preview(RepeatSection section)
    {
        foreach (var beat in section.previewBeatList)
        {
            if (!string.IsNullOrEmpty(beat.animationState))
            {
                float animAdvancedTime = level.animationStateAdvanceTime[level.animationStateNames.IndexOf(beat.animationState)];
                TimersManager.SetTimer(this, beat.time - audioSource.time - animAdvancedTime, delegate
                {
                    enemyUpperAnimator.Play(beat.animationState);
                });
            }

            TimersManager.SetTimer(this, beat.time - audioSource.time, delegate
            {
                audioSource.PlayOneShot(beat.audioEffect);

                Destroy(throwable);
                if (beat.randomThrowable)
                {
                    throwable = Instantiate(level.throwablePrefabList[Random.Range(0, level.throwablePrefabList.Count)], throwableRoot.transform);
                }
                else
                {
                    throwable = Instantiate(beat.throwable, throwableRoot.transform);
                }
                Debug.Log("咳嗽");
            });
        }

        section.miss            = false;
        section.currentPlayBeat = section.playBeatList[0];
        section.nextHitIndex    = 1;
        foreach (var beat in section.playBeatList)
        {
            beat.hasClicked = false;
            beat.hasHit     = false;
        }
    }
Esempio n. 6
0
        // receive event notifications from MusicBee
        // you need to set about.ReceiveNotificationFlags = PlayerEvents to receive all notifications, and not just the startup event
        public void ReceiveNotification(string sourceFileUrl, NotificationType type)
        {
            // perform some action depending on the notification type
            switch (type)
            {
            case NotificationType.PluginStartup:
                // perform startup initialisation
                _manager = new Manager(mbApiInterface);
                _track   = GetTrack();
                _manager.UpdateTrack(_track);
                //_timer = new Timer(100);
                //_timer.Elapsed += _timer_Elapsed;
                switch (mbApiInterface.Player_GetPlayState())
                {
                case PlayState.Playing:
                    // _timer.Start();
                    _manager.StartTimer();
                    break;
                }
                //if (ChapterListMB.Properties.Settings.Default.StartWithMusicBee)
                //    OnMenuClicked(null, null);
                break;

            case NotificationType.TrackChanged:
                if (_mainForm == null && _mbPanel == null)
                {
                    return;
                }
                RepeatSection.Clear();
                _currentChapter = null;
                _track          = GetTrack();
                _manager.UpdateTrack(_track);
                _mainForm?.Invoke(_mainForm.UpdateTrackDelegate, _track);
                if (mbApiInterface.Player_GetPlayState() == PlayState.Playing)
                {
                    _manager.StartTimer();
                }
                break;

            case NotificationType.TrackChanging:
                //if (!_timer.Enabled) _timer.Stop();
                _manager.StopTimer();
                break;

            case NotificationType.PlayStateChanged:
                //if (_track == null) return;
                switch (mbApiInterface.Player_GetPlayState())
                {
                case PlayState.Playing:
                    //if (!_timer.Enabled) _timer.Start();
                    _manager.StartTimer();
                    break;

                case PlayState.Paused:
                    //if (_timer.Enabled) _timer.Stop();
                    _manager.StopTimer();
                    break;

                case PlayState.Stopped:
                    //if (_timer.Enabled) _timer.Stop();
                    _manager.StopTimer();
                    break;

                case PlayState.Undefined:
                    //if (_timer.Enabled) _timer.Stop();
                    _manager.StopTimer();
                    break;
                }
                break;
            }
        }