Example #1
0
    bool HoldJudgeCheck(LaneEnum laneEnum, int noteNum)
    {
        int   laneInt = (int)laneEnum;
        float notePerfectJudgeTime = noteInstDatas[laneInt][noteNum].notePerfectJudgeTime;

        if (songPlayingTime >= notePerfectJudgeTime)
        {
            noteInstDatas[laneInt][noteNum].holdJudge = false;
            if (!touchHold[laneInt])
            {
                return(false);
            }
            float liftPosX = lift[laneInt].transform.position.x;
            float notePosX = noteInstDatas[laneInt][noteNum].noteInst.transform.position.x;
            for (JudgeEnum judgeEnum = JudgeEnum.perfect; judgeEnum != JudgeEnum.miss; judgeEnum++)
            {
                int judgeInt = (int)judgeEnum;
                if (liftPosX + holdJudgePos[judgeInt] >= notePosX - holdJudgePos[judgeInt] && liftPosX - holdJudgePos[judgeInt] <= notePosX + holdJudgePos[judgeInt])
                {
                    Judge(judgeEnum, laneEnum, noteNum);
                    return(true);
                }
            }
        }
        return(false);
    }
Example #2
0
    void NoteMove(LaneEnum laneEnum, int noteNum)
    {
        int     laneInt = (int)laneEnum;
        Vector3 movePos = (transform.up + transform.forward) * noteInstDatas[laneInt][noteNum].noteSpeed * Time.fixedDeltaTime;

        noteInstDatas[laneInt][noteNum].noteInst.transform.position -= movePos;
    }
Example #3
0
    void TapJudgeCheck(LaneEnum laneEnum, int noteNum)
    {
        int   laneInt  = (int)laneEnum;
        float liftPosX = lift[laneInt].transform.position.x;
        float notePosX = noteInstDatas[laneInt][noteNum].noteInst.transform.position.x;

        float inputGapTime = songPlayingTime - songAudio.time;


        //判定デバッグ
        inputGapText.text = "inputgap: " + inputGapTime;
        gapTimeAdd       += noteInstDatas[laneInt][noteNum].notePerfectJudgeTime - songPlayingTime;
        judgeCount++;
        gapText.text = "gap:" + (gapTimeAdd / judgeCount);


        if (liftPosX + tapJudgePosX >= notePosX - tapJudgePosX && liftPosX - tapJudgePosX <= notePosX + tapJudgePosX)
        {
            float notePerfectJudgeTime = noteInstDatas[laneInt][noteNum].notePerfectJudgeTime;
            for (JudgeEnum judgeEnum = JudgeEnum.perfect; judgeEnum != JudgeEnum.miss; judgeEnum++)
            {
                int judgeInt = (int)judgeEnum;
                if (songPlayingTime >= notePerfectJudgeTime - tapJudgeTime[judgeInt] && songPlayingTime <= notePerfectJudgeTime + tapJudgeTime[judgeInt])
                {
                    Judge(judgeEnum, laneEnum, noteNum);
                    return;
                }
            }
        }
    }
Example #4
0
 void SongPlaying()
 {
     for (LaneEnum laneEnum = LaneEnum.right; laneEnum != LaneEnum.none; laneEnum++)
     {
         int laneInt = (int)laneEnum;
         NoteSpawn(laneEnum);
         if (autoPlay[laneInt] && noteInstDatas[laneInt].Count > 0)
         {
             AutoPlay(laneEnum);
         }
         for (int noteNum = 0; noteNum != noteInstDatas[laneInt].Count; noteNum++)
         {
             NoteMove(laneEnum, noteNum);
             if (noteInstDatas[laneInt][noteNum].holdJudge)
             {
                 if (HoldJudgeCheck(laneEnum, noteNum))
                 {
                     noteNum--;
                 }
             }
             else
             {
                 if (MissJudgeCheck(laneEnum, noteNum))
                 {
                     noteNum--;
                 }
             }
         }
     }
     songPlayingTime += Time.fixedDeltaTime;
     if (songAudio.time == 0 && !songAudio.isPlaying)
     {
         GameClear();
     }
 }
