Exemplo n.º 1
0
    public void ButtonPressed()
    {
        if (notes.Count == 0)
        {
            //todo failure
            Debug.Log("failure!");

            return;
        }

        int sampleDistance = Mathf.Abs(koreo.GetLatestSampleTime() - notes[0].evt.StartSample);

        if (sampleDistance <= RhythmGameManager.PERFECT_HIT_RANGE_IN_SAMPLES)
        {
            //todo success
            Debug.Log("correct!");

            //destroy node
            RhythmNote todelete = notes[0];
            notes.RemoveAt(0);
            GameObject.Destroy(todelete.circleObject);
            GameObject.Destroy(todelete.gameObect);
            Debug.Log("p" + todelete.percentage);
            audioSource.Play();
        }
        else
        {
            Debug.Log("failure!");
        }
    }
Exemplo n.º 2
0
 public RhythmGameNoteDeleteMsg(RhythmNote rhythmNote, int index, GameObject note, bool isRight, bool isNoTouch)
 {
     this.rhythmNote = rhythmNote;
     this.index      = index;
     this.note       = note;
     this.isRight    = isRight;
     this.isNoTouch  = isNoTouch;
 }
Exemplo n.º 3
0
    void UpdateNotePositions()
    {
        if (notes.Count == 0)
        {
            return;
        }

        int currentSample = koreo.GetLatestSampleTime();

        foreach (RhythmNote n in notes)
        {
            //starts at noteTravelSampleTime and goes to 0
            int distance = n.evt.StartSample - currentSample;

            //starts at zero
            float betterDistance = RhythmGameManager.noteTravelSampleTime - distance;
            //Debug.Log("b" + betterDistance);

            n.percentage = betterDistance / RhythmGameManager.noteTravelSampleTime;
            //Debug.Log("p" + n.percentage);

            Vector3 targetPosition = new Vector3(0, 0, 90f) + n.percentage * noteDirection;
            //TODO maybe slerp
            n.gameObect.transform.position = targetPosition;

            //update circle
            n.circle.openness = 1 - n.percentage;
            ///todo
            if (n.circle.openness <= 0.9 && n.circle.openness >= 0.5f)
            {
                n.circle.circleImage.enabled = true;
            }


            if (n.circle.openness < 0)
            {
                GameObject.Destroy(n.circleObject);
            }

            //TODO DEBUG HITSOUND

            if (n.percentage >= 0.97f)
            {
                if (!n.dirty)
                {
                    n.dirty = true;
                    audioSource.Play();
                }
            }
        }
        if (notes[0].percentage > missPercentage)
        {
            RhythmNote todelete = notes[0];
            notes.RemoveAt(0);
            GameObject.Destroy(todelete.circleObject);
            GameObject.Destroy(todelete.gameObect);
        }
    }
    IEnumerator MoveNote(Vector3 target)
    {
        note[0].SetActive(true);

        while (true)
        {
            yield return(null);

            //(1.8  0)
            float distance = Vector3.Distance(this.gameObject.transform.position, target);

            if (distance > 1.5)
            {
                note[0].SetActive(true);
                rhythmNote = RhythmNote.None;
            }
            else if (distance <= 1.5 & distance > 1.1)
            {
                note[0].SetActive(false);
                note[1].SetActive(true);
                rhythmNote = RhythmNote.Bad;
            }
            else if (distance <= 1.1 & distance > 0.8)
            {
                note[1].SetActive(false);
                note[2].SetActive(true);
                rhythmNote = RhythmNote.Normal;
            }
            else if (distance <= 0.8 & distance > 0.5)
            {
                note[1].SetActive(false);
                note[2].SetActive(true);
                rhythmNote = RhythmNote.Good;
            }
            else if (distance <= 0.5 & distance > 0.3)
            {
                note[2].SetActive(false);
                note[3].SetActive(true);
                rhythmNote = RhythmNote.Perfect;
            }
            else
            {
                if (!isTouch)
                {
                    note[2].SetActive(false);
                    note[3].SetActive(true);
                    rhythmNote = RhythmNote.Miss;
                    NoteDelete();
                }
            }

            this.gameObject.transform.position = Vector3.MoveTowards(this.gameObject.transform.position, target, 0.7f * Time.deltaTime);
        }
    }
