示例#1
0
 // Tap down event
 void OnTapDown(int id, Vector2 position)
 {
     if (common.gameOver)
     {
         common.OnTapDown(id, position);
     }
     else
     {
         // Collision check via raycast
         Ray        ray = Camera.main.ScreenPointToRay(position);
         RaycastHit hit;
         // If hit
         if (Physics.Raycast(ray, out hit))
         {
             // Check tag
             GameObject hitObject = hit.collider.gameObject;
             if (hitObject.tag.Equals(Tags.NOTE))
             {
                 NotesScript note = hitObject.GetComponent <NotesScript>();
                 if (note.state == NotesScript.NotesState.ACTIVE)
                 {
                     common.OnNoteHit(note);
                 }
             }
         }
     }
 }
    private void DoNotNotes()
    {
        if (activeNotes == null)
        {
            return;
        }

        for (int i = 0; i < activeNotes.Length; i++)
        {
            if (activeNotes[i] == null)
            {
                continue;
            }
            NotesScript note = activeNotes[i].GetComponent <NotesScript>();
            float       diff = note.notesTiming - move.time;
            if (LNType == LNType.Keep && note.type == ScoreIndex.LONG_END && diff <= 0f)
            {
                ScoreManager.instance.AddJudge(JudgeState.Great, note, diff);
                SetActiveNotes(i, JudgeState.Great);
            }
            else if (diff < (judgeWidth.JudgeTimings[judgeWidth.JudgeTimings.Length - 1] * -1.0f))
            {
                ScoreManager.instance.AddJudge(JudgeState.Bad, note, diff);
                SetActiveNotes(i, JudgeState.Bad);
            }
        }
    }
示例#3
0
    private void SetJudgeString(JudgeState state, NotesScript note)
    {
        switch (state)
        {
        case JudgeState.Great:
            combo++;
            judgeStr.text = "GREAT " + combo.ToString();
            break;

        case JudgeState.Good:
            combo++;
            judgeStr.text = "GOOD " + combo.ToString();
            break;

        case JudgeState.Bad:
            combo         = 0;
            judgeStr.text = "BAD";
            break;

        case JudgeState.AUTO:
            combo++;
            judgeStr.text = "AUTO " + combo.ToString();
            break;
        }
    }
示例#4
0
    public void OnNoteMiss(NotesScript note)
    {
        float timeDiff = note.time - musicTime;

        SetAccuracy(timeDiff);
        note.state = NotesScript.NotesState.MISS;
        note.PlayMissAnim();
    }