Example #5
0
    /////////////////////////////////////////////

    //タッチ関連 関数////////////////////////////
    void TouchCheck()
    {
        for (int touchNum = 0; touchNum < Input.touchCount; touchNum++)
        {
            Touch      touch      = Input.GetTouch(touchNum);
            Vector3    touchPos   = touch.position;
            int        fingerId   = touch.fingerId;
            TouchPhase touchPhase = touch.phase;
            if (touchPhase == TouchPhase.Began)
            {
                TouchDown(touchPos, fingerId);
            }
            for (LaneEnum laneEnum = LaneEnum.right; laneEnum != LaneEnum.none; laneEnum++)
            {
                int laneInt = (int)laneEnum;
                if (fingerId == touchHoldFingerId[laneInt])
                {
                    if (touchPhase == TouchPhase.Moved || touchPhase == TouchPhase.Stationary)
                    {
                        TouchHold(laneEnum, touchPos);
                    }
                    if (touchPhase == TouchPhase.Ended || touchPhase == TouchPhase.Canceled)
                    {
                        TouchUp(laneEnum);
                    }
                }
            }
        }
    }
Example #6
0
    void NoteMoveA(LaneEnum laneEnum, int noteNum, float songTime)
    {
        int      laneInt      = (int)laneEnum;
        NoteData tempNoteData = noteDatas[laneInt][noteSpawnCount[laneInt]];
        Vector3  movePos      = (transform.up + transform.forward) * noteInstDatas[laneInt][noteNum].noteSpeed * Time.deltaTime;

        noteInstDatas[laneInt][noteNum].noteInst.transform.position -= movePos;
    }
Example #7
0
    void TouchUp(LaneEnum laneEnum)
    {
        int laneInt = (int)laneEnum;

        lift[laneInt].gameObject.SetActive(false);
        liftLine[laneInt].gameObject.SetActive(false);
        touchHold[laneInt]         = false;
        touchHoldFingerId[laneInt] = -1;
        Debug.Log("TouchUp");
    }
Example #8
0
    bool MissJudgeCheck(LaneEnum laneEnum, int noteNum)
    {
        int   laneInt = (int)laneEnum;
        float notePerfectJudgeTime = noteInstDatas[laneInt][noteNum].notePerfectJudgeTime;

        if (songPlayingTime > notePerfectJudgeTime + tapJudgeTime[(int)JudgeEnum.bad])
        {
            Judge(JudgeEnum.miss, laneEnum, noteNum);
            return(true);
        }
        return(false);
    }
Example #9
0
    void AutoPlayA(LaneEnum laneEnum, float songTime)
    {
        int   laneInt = (int)laneEnum;
        int   noteNum = 0;
        float notePerfectJudgeTime = noteInstDatas[laneInt][noteNum].notePerfectJudgeTime;

        //if (songPlayingTime >= notePerfectJudgeTime) Judge(JudgeEnum.perfect, laneEnum, noteNum);
        if (songTime >= notePerfectJudgeTime)
        {
            TapJudgeCheck(laneEnum, noteNum);
        }
    }
Example #10
0
    void TouchHold(LaneEnum laneEnum, Vector3 touchPos)
    {
        int laneInt = (int)laneEnum;

        touchPos.z -= cam.transform.position.z;
        Vector3 touchWorldPos = cam.ScreenToWorldPoint(touchPos);
        float   liftPosX      = touchWorldPos.x;

        liftPosX = liftPosX >= liftPosRest[laneInt].x ? liftPosX : liftPosRest[laneInt].x;
        liftPosX = liftPosX < liftPosRest[laneInt].y ? liftPosX : liftPosRest[laneInt].y;
        lift[laneInt].transform.position     = transform.right * liftPosX;
        liftLine[laneInt].transform.position = transform.right * liftPosX + liftLineBasicPos;
    }