Exemplo n.º 5
0
    public void MoveStart(Vector3 target, bool isRight, int index, int noteCount)
    {
        //this.gameObject.GetComponent<MeshRenderer>().material.color = Color.white;
        particle.gameObject.SetActive(false);
        rhythmNote     = RhythmNote.None;
        this.isRight   = isRight;
        this.index     = index;
        this.noteCount = noteCount;
        foreach (var o in note)
        {
            o.SetActive(false);
        }

        corMove = StartCoroutine(MoveNote(target));
    }
Exemplo n.º 6
0
 public void SetEffect(RhythmNote rhythmNote)
 {
     if (rhythmNote == RhythmNote.Perfect)
     {
         Judge[1].SetActive(true);
     }
     else if (rhythmNote == RhythmNote.Good)
     {
         Judge[0].SetActive(true);
     }
     else if (rhythmNote == RhythmNote.Bad)
     {
         Judge[2].SetActive(true);
     }
 }
Exemplo n.º 7
0
    public void AddNote(KoreographyEvent newNote)
    {
        RhythmNote n = new RhythmNote();

        n.evt        = newNote;
        n.gameObect  = (GameObject)Instantiate(notePrefab, new Vector3(0, 0, 90), Quaternion.identity);
        n.percentage = 0.0f;

        n.circleObject = (GameObject)Instantiate(circlePrefab, new Vector3(0, 0, 90f), Quaternion.identity);
        n.circle       = n.circleObject.GetComponent <HitCircle>();
        n.circleObject.transform.SetParent(UIPanel.transform);
        RectTransform rect = n.circleObject.GetComponent <RectTransform>();

        rect.position           = noteDirection;
        rect.localScale         = new Vector3(1, 1, 1);
        rect.anchorMin          = buttonTransform.anchorMin;
        rect.anchorMax          = buttonTransform.anchorMax;
        rect.anchoredPosition3D = Vector3.zero;
        //n.circleObject.transform.position = Vector3.zero;
        n.circle.openness = 1;
        notes.Add(n);
    }
Exemplo n.º 8
0
    void RhythmGameBtnTouch(RhythmGameBtnTouchMsg msg)
    {
        if (msg.isRight)
        {
            rightOver.SetActive(true);
            StartCoroutine(ButtonOverClose(rightOver));

            RhythmNote tempRhythmNote = RhythmNote.None;
            int        minValue       = -1;
            int        noteIndex      = 0;
            for (int i = 0; i < RightNote.Length; i++)
            {
                if (RightNote[i] != null)
                {
                    int tempNum = RightNote[i].GetComponent <RhythmGameNote_Controller>().noteCount;
                    if (minValue == -1)
                    {
                        noteIndex = i;
                        minValue  = tempNum;
                    }
                    else if (minValue > tempNum)
                    {
                        noteIndex = i;
                        minValue  = tempNum;
                    }
                }
            }
            if (RightNote[noteIndex] == null)
            {
                return;
            }

            tempRhythmNote = RightNote[noteIndex].GetComponent <RhythmGameNote_Controller>().rhythmNote;
            if (tempRhythmNote != RhythmNote.None && tempRhythmNote != RhythmNote.Miss)
            {
                RhythmGameNoteDelete(new RhythmGameNoteDeleteMsg(tempRhythmNote, noteIndex, RightNote[noteIndex], true, false));
            }
        }
        else
        {
            leftOver.SetActive(true);
            StartCoroutine(ButtonOverClose(leftOver));
            RhythmNote tempRhythmNote = RhythmNote.None;
            int        minValue       = -1;
            int        noteIndex      = 0;
            for (int i = 0; i < LeftNote.Length; i++)
            {
                if (LeftNote[i] != null)
                {
                    int tempNum = LeftNote[i].GetComponent <RhythmGameNote_Controller>().noteCount;
                    if (minValue == -1)
                    {
                        noteIndex = i;
                        minValue  = tempNum;
                    }
                    else if (minValue > tempNum)
                    {
                        noteIndex = i;
                        minValue  = tempNum;
                    }
                }
            }
            if (LeftNote[noteIndex] == null)
            {
                return;
            }

            tempRhythmNote = LeftNote[noteIndex].GetComponent <RhythmGameNote_Controller>().rhythmNote;
            if (tempRhythmNote != RhythmNote.None && tempRhythmNote != RhythmNote.Miss)
            {
                RhythmGameNoteDelete(new RhythmGameNoteDeleteMsg(tempRhythmNote, noteIndex, LeftNote[noteIndex], false, false));
            }
        }
    }