示例#5
0
    // Remove completed notes, add new ones
    void UpdateNotesList()
    {
        // Game over check
        if (common.gameOver)
        {
            return;
        }

        // Remove completed notes, assumes sequential removal
        while (notes.Count > 0 && notes.First.Value.state == NotesScript.NotesState.REMOVE)
        {
            Destroy(notes.First.Value.gameObject);
            notes.RemoveFirst();
        }

        // Add new notes
        while (notesIterator.hasNext())
        {
            // If in the look-ahead range
            if (notesIterator.nextTime() - common.musicTime < CommonScript.TIME_LOOKAHEAD)
            {
                GameObject  notesObject = (GameObject)Instantiate(notesPrefab);
                NotesScript note        = notesObject.GetComponent <NotesScript>();
                notesIterator.next(note);
                // Set note's position
                Vector3 position;
                float   timePoint  = note.time % CommonScript.TIME_SCROLL;
                float   multiplier = timePoint / CommonScript.TIME_SCROLL;
                switch (note.column)
                {
                case 0: position = notesPositionInit_0 - notesPositionDelta_0 * multiplier; break;

                case 1: position = notesPositionInit_1 - notesPositionDelta_1 * multiplier; break;

                case 2: position = notesPositionInit_2 - notesPositionDelta_2 * multiplier; break;

                case 3: position = notesPositionInit_3 - notesPositionDelta_3 * multiplier; break;

                default: position = new Vector3(0, 0, 0); break;                         // Error
                }
                notesObject.transform.position = position;
                exSprite sprite = notesObject.GetComponent <exSprite>();
                sprite.color = new Color(1, 1, 1, 0);
                notes.AddLast(new LinkedListNode <NotesScript>(note));
            }
            else
            {
                break;
            }
        }

        // Check game done
        if (notes.Count == 0 && !notesIterator.hasNext())
        {
            slider.gameObject.active = false;
            common.OnGameOver();
        }
    }
    /// <summary>
    /// 譜面を生成するよ
    /// </summary>
    private void GenerateScore()
    {
        if (data_BPM.Count == 0)
        {
            Debug.LogWarning("BPM情報が見つかりませんでした");
            return;
        }

        Init_noteObjects();

        float offset = data_OFFSET;

        float[] xPos = { -7.0f, -5.0f, -3.0f, -1.0f };
        for (int x = 0; x < data_MusicScore.Length; x++)
        {
            for (int y = 0; y < data_MusicScore[x].Count; y++)
            {
                NotesInfo info = data_MusicScore[x][y];
                BPMS      bpm  = GetBPM(info);
                STOPS     stop = GetStop(info);

                GameObject obj        = Instantiate(notesPrefab);
                float      noteBarPos = (float)info.bar + (float)info.th / (float)info.barOriginTh;

                NotesScript note = obj.AddComponent <NotesScript>();
                note.stopdata = stop;

                note.notesTiming = bpm.currentTime + 240f / bpm.BPM * (noteBarPos - bpm.changeTiming);
                note.type        = info.type;
                obj.transform.SetParent(parentObj.transform);

                float yPos = bpm.currentLength_Total + (noteBarPos - bpm.changeTiming) * bpm.scoreLengthPerBar * bpm.correctionNum;

                obj.transform.localPosition = new Vector3(xPos[x], yPos * multi, 0f);

                if (info.type == ScoreIndex.LONG)
                {
                    GameObject obj2 = Instantiate(notesPrefab);
                    noteBarPos = (float)info.LNend_bar + (float)info.LNend_th / (float)info.LNend_barOriginTh;

                    note.LNendObj = obj2;
                    note.lr       = obj.AddComponent <LineRenderer>();
                    note          = obj2.AddComponent <NotesScript>();

                    note.type        = ScoreIndex.LONG_END;
                    note.notesTiming = bpm.currentTime + 240f / bpm.BPM * (noteBarPos - bpm.changeTiming);
                    obj2.transform.SetParent(parentObj.transform);
                    yPos = bpm.currentLength_Total + (noteBarPos - bpm.changeTiming) * bpm.scoreLengthPerBar * bpm.correctionNum;

                    obj2.transform.localPosition = new Vector3(xPos[x], yPos * multi, 0f);
                    obj2.transform.SetParent(obj.transform);
                }

                noteObjects[x].Enqueue(obj);
            }
        }
    }
示例#7
0
    // Note hit
    public void OnNoteHit(NotesScript note)
    {
        float timeDiff = note.time - musicTime;

        SetAccuracy(timeDiff);
        note.state = NotesScript.NotesState.HIT;
        note.PlayHitAnim();
        note.time_hit = musicTime;
    }
示例#8
0
 public void CheckAutoPlay(NotesScript note, float timeDiff)
 {
     if (autoPlay && note.state == NotesScript.NotesState.ACTIVE)
     {
         if (timeDiff < ACC_PRE_MARVEVLOUS / 2)               // Super accuracy!
         {
             OnNoteHit(note);
         }
     }
 }
示例#9
0
    public void UpdateNoteState(NotesScript note, float timeDiff)
    {
        // Update alpha
        exSprite sprite = note.gameObject.GetComponent <exSprite>();

        if (timeDiff > TIME_ONSCREEN_OPAQ)
        {
            sprite.color = new Color(1, 1, 1, 1 - (timeDiff - TIME_ONSCREEN_OPAQ) / (TIME_LOOKAHEAD - TIME_ONSCREEN_OPAQ));
        }
        else
        {
            sprite.color = new Color(1, 1, 1, 1);
        }

        // We assume notes don't skip states (e.g. from DISABLE to MISS)
        switch (note.state)
        {
        case NotesScript.NotesState.DISABLE:
            if (timeDiff <= TIME_ACTIVE)
            {
                note.state = NotesScript.NotesState.ACTIVE;
            }
            break;

        case NotesScript.NotesState.ACTIVE:
            if (timeDiff <= TIME_MISS)
            {
                OnNoteMiss(note);
            }
            break;

        case NotesScript.NotesState.HIT:
            float hitTimeDiff = note.time_hit - musicTime;
            if (hitTimeDiff <= TIME_REMOVE)
            {
                note.state = NotesScript.NotesState.REMOVE;
            }
            break;

        case NotesScript.NotesState.MISS:
            // TODO
            if (timeDiff <= TIME_MISS + TIME_REMOVE)
            {
                note.state = NotesScript.NotesState.REMOVE;
            }
            break;

        case NotesScript.NotesState.REMOVE:
        default:
            break;
        }
    }