Example #11
0
 void Start()
 {
     //仮実装////////////////////
     //SelectSceneManagerが完成したらAwake関数に移動//////////
     for (LaneEnum laneEnum = LaneEnum.right; laneEnum != LaneEnum.none; laneEnum++)
     {
         int laneInt = (int)laneEnum;
         lift[laneInt].GetComponent <SpriteRenderer>().color     = SelectSceneManager.liftColor;
         liftLine[laneInt].GetComponent <SpriteRenderer>().color = SelectSceneManager.liftLineColor;
     }
     songAudio.clip = (AudioClip)Resources.Load("SongFile/" + SelectSceneManager.selectSongFileString + "/Song");
     NoteDataRead(SelectSceneManager.selectSongFileString);
     /////////////////////////////////////////////////////////
     ///////////////////////////
 }
Example #12
0
        private void Update()
        {
#if UNITY_EDITOR
            if (EventSystem.current.IsPointerOverGameObject())
            {
                return;
            }
#else
            if (EventSystem.current.IsPointerOverGameObject(0))
            {
                return;
            }
#endif
            if (Input.GetMouseButtonDown(0))
            {
                ray = camera.ScreenPointToRay(Input.mousePosition);
                Physics.Raycast(ray, out hit);

                if (hit.transform is null)
                {
                    return;
                }

                if (hit.transform.TryGetComponent <ISelectable>(out var _selectable))
                {
                    if (selectable != null && selectable == _selectable)
                    {
                        selectable.Deselect();
                        selectable = null;
                        return;
                    }
                    selectable?.Deselect();
                    selectable = _selectable;
                    selectable.OnClick();
                }
                else if (selectable != null && hit.transform.TryGetComponent(out laneEnum))
                {
                    selectable.MoveTo(laneEnum.value, () =>
                    {
                        selectable = null;
                        laneEnum   = null;
                    });
                }
            }
        }
Example #13
0
 void TouchDown(Vector3 touchPos, int fingerID)
 {
     if (touchPos.y < halfScreenPos.y)
     {
         LaneEnum laneEnum = touchPos.x >= halfScreenPos.x ? LaneEnum.right : LaneEnum.left;
         int      laneInt  = (int)laneEnum;
         TouchHold(laneEnum, touchPos);
         lift[laneInt].gameObject.SetActive(true);
         liftLine[laneInt].gameObject.SetActive(true);
         touchHold[laneInt]         = true;
         touchHoldFingerId[laneInt] = fingerID;
         if (noteInstDatas[laneInt].Count > 0)
         {
             TapJudgeCheck(laneEnum, 0);
         }
         Debug.Log("TouchDown");
     }
 }
Example #14
0
    /////////////////////////////////////////////

    //判定関連 関数//////////////////////////////
    void Judge(JudgeEnum judgeEnum, LaneEnum laneEnum, int noteNum)
    {
        int judgeInt = (int)judgeEnum;
        int laneInt  = (int)laneEnum;
        int feverInt = (int)noteInstDatas[laneInt][noteNum].feverEnum;

        judgeCount++;
        judge[judgeInt]++;
        JudgeTextUpdate(judgeEnum);
        if (judgeEnum == JudgeEnum.perfect || judgeEnum == JudgeEnum.great || judgeEnum == JudgeEnum.good)
        {
            int                       tempJudgeCoef        = judgeCoef[judgeInt];
            int                       tempFeverCoef        = feverCoef[feverInt];
            float                     tempHealth           = nowHealth + tempJudgeCoef * tempFeverCoef * SelectSceneManager.musicDatas[SelectSceneManager.selectSongFileInt].heel;
            Vector3                   noteParticlePos      = noteInstDatas[laneInt][noteNum].noteInst.transform.position;
            Color                     noteParticleColor    = noteInstDatas[laneInt][noteNum].noteColor;
            ParticleSystem            noteParticleInst     = Instantiate(noteParticlePrefab, noteParticlePos, Quaternion.identity);
            ParticleSystem.MainModule noteParticleInstMain = noteParticleInst.main;
            noteParticleInstMain.startColor = noteParticleColor;
            noteParticleInst.Play();
            judgeAudio.PlayOneShot(judgeClip);
            nowCombo++;
            maxCombo  = Mathf.Max(maxCombo, nowCombo);
            score    += tempJudgeCoef * tempFeverCoef * Mathf.Sqrt(nowCombo) * Mathf.Sqrt(SelectSceneManager.musicDatas[SelectSceneManager.selectSongFileInt].difficulty) * 10.0f;
            nowHealth = tempHealth <= maxHealth ? tempHealth : maxHealth;
            ScoreTextUpdate();
            ComboTextUpdate();
        }
        else if (judgeEnum == JudgeEnum.bad || judgeEnum == JudgeEnum.miss)
        {
            int   tempFeverCoef = feverCoef[feverInt];
            float tempHealth    = nowHealth - tempFeverCoef * SelectSceneManager.musicDatas[SelectSceneManager.selectSongFileInt].damage;
            nowCombo  = 0;
            nowHealth = tempHealth >= 0 ? tempHealth : 0;
            if (nowHealth == 0)
            {
                GameOver();
            }
        }
        HealthTextUpdate();
        HealthSliderImageUpdate();
        Destroy(noteInstDatas[laneInt][noteNum].noteInst.gameObject);
        noteInstDatas[laneInt].RemoveAt(noteNum);
    }
