Ejemplo n.º 1
0
    IEnumerator CreateNotes(NoteAsset note)
    {
        yield return(new WaitForSeconds(note.Time));

        if (note.Dur == 0)
        {
            if (note.Pos % 2 == 0)
            {
                (Instantiate(noteWhite) as GameObject).GetComponent <TapController>().note = note;
            }
            else
            {
                (Instantiate(noteBlue) as GameObject).GetComponent <TapController>().note = note;
            }
        }
        else
        {
            if (note.Pos % 2 == 0)
            {
                (Instantiate(noteLongWhite) as GameObject).GetComponent <HoldController>().note = note;
            }
            else
            {
                (Instantiate(noteLongBlue) as GameObject).GetComponent <HoldController>().note = note;
            }
        }
        yield break;
    }
Ejemplo n.º 2
0
    private IEnumerator DestroyNote()
    {
        float duration = note.Dur;

        if (!isJudged)
        {
            yield return(new WaitForSeconds(goodTime));
        }
        else
        {
            note.CanJudge = false;
        }
        NoteAsset nextNote = InputController._instance.GetNextNote(note);

        yield return(new WaitForSeconds(0.03f));

        if (nextNote != null)
        {
            nextNote.CanJudge = true;
        }
        yield return(new WaitForSeconds(duration));

        Destroy(gameObject);
        yield break;
    }
Ejemplo n.º 3
0
 private void GetMap(string path)
 {
     try
     {
         TextAsset text  = Resources.Load <TextAsset>("Songs/" + path + "/" + diff);
         string[]  lines = text.text.Split('\n');
         Debug.Log("Assets/Resources/Songs/" + path + "/" + diff + ".txt");
         bpm        = int.Parse(lines[0].Substring(5));
         totalScore = 0;
         for (int i = 1; i < lines.Length; i++)
         {
             if (lines[i] != "")
             {
                 string[]  line = lines[i].Split(',');
                 NoteAsset note = new NoteAsset(line[0], (int.Parse(line[1])) / 1000.0f, int.Parse(line[2]), int.Parse(line[3]) / 1000.0f);
                 if ((int.Parse(line[3]) / 1000.0f) > 0)
                 {
                     totalScore += 2;
                 }
                 else
                 {
                     totalScore++;
                 }
                 NoteController._instance.noteList.Add(note);
             }
         }
         JudgeStatistics.totalScore = totalScore * 3;
     }
     catch (System.Exception)
     {
         Debug.LogError("File not exist.");
     }
 }