示例#10
0
    //セットするよ
    public void SetActiveNotes(int laneNum, JudgeState judge = JudgeState.none)
    {
        bool LongEnd = false;

        if (activeNotes[laneNum] != null)
        {
            NotesScript noteInfo = activeNotes[laneNum].GetComponent <NotesScript>();

            ScoreIndex noteType = noteInfo.type;

            switch (noteType)
            {
            case ScoreIndex.SIMPLE:
                Destroy(activeNotes[laneNum]);
                break;

            case ScoreIndex.LONG:
                if (judge == JudgeState.Bad)
                {
                    Destroy(activeNotes[laneNum]);
                }
                else
                {
                    LongEnd = true;
                }
                break;

            case ScoreIndex.LONG_END:
                Destroy(activeNotes[laneNum].transform.parent.gameObject);
                break;
            }
        }

        if (LongEnd)
        {
            activeNotes[laneNum] = activeNotes[laneNum].GetComponent <NotesScript>().LNendObj;
            return;
        }

        if (noteObjects[laneNum].Count != 0)
        {
            activeNotes[laneNum] = noteObjects[laneNum].Dequeue();
        }
        else
        {
            activeNotes[laneNum] = null;
        }
    }
    // Remove completed notes, add new ones
    void UpdateNotesList()
    {
        // Game over check
        if (common.gameOver)
        {
            return;
        }

        // Remove completed notes, assumes sequential removal
        while (notes.Count > 0 && notes.First.Value.state == NotesScript.NotesState.REMOVE)
        {
            Destroy(notes.First.Value.gameObject);
            notes.RemoveFirst();
        }

        // Add new notes
        while (notesIterator.hasNext())
        {
            // If in the look-ahead range
            if (notesIterator.nextTime() - common.musicTime < CommonScript.TIME_LOOKAHEAD)
            {
                GameObject  notesObject = (GameObject)Instantiate(notesPrefab);
                NotesScript note        = notesObject.GetComponent <NotesScript>();
                notesIterator.next(note);
                notes.AddLast(new LinkedListNode <NotesScript>(note));
            }
            else
            {
                break;
            }
        }

        // Check game done
        if (notes.Count == 0 && !notesIterator.hasNext())
        {
            foreach (TapboxScript tapbox in tapboxes)
            {
                tapbox.gameObject.active = false;
            }
            common.OnGameOver();
        }
    }
示例#12
0
    private void AddScore(JudgeState state, NotesScript note)
    {
        switch (state)
        {
        case JudgeState.Great:
            score += 2;
            break;

        case JudgeState.Good:
            score += 1;
            break;

        case JudgeState.AUTO:
            score += 2;
            break;

        default:
            break;
        }
    }
示例#13
0
    public void AddJudge(JudgeState state, NotesScript note, float diff = 0.0f)
    {
        AddScore(state, note);
        SetJudgeString(state, note);
        string FS;

        if (diff >= 0.0f)
        {
            FS = "FAST";
        }
        else
        {
            FS = "SLOW";
        }
        switch (state)
        {
        case JudgeState.Great:
            AddJudge_Great();
            FSStr.text = "";
            break;

        case JudgeState.Good:
            AddJudge_Good();
            FSStr.text = FS;
            break;

        case JudgeState.Bad:
            AddJudge_Bad();
            FSStr.text = FS;
            if (note.type == ScoreIndex.LONG)
            {
                AddJudge_Bad();
            }
            break;

        case JudgeState.AUTO:
            AddJudge_Great();
            break;
        }
    }
示例#14
0
    private void AutoPlay()
    {
        if (activeNotes == null)
        {
            return;
        }

        for (int i = 0; i < activeNotes.Length; i++)
        {
            if (activeNotes[i] == null)
            {
                continue;
            }
            float diff = activeNotes[i].GetComponent <NotesScript>().notesTiming
                         - move.time;
            if (diff <= 0.0f)
            {
                NotesScript note = activeNotes[i].GetComponent <NotesScript>();
                ScoreManager.instance.AddJudge(JudgeState.AUTO, note);
                SetActiveNotes(i, JudgeState.Great);
                _audioSource.PlayOneShot(clap);
            }
        }
    }
示例#15
0
 public void next(NotesScript note)
 {
     note.Setup(time, column, fraction, type);
     advance();
 }
示例#16
0
 public float GetTimeDiff(NotesScript note)
 {
     return(note.time - musicTime);
 }
示例#17
0
 public void next(NotesScript note)
 {
     note.Setup(time, column, fraction, type);
     advance();
 }