Example #15
0
    void Update()
    {
        //FPS計測
        float fps = 1f / Time.deltaTime;

        fpsText.text = "FPS:" + fps.ToString("F0");
        if (songPlaying)
        {
            if (firstSongPlayingUpdate)
            {
                songPlayingUpdateTime += songPlayingTime;
                firstSongPlayingUpdate = false;
            }
            else
            {
                songPlayingUpdateTime += Time.deltaTime;
            }
        }
        TouchCheck();
        if (judgeTextFadeOut)
        {
            judgeTextFadeOut = TextFadeOut(judgeTextCanvasGroup);
        }
        if (comboTextFadeOut)
        {
            comboTextFadeOut = TextFadeOut(comboTextCanvasGroup);
        }
        //PC判定確認用
        if (Input.GetKeyDown(KeyCode.F) || Input.GetKeyDown(KeyCode.J))
        {
            tapJudgePosX = 10.0f;
            for (LaneEnum laneEnum = LaneEnum.right; laneEnum != LaneEnum.none; laneEnum++)
            {
                int laneInt = (int)laneEnum;
                if (noteInstDatas[laneInt].Count > 0)
                {
                    TapJudgeCheck(laneEnum, 0);
                }
            }
            tapJudgePosX = 1.5f;
        }
    }
Example #16
0
    void NoteSpawnA(LaneEnum laneEnum, float songTime)
    {
        int laneInt = (int)laneEnum;

        if (!noteSpawnEnd[laneInt] && noteDatas[laneInt][noteSpawnCount[laneInt]].noteSpawnTime <= songTime)
        {
            NoteData tempNoteData = noteDatas[laneInt][noteSpawnCount[laneInt]];
            float    noteGapPos   = -(songTime - tempNoteData.noteSpawnTime) * tempNoteData.noteSpeed;
            Vector3  notePos      = noteBasicPos[laneInt] + new Vector3(tempNoteData.noteSpawnPosX, noteGapPos, noteGapPos);
            Vector3  noteRot      = new Vector3(45.0f, 0.0f, 0.0f);
            Color    noteColor    = tempNoteData.noteColor;
            tempNoteData.noteInst = Instantiate(notePrefab, notePos, Quaternion.Euler(noteRot));
            tempNoteData.noteInst.GetComponent <SpriteRenderer>().color = noteColor;
            noteInstDatas[laneInt].Add(tempNoteData);
            noteInstDatas[laneInt].Sort(NotePerfectJudgeTimeCompare);
            noteSpawnCount[laneInt]++;
            if (noteSpawnCount[laneInt] == noteDatas[laneInt].Count)
            {
                noteSpawnEnd[laneInt] = true;
            }
        }
    }