Ejemplo n.º 4
0
 public bool Judge1(NoteAsset note)
 {
     if (Input.GetAxisRaw("UpDown") == 1 && note.CanJudge)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 5
0
 public bool Judge0(NoteAsset note)
 {
     if (Input.GetAxisRaw("LeftRight") == -1 && note.CanJudge)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 6
0
    public static bool JoystickLJudge(NoteAsset note)    //0
    {
        start = 0;
        int next = (int)Input.GetAxisRaw("LeftRight");

        if (next - start == -1)
        {
            return(note.CanJudge);
        }
        return(false);
    }
Ejemplo n.º 7
0
    /// <summary>
    /// 获取当前列的上一个note
    /// </summary>
    /// <param name="note"></param>
    /// <returns></returns>
    public NoteAsset GetPreviousNote(NoteAsset note)
    {
        List <NoteAsset> noteList = NoteController._instance.noteList;
        int index     = noteList.IndexOf(note);
        int nextIndex = noteList.FindLastIndex(index,
                                               delegate(NoteAsset note1)
        {
            return(note1.Pos == note.Pos);
        });

        return(noteList[nextIndex]);
    }
Ejemplo n.º 8
0
    public GameObject GetKey(NoteAsset note)
    {
        GameObject  player      = Instantiate(_instance.audioPlayer) as GameObject;
        string      s           = _instance.soundList[note.Id];
        AudioClip   clip        = Resources.Load <AudioClip>("Songs/" + ReadSong.path + "/key/" + s);
        AudioSource audiosource = player.AddComponent <AudioSource>();

        audiosource.volume      = ReadSong.vol;
        audiosource.clip        = clip;
        audiosource.playOnAwake = false;
        return(player);
    }
Ejemplo n.º 9
0
    private void UserPlayMode()
    {
        bool      isFirstNote = false;
        NoteAsset previous    = InputController._instance.GetPreviousNote(note);

        if (previous == null)
        {
            isFirstNote = true;
        }
        if (Time.timeSinceLevelLoad <= note.Time + noteDropTime + goodTime)
        {
            if (note.CanJudge && ((!previous.CanJudge) || !isFirstNote))
            {
                JudgeType returnType = NoteJudge(note);
                if (returnType != JudgeType.Poor && returnType != JudgeType.Bad)
                {
                    isJudged = true;
                    StartCoroutine(DestroyNote());
                    CreateFX(returnType);
                    InputController.combo++;
                    InputController._instance.ShowJudge(returnType);
                    InputController._instance.ShowCombo(returnType);
                    InputController._instance.ShowFastSlow(returnType);
                    Invoke("HoldEnded", note.Dur);
                }
                else if (returnType == JudgeType.Bad && returnType == JudgeType.Poor)
                {
                    InputController._instance.ShowCombo(returnType);
                    InputController._instance.ShowFastSlow(returnType);
                }
            }
        }
        else
        {
            TransparentHold();
            isJudged              = true;
            IsDestroyed           = true;
            InputController.combo = 0;
            JudgeStatistics.poor += 2;
            if (JudgeStatistics.life >= 9)
            {
                JudgeStatistics.life -= 8f;
            }
            InputController._instance.ShowJudge(JudgeType.Poor);
            InputController._instance.ShowCombo(JudgeType.Poor);
            InputController._instance.ShowFastSlow(JudgeType.Poor);
            Debug.Log(note + "poor");
        }
    }
Ejemplo n.º 10
0
    /// <summary>
    /// 获取当前列的下一个note
    /// </summary>
    /// <param name="note"></param>
    /// <returns></returns>
    public NoteAsset GetNextNote(NoteAsset note)
    {
        List <NoteAsset> noteList = NoteController._instance.noteList;
        int index = noteList.IndexOf(note);

        try
        {
            int nextIndex = noteList.FindIndex(index + 1,
                                               delegate(NoteAsset note1)
            {
                return(note1.Pos == note.Pos);
            });
            return(noteList[nextIndex]);
        }
        catch (Exception)
        {
            return(null);
        }
    }
Ejemplo n.º 11
0
    public override JudgeType NoteJudge(NoteAsset note)
    {
        AudioSource audio = key;
        int         pos   = note.Pos;

        if (InputController._instance.isControllerConnected)
        {
            if ((Utils.JoystickLJudge(note) && pos == 0) || (Utils.JoystickUJudge(note) && pos == 1) ||
                (Utils.HoldJudge(KeyCode.JoystickButton2, note) && pos == 2) || (Utils.HoldJudge(KeyCode.JoystickButton3, note) && pos == 3) ||
                (Utils.HoldJudge(KeyCode.JoystickButton1, note) && pos == 4) || (Utils.JoystickRJudge(note) && pos == 2))
            {
                StartCoroutine(PlaySingleKey(audio));
                IsHolded = true;
                return(JudgeNote(note));
            }
            //else if ((Utils.HoldUpJudge(KeyCode.JoystickButton2, note) && pos == 2) || (Utils.HoldUpJudge(KeyCode.JoystickButton3, note) && pos == 3) ||
            //	(Utils.HoldUpJudge(KeyCode.JoystickButton1, note) && pos == 4))
            //{
            //	IsHolded = false;
            //	IsDestroyed = true;
            //	isComplete = false;
            //}
        }
        else
        {
            JudgeType judge = JudgeType.Poor;
            if ((Utils.HoldJudge(KeyCode.D, note) && pos == 0) || (Utils.HoldJudge(KeyCode.F, note) && pos == 1) ||
                (Utils.HoldJudge(KeyCode.Space, note) && pos == 2) || (Utils.HoldJudge(KeyCode.J, note) && pos == 3) ||
                (Utils.HoldJudge(KeyCode.K, note) && pos == 4))
            {
                judge    = JudgeNote(note);
                IsHolded = true;
                StartCoroutine(Timer());
                StartCoroutine(PlaySingleKey(audio));
            }
            else
            {
                IsHolded = false;
            }
            return(judge);
        }
        return(JudgeType.Poor);
    }
Ejemplo n.º 12
0
    private IEnumerator DestroyNote()
    {
        if (!isJudged)
        {
            transform.position = new Vector3(transform.position.x, -3.25f);
            yield return(new WaitForSeconds(goodTime));
        }
        else
        {
            note.CanJudge = false;
        }
        NoteAsset nextNote = InputController._instance.GetNextNote(note);

        yield return(new WaitForSeconds(0.03f));

        if (nextNote != null)
        {
            nextNote.CanJudge = true;
        }
        DestroyImmediate(gameObject);
        yield break;
    }
Ejemplo n.º 13
0
 public static bool JoystickRJudge(NoteAsset note)    //2
 {
     return((Input.GetAxisRaw("LeftRight") == 1) && note.CanJudge);
 }
Ejemplo n.º 14
0
 public static bool HoldJudge(KeyCode key, NoteAsset note)
 {
     return(Input.GetKey(key) && note.CanJudge);
 }
Ejemplo n.º 15
0
    public static bool HoldUpJudge(KeyCode key, NoteAsset note)
    {
        float upTime = Time.timeSinceLevelLoad + note.Dur + NoteController.noteDropTime - 0.05f;

        return(Input.GetKeyUp(key) && (Time.timeSinceLevelLoad <= upTime) && note.CanJudge);
    }
Ejemplo n.º 16
0
    public override JudgeType NoteJudge(NoteAsset note)
    {
        AudioSource audio = key;
        int         pos   = note.Pos;

        if (InputController._instance.isControllerConnected)
        {
            if (Input.GetAxis("LeftRight") < 0 && pos == 0 && note.CanJudge)
            {
                if (!LeftArrow)
                {
                    if (!isNotePlayed)
                    {
                        StartCoroutine(PlaySingleKey(audio));
                    }
                    JudgeType i = JudgeNote(note);
                    if (i != JudgeType.Bad)
                    {
                        return(i);
                    }
                }
                LeftArrow = true;
            }
            else
            {
                LeftArrow = false;
            }
            if (Input.GetAxis("LeftRight") > 0 && pos == 2 && note.CanJudge)
            {
                if (!RightArrow)
                {
                    if (!isNotePlayed)
                    {
                        StartCoroutine(PlaySingleKey(audio));
                    }
                    JudgeType i = JudgeNote(note);
                    if (i != JudgeType.Bad)
                    {
                        return(i);
                    }
                }
                RightArrow = true;
            }
            else
            {
                RightArrow = false;
            }
            if (Input.GetAxis("UpDown") > 0 && pos == 1 && note.CanJudge)
            {
                if (!UpArrow)
                {
                    if (!isNotePlayed)
                    {
                        StartCoroutine(PlaySingleKey(audio));
                    }
                    JudgeType i = JudgeNote(note);
                    if (i != JudgeType.Bad)
                    {
                        return(i);
                    }
                }
                UpArrow = true;
            }
            else
            {
                UpArrow = false;
            }
            if ((Utils.KeyJudge(KeyCode.JoystickButton2, note) && pos == 2) ||
                (Utils.KeyJudge(KeyCode.JoystickButton3, note) && pos == 3) ||
                (Utils.KeyJudge(KeyCode.JoystickButton1, note) && pos == 4))
            {
                if (!isNotePlayed)
                {
                    Debug.Log("play");
                    StartCoroutine(PlaySingleKey(audio));
                }
                return(JudgeNote(note));
            }
        }
        else
        {
            if ((Utils.KeyJudge(KeyCode.D, note) && pos == 0) || (Utils.KeyJudge(KeyCode.F, note) && pos == 1) ||
                (Utils.KeyJudge(KeyCode.Space, note) && pos == 2) || (Utils.KeyJudge(KeyCode.J, note) && pos == 3) ||
                (Utils.KeyJudge(KeyCode.K, note) && pos == 4))
            {
                JudgeType i = JudgeNote(note);
                if (!isNotePlayed && i != JudgeType.Bad)
                {
                    Debug.Log("play");
                    StartCoroutine(PlaySingleKey(audio));
                }
                return(i);
            }
        }
        return(JudgeType.Poor);
    }
Ejemplo n.º 17
0
 public static bool JoystickUJudge(NoteAsset note)    //1
 {
     return((Input.GetAxisRaw("UpDown") == 1) && note.CanJudge);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// 判定音符
 /// </summary>
 /// <param name="note">当前note</param>
 /// <returns>判定id</returns>
 public abstract JudgeType NoteJudge(NoteAsset note);
Ejemplo n.º 19
0
    public JudgeType JudgeNote(NoteAsset note)
    {
        float sceneTime = Time.timeSinceLevelLoad;
        float time      = note.Time;
        float exactTime = time + noteDropTime + fixedTime;

        if (sceneTime <= exactTime + perfectTime &&
            sceneTime > exactTime - perfectTime)
        {
            Debug.Log(note + "perfect");
            JudgeStatistics.perfect++;
            if (JudgeStatistics.life <= 99.55f)
            {
                JudgeStatistics.life += 0.45f;
            }
            return(JudgeType.Perfect);
        }
        else if (sceneTime < exactTime + greatTime && sceneTime > exactTime + perfectTime)
        {
            Debug.Log(note + "Lgreat");
            JudgeStatistics.great++;
            if (JudgeStatistics.life <= 99.85f)
            {
                JudgeStatistics.life += 0.15f;
            }
            return(JudgeType.LGreat);
        }
        else if (sceneTime > exactTime - greatTime && sceneTime < exactTime - perfectTime)
        {
            Debug.Log(note + "Egreat");
            JudgeStatistics.great++;
            if (JudgeStatistics.life <= 99.85f)
            {
                JudgeStatistics.life += 0.15f;
            }
            return(JudgeType.EGreat);
        }
        else if (sceneTime < exactTime + goodTime && sceneTime > exactTime + greatTime)
        {
            Debug.Log(note + "Lgood");
            JudgeStatistics.good++;
            return(JudgeType.LGood);
        }
        else if (sceneTime > exactTime - goodTime && sceneTime < exactTime - greatTime)
        {
            Debug.Log(note + "Egood");
            JudgeStatistics.good++;
            return(JudgeType.EGood);
        }
        else if (sceneTime < exactTime - goodTime && sceneTime > exactTime - badTime)
        {
            Debug.Log(note + "Ebad");
            JudgeStatistics.bad++;
            JudgeStatistics.life -= 2f;
            return(JudgeType.Bad);
        }
        else if (sceneTime < exactTime - badTime)
        {
            return(JudgeType.Poor);
        }
        return(JudgeType.Default);
    }