Esempio n. 1
0
        private void OnFirePressed(EFire firePressed)
        {
            if (this == null)
            {
                return;
            }

            if (firePressed.ToString().Equals(_singleNoteConfiguration.button))
            {
                _audioSource.PlayOneShot(_singleNoteConfiguration.Note);
                AnimateBump();
            }
        }
    private void OnPlayerFireAction(EFire firePressed)
    {
        if (_shouldMumble || _isFinished || this == null)
        {
            return;
        }

        _symbolsEntered++;
        var indexOfSymbol = -1;

        for (int i = _nextCorrectIndex; i < _noteConfiguration.Count; i++)
        {
            var currentDancingSymbol = _noteConfiguration[i];
            if (firePressed.ToString().Equals(currentDancingSymbol.button))
            {
                indexOfSymbol = i;
                break;
            }
        }

        if (indexOfSymbol == _nextCorrectIndex)
        {
            _nextCorrectIndex++;
        }
        else
        {
            _nextCorrectIndex = 0;
        }

        if (_symbolsEntered == _noteConfiguration.Count)
        {
            if ((indexOfSymbol >= _nextCorrectIndex - 1) && (_nextCorrectIndex == _noteConfiguration.Count))
            {
                _isFinished = true;
                AnimateGoodbye();
                return;
            }
            else
            {
                // Failure!
                _audioSource.Stop();
                Invoke("PlayFailure", 0.15f);
                _symbolsEntered   = 0;
                _nextCorrectIndex = 0;
                return;
            }
        }
    }
    private void OnPlayerFireAction(EFire firePressed)
    {
        if (this == null)
        {
            return;
        }

        var indexOfSymbol = -1;

        for (int i = 0; i < _singleNotes.Length; i++)
        {
            SingleNoteConfiguration singleNote = _singleNotes[i];
            if (firePressed.ToString().Equals(singleNote.button))
            {
                indexOfSymbol = i;
                break;
            }
        }

        if (indexOfSymbol < 0)
        {
            return;
        }

        _speakBubble.SetActive(true);
        var currentNote = _singleNotes[indexOfSymbol];

        if (_audioSource.isPlaying)
        {
            _audioSource.Stop();
        }
        _audioSource.PlayOneShot(currentNote.Note);
        _spriteRendererOfCurrentNote.sprite = currentNote.Sprite;

        if (_removeBubbleCoroutine != null)
        {
            StopCoroutine(_removeBubbleCoroutine);
        }
        _removeBubbleCoroutine = StartCoroutine(RemoveBubbleDelayed());
    }