예제 #1
0
    public void TryHit(SongProfiler.PlayerNumber playerNumber)
    {
        /*
         * // Show the indicator for a bit
         * if (indicatorRoutine != null)
         * {
         *  StopCoroutine(indicatorRoutine);
         * }
         *
         * indicatorRoutine = HideIndicator();
         * StartCoroutine(indicatorRoutine);
         * GetComponent<SpriteRenderer>().enabled = true;
         */

        // Try and hit overlapping Notes
        List <Collider2D> overlappingColliders = new List <Collider2D>();

        GetComponent <Collider2D>().OverlapCollider(new ContactFilter2D(), overlappingColliders);

        bool found = false;

        foreach (Collider2D collider in overlappingColliders)
        {
            SockNote note = collider.gameObject.GetComponent <SockNote>();
            if (note != null && note.hittable)
            {
                note.Hit(playerNumber);
                found = true;
            }
        }
        if (!found)
        {
            _playerMovement.UpdateScore(-1);
        }
    }
예제 #2
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        SockNote note = other.GetComponent <SockNote>();

        if (note != null)
        {
            note.Miss();
        }
    }
예제 #3
0
    void Update()
    {
        if (songStarted)
        {
            float currentDspTime = (float)AudioSettings.dspTime;

            // Time to spawn a note!
            while (currentDspTime >= nextBeatSpawnTime && _noteI < _songProfiler.Song.Count)
            {
                GameObject noteObj           = Instantiate(notePrefab, new Vector2(_currNote.xPosition, spawnY), Quaternion.identity, spawn.transform);
                GameObject approachCircleObj = Instantiate(approachCirclePrefab,
                                                           new Vector2(_currNote.xPosition, (_currNote.position == SongProfiler.NotePosition.Jump) ? jumpY : targetY),
                                                           Quaternion.identity);

                GameObject xIndicatorObj = Instantiate(xIndicatorPrefab,
                                                       new Vector2(_currNote.xPosition, spawnY),
                                                       Quaternion.identity);


                SockNote note = noteObj.GetComponent <SockNote>();

                approachCircleObj.GetComponent <NoteEffectAnimator>().sockNote = note;
                note.effects.Add(approachCircleObj.GetComponent <NoteEffectAnimator>());
                xIndicatorObj.GetComponent <NoteEffectAnimator>().sockNote = note;
                note.effects.Add(xIndicatorObj.GetComponent <NoteEffectAnimator>());

                note.startDsp  = nextBeatSpawnTime;
                note.targetDsp = nextBeatSpawnTime + GetHitTime(_currNote);
                note.killDsp   = nextBeatSpawnTime + killTime;

                // Sets note owner and position

                // Get the next Sock you should spawn
                note.owner = _currNote.player;
                Sock sock = SockManager.Instance.PopRhythmQueue(note.owner);
                note.SetSock(sock, _currNote.player, _currNote.position);

                _noteI++;
                if (_noteI < _songProfiler.Song.Count)
                {
                    nextBeatSpawnTime = audioStartTime + _currNote.noteTime - GetHitTime(_currNote);
                }
                else
                {
                    // end song
                }
            }
            if (musicSource.clip.length < currentDspTime - audioStartTime)
            {
                EndSong();
            }
        }
    }