Example #17
0
    // -----    .Five.    -------------------
    // -----    .Four.    -------------------
    // -----    .Three.   -------------------
    // -----    .Two.     -------------------
    // -----    .One.     -------------------
    public static float GetPosition(this LaneEnum rawValue)
    {
        switch (rawValue)
        {
        case LaneEnum.One:
            return(-2.5f);

        case LaneEnum.Two:
            return(-1.5f);

        case LaneEnum.Three:
            return(0);

        case LaneEnum.Four:
            return(1.5f);

        case LaneEnum.Five:
            return(2.5f);

        default:
            return(-1.5f);
        }
    }
Example #18
0
    /////////////////////////////////////////////

    //ノーツ関連 関数////////////////////////////
    void NoteDataRead(string songFileString)
    {
        string[] noteDataRead = ((TextAsset)Resources.Load("SongFile/" + songFileString + "/NoteData")).text.Split('\n');
        float    bpm          = SelectSceneManager.musicDatas[SelectSceneManager.selectSongFileInt].basicBpm;
        float    noteSpeed    = 1.0f;

        float[] notePerfectJudgeTime = new float[2]
        {
            SelectSceneManager.musicDatas[SelectSceneManager.selectSongFileInt].offset + SelectSceneManager.judgeGapTime,
            SelectSceneManager.musicDatas[SelectSceneManager.selectSongFileInt].offset + SelectSceneManager.judgeGapTime
        };
        FeverEnum feverEnum        = FeverEnum.no;
        int       noteDataReadLine = 0;

        while (noteDataReadLine != noteDataRead.Length)
        {
            //コマンド読み取り
            string[] commandRead     = noteDataRead[noteDataReadLine++].Split('/');
            int      commandReadLine = 0;
            while (commandReadLine != commandRead.Length)
            {
                switch (commandRead[commandReadLine++])
                {
                case "bpm":
                    bpm = float.Parse(commandRead[commandReadLine++]);
                    break;

                case "speed":
                    noteSpeed = float.Parse(commandRead[commandReadLine++]);
                    break;

                case "fever":
                    switch (commandRead[commandReadLine++][0])
                    {
                    case '0':
                        feverEnum = FeverEnum.no;
                        break;

                    case '1':
                        feverEnum = FeverEnum.yes;
                        break;
                    }
                    break;

                case "comment":
                    commandReadLine++;
                    break;
                }
            }
            //ノーツ配置読み取り
            for (LaneEnum laneEnum = LaneEnum.right; laneEnum != LaneEnum.none; laneEnum++)
            {
                int      laneInt     = (int)laneEnum;
                string[] notePosRead = noteDataRead[noteDataReadLine++].Split('/');
                for (int notePosReadLine = 0; notePosReadLine != notePosRead.Length; notePosReadLine++)
                {
                    if (notePosRead[notePosReadLine][0] != '*')
                    {
                        noteDatas[(int)laneEnum].Add
                        (
                            new NoteData()
                        {
                            noteSpeed            = SelectSceneManager.noteBasicSpeed * noteSpeed,
                            notePerfectJudgeTime = notePerfectJudgeTime[laneInt],
                            noteSpawnTime        = notePerfectJudgeTime[laneInt] - noteBasicPos[laneInt].y / (SelectSceneManager.noteBasicSpeed * noteSpeed),
                            noteSpawnPosX        = float.Parse(notePosRead[notePosReadLine]),
                            noteColor            = SelectSceneManager.noteColor[(int)feverEnum],
                            feverEnum            = feverEnum,
                            laneEnum             = laneEnum
                        }
                        );
                    }
                    notePerfectJudgeTime[laneInt] += (60.0f / bpm) * (4.0f / notePosRead.Length);
                }
            }
        }
        noteDatas[(int)LaneEnum.right].Sort(NoteSpawnTimeCompare);
        noteDatas[(int)LaneEnum.left].Sort(NoteSpawnTimeCompare);
    }