示例#18
0
 public void next(out float time, out int column, out int fraction, out NotesScript.NotesType type)
 {
     time = this.time;
     column = this.column;
     fraction = this.fraction;
     type = this.type;
     advance();
 }
示例#19
0
 public void AddNote(NotesScript note)
 {
     notesList.Add(note);
 }
示例#20
0
    void UpdateNotesList()
    {
        // Game over check
        if (common.gameOver)
        {
            return;
        }

        // Remove completed notes, assumes sequential removal
        while (notes.Count > 0 && notes.First.Value.state == NotesScript.NotesState.REMOVE)
        {
            Destroy(notes.First.Value.gameObject);
            notes.RemoveFirst();
        }

        // Add new notes
        while (notesIterator.hasNext())
        {
            // If in the look-ahead range
            if (notesIterator.nextTime() - common.musicTime < CommonScript.TIME_LOOKAHEAD)
            {
                GameObject  notesObject = (GameObject)Instantiate(notesPrefab);
                NotesScript note        = notesObject.GetComponent <NotesScript>();
                notesIterator.next(note);
                // For grid
                note.column += rowCount * 4;
                rowCount++;
                if (rowCount > 3)
                {
                    rowCount = 0;
                }
                Vector3 position;
                switch (note.column)
                {
                case 0: position = tapboxPosition_0; break;

                case 1: position = tapboxPosition_1; break;

                case 2: position = tapboxPosition_2; break;

                case 3: position = tapboxPosition_3; break;

                case 4: position = tapboxPosition_4; break;

                case 5: position = tapboxPosition_5; break;

                case 6: position = tapboxPosition_6; break;

                case 7: position = tapboxPosition_7; break;

                case 8: position = tapboxPosition_8; break;

                case 9: position = tapboxPosition_9; break;

                case 10: position = tapboxPosition_10; break;

                case 11: position = tapboxPosition_11; break;

                case 12: position = tapboxPosition_12; break;

                case 13: position = tapboxPosition_13; break;

                case 14: position = tapboxPosition_14; break;

                case 15: position = tapboxPosition_15; break;

                default: position = new Vector3(0, 0, 0); break;                         // Error
                }
                position += notesPositionOffset;
                note.gameObject.transform.position = position;
                // Add
                notes.AddLast(new LinkedListNode <NotesScript>(note));
            }
            else
            {
                break;
            }
        }

        // Check game done
        if (notes.Count == 0 && !notesIterator.hasNext())
        {
            foreach (TapboxScript tapbox in tapboxes)
            {
                tapbox.gameObject.active = false;
            }
            common.OnGameOver();
        }
    }
示例#21
0
    public void InputKey(int laneNum, bool keyState)
    {
        if (activeNotes[laneNum] == null)
        {
            return;
        }

        NotesScript noteInfo = activeNotes[laneNum].GetComponent <NotesScript>();

        ScoreIndex type = noteInfo.type;

        if (keyState == false && type != ScoreIndex.LONG_END)
        {
            return;
        }

        float diff = noteInfo.notesTiming - move.time;

        float fixDiff = Mathf.Abs(diff);

        JudgeState state = JudgeState.none;

        //判定部分
        if (judgeWidth.JudgeTimings[judgeWidth.JudgeTimings.Length - 1] >= fixDiff)
        {
            for (int i = 0; i < judgeWidth.JudgeTimings.Length; i++)
            {
                if (judgeWidth.JudgeTimings[i] >= fixDiff)
                {
                    switch (i)
                    {
                    case 0:
                        state = JudgeState.Great;
                        break;

                    case 1:
                        state = JudgeState.Good;
                        break;

                    case 2:
                        state = JudgeState.Bad;
                        break;
                    }
                    break;
                }
            }
        }

        switch (type)
        {
        case ScoreIndex.SIMPLE:
            if (state == JudgeState.none)
            {
                break;
            }
            ScoreManager.instance.AddJudge(state, noteInfo, diff);
            SetActiveNotes(laneNum, state);
            break;

        case ScoreIndex.LONG:
            if (state == JudgeState.none)
            {
                break;
            }
            ScoreManager.instance.AddJudge(state, noteInfo, diff);
            SetActiveNotes(laneNum, state);
            break;

        case ScoreIndex.LONG_END:
            if (state == JudgeState.none)
            {
                state = JudgeState.Bad;
            }
            ScoreManager.instance.AddJudge(state, noteInfo, diff);
            SetActiveNotes(laneNum, state);
            break;
        }
    }