Exemplo n.º 9
0
 public RhythmGameNoteJudgeMsg(RhythmNote rhythmNote)
 {
     this.rhythmNote = rhythmNote;
 }
Exemplo n.º 10
0
    private void CreateNotes()
    {
        if (noteIndex < notes.Count)
        {
            if (notes[noteIndex].startTotal < timeLapsed + timeOffset)
            {
                pos = spawnPositions[notes[noteIndex].pitchPosition];
                color = notes[noteIndex].color;
                noteWidth = notes[noteIndex].noteDuration * lengthRatio;

                switch(notes[noteIndex].color)
                {
                    case Note.NoteColor.Blue:
                    case Note.NoteColor.Yellow:
                    case Note.NoteColor.Green:
                    case Note.NoteColor.Red:
                    {
                        GameObject newNote = (GameObject)Instantiate(singlePrefab);
                        newNote.transform.parent = noteParent.transform;
                        newNote.transform.localScale = Vector3.one;
                        newNote.name = notesSpawned.ToString() + ": Note (" + notes[noteIndex].color.ToString() + ")";

                        rNote = newNote.GetComponent<RhythmNote>();
                        rNote.Init(pos, color, noteWidth, gameObject);
                        notesSpawned++;
                        break;
                    }
                    default:
                    {
                        GameObject newNote = (GameObject)Instantiate(doublePrefab);
                        newNote.transform.parent = noteParent.transform;
                        newNote.transform.localScale = Vector3.one;
                        newNote.name = notesSpawned.ToString() + ": Note (" + notes[noteIndex].color.ToString() + ")";

                        rNote = newNote.GetComponent<RhythmNote>();
                        rNote.Init(pos, color, noteWidth, gameObject);
                        notesSpawned++;
                        break;
                    }
                }

                noteIndex++;
            }
        }
    }
Exemplo n.º 11
0
    void RhythmGameBtnTouch(RhythmGameBtnTouchMsg msg)
    {
        if (msg.isRight)
        {
            RhythmNote tempRhythmNote = RhythmNote.None;
            int        minValue       = -1;
            int        noteIndex      = 0;
            for (int i = 0; i < RightNote.Length; i++)
            {
                if (RightNote[i] != null)
                {
                    int tempNum = RightNote[i].GetComponent <RhythmGameNote_Controller>().noteCount;
                    if (minValue == -1)
                    {
                        noteIndex = i;
                        minValue  = tempNum;
                    }
                    else if (minValue > tempNum)
                    {
                        noteIndex = i;
                        minValue  = tempNum;
                    }
                }
            }
            if (RightNote[noteIndex] == null)
            {
                return;
            }

            tempRhythmNote = RightNote[noteIndex].GetComponent <RhythmGameNote_Controller>().rhythmNote;
            if (tempRhythmNote != RhythmNote.None)
            {
                RhythmGameNoteDelete(new RhythmGameNoteDeleteMsg(tempRhythmNote, noteIndex, RightNote[noteIndex], true, false));
            }
        }
        else
        {
            RhythmNote tempRhythmNote = RhythmNote.None;
            int        minValue       = -1;
            int        noteIndex      = 0;
            for (int i = 0; i < LeftNote.Length; i++)
            {
                if (LeftNote[i] != null)
                {
                    int tempNum = LeftNote[i].GetComponent <RhythmGameNote_Controller>().noteCount;
                    if (minValue == -1)
                    {
                        noteIndex = i;
                        minValue  = tempNum;
                    }
                    else if (minValue > tempNum)
                    {
                        noteIndex = i;
                        minValue  = tempNum;
                    }
                }
            }
            if (LeftNote[noteIndex] == null)
            {
                return;
            }

            tempRhythmNote = LeftNote[noteIndex].GetComponent <RhythmGameNote_Controller>().rhythmNote;
            if (tempRhythmNote != RhythmNote.None)
            {
                RhythmGameNoteDelete(new RhythmGameNoteDeleteMsg(tempRhythmNote, noteIndex, LeftNote[noteIndex], false, false));
            }
        }
    }