Exemplo n.º 1
0
        public override ENoteGrade OnTick( )
        {
            ENoteGrade grade = ENoteGrade.UNKNOWN;

            if (!Note.IsRendering && Note.Info.startTime - NoR2252Application.PreLoad <= NoR2252Application.VideoTime)
            {
                Note.IsRendering = true;
                Note.View.OnSpawn( );
            }
            Note.View.Render( );

            //if not being touch and time is over the startTime then recycle self and set grade to miss
            if (!bHolding && NoR2252Application.VideoTime >= Note.Info.startTime + NoR2252Data.Instance.TimeGrade [(int)ENoteGrade.MISS] && !bGetResult)
            {
                grade = ENoteGrade.MISS;
                GetResult(grade);
            }
            //if player keep hold this note until note end time recycle it and plus a perfect point by call PlusPoint
            if (!bGetResult && NoR2252Application.VideoTime >= Note.Info.endTime)
            {
                grade = bHolding?ENoteGrade.PERFECT : ENoteGrade.MISS;
                Note.Controller.PlusPoint(grade);
                GetResult(grade);
            }
            return(grade);
        }
Exemplo n.º 2
0
        /// <summary>return the grade due to the time offset</summary>
        /// <param name="factor">multiply the factor to TimeGrade if factor less than one the judge is stricker else looser</param>
        protected ENoteGrade GetGrade(float timeOffset, float factor = 1f)
        {
            ENoteGrade grade = ENoteGrade.UNKNOWN;

            if (timeOffset < NoR2252Data.Instance.TimeGrade [(int)ENoteGrade.PERFECT] * factor)
            {
                grade = ENoteGrade.PERFECT;
            }
            else if (timeOffset < NoR2252Data.Instance.TimeGrade [(int)ENoteGrade.GREAT] * factor)
            {
                grade = ENoteGrade.GREAT;
            }
            else if (timeOffset < NoR2252Data.Instance.TimeGrade [(int)ENoteGrade.GOOD] * factor)
            {
                grade = ENoteGrade.GOOD;
            }
            else if (timeOffset < NoR2252Data.Instance.TimeGrade [(int)ENoteGrade.BAD] * factor)
            {
                grade = ENoteGrade.BAD;
            }
            else if (timeOffset < NoR2252Data.Instance.TimeGrade [(int)ENoteGrade.MISS] * factor)
            {
                grade = ENoteGrade.MISS;
            }
            return(grade);
        }
Exemplo n.º 3
0
    //FingerSet
    //react with the gameNote which type is HOLD or SLIDE-CHILD
    void FingerSet(LeanFinger finger)
    {
        Vector2 pos = Camera.main.ScreenToWorldPoint(finger.ScreenPosition);

        foreach (GameNote note in gameNotes)
        {
            if (note.IsRendering && (note.Info.type == (int)ENoteType.SLIDE_CHILD || note.Info.type == (int)ENoteType.HOLD) && note.IsCollide(pos))
            {
                ENoteGrade grade = note.OnTouch(EFingerAction.SET, finger.Index);
                CountScore(grade);
                //if type is SLIDE-CHILD update the fingerIndex information
                if (note.Info.type == (int)ENoteType.SLIDE_CHILD)
                {
                    if ((int)grade <= (int)ENoteGrade.GOOD)
                    {
                        audio.Play( );
                        slideFinger [finger.Index] = note.Info.nextId;
                    }
                    else if ((int)grade > (int)ENoteGrade.GOOD && grade != ENoteGrade.UNKNOWN)
                    {
                        audio.Play( );
                        slideFinger [finger.Index] = 0;
                    }
                }
            }
        }
    }
Exemplo n.º 4
0
        public override ENoteGrade OnTouch(EFingerAction action, int fingerId)
        {
            if (bGetResult)
            {
                return(ENoteGrade.UNKNOWN);
            }
            ENoteGrade grade = ENoteGrade.UNKNOWN;

            if (NoR2252Application.VideoTime <= Note.Info.endTime - NoR2252Data.Instance.TimeGrade [(int)ENoteGrade.MISS])
            {
                return(grade);
            }
            float offset = Mathf.Abs(NoR2252Application.VideoTime - Note.Info.endTime);

            //give the grade a factor make it much easier
            grade = GetGrade(offset, NoR2252Data.Instance.SlideChildGradeFactor);
            //if fingerID exist check if the same finger with pre note of slide
            if (Note.Controller.SlideFinger.ContainsKey(fingerId))
            {
                if (Note.Controller.SlideFinger [fingerId] != Note.Info.id)
                {
                    grade = ENoteGrade.MISS;
                }
            }
            //if its a new finger got miss grade
            else
            {
                grade = ENoteGrade.MISS;
            }
            GetResult(grade);
            return(grade);
        }
Exemplo n.º 5
0
 public virtual void OnClear(ENoteGrade grade)
 {
     if (grade != ENoteGrade.UNKNOWN && !bClearing)
     {
         timer.Reset(clearTime);
         resultText = Note.ResultTextController.SetResult(grade, Note.transform.position);
     }
 }
Exemplo n.º 6
0
 public override void OnClear(ENoteGrade grade)
 {
     base.OnClear(grade);
     if (grade != ENoteGrade.UNKNOWN && !bClearing)
     {
         VRef.lineAnimator.SetTrigger("FadeOut");
         VRef.lineRenderer.size = new Vector2(0f, 0f);
     }
 }
Exemplo n.º 7
0
 public override void OnClear(ENoteGrade grade)
 {
     base.OnClear(grade);
     if (grade != ENoteGrade.UNKNOWN && !bClearing)
     {
         VRef.animator.SetTrigger("FadeOut");
         bClearing = true;
         if (grade == ENoteGrade.PERFECT || grade == ENoteGrade.GREAT)
         {
         }
     }
 }
Exemplo n.º 8
0
    //FingerDown
    //react with the gameNote which type is SLIDE-HEAD or HOLD
    void FingerDown(LeanFinger finger)
    {
        audio.Play( );
        Vector2 pos = Camera.main.ScreenToWorldPoint(finger.ScreenPosition);

        foreach (GameNote note in gameNotes)
        {
            if (note.IsRendering && (note.Info.type == (int)ENoteType.SLIDE_HEAD || note.Info.type == (int)ENoteType.HOLD) && note.IsCollide(pos))
            {
                ENoteGrade grade = note.OnTouch(EFingerAction.DOWN, finger.Index);
                if (grade != ENoteGrade.UNKNOWN)
                {
                    audio.Play( );
                }
                //if note == hold and got bad or miss at first
                if (note.Info.type == (int)ENoteType.HOLD && grade > ENoteGrade.GOOD)
                {
                    CountScore(grade, true);
                }
                else
                {
                    CountScore(grade);
                }
                //if successful add fingerID and nextID
                //if nextID equals to zero means got failed on SLIDE-HEAD
                if (note.Info.type == (int)ENoteType.SLIDE_HEAD)
                {
                    if ((int)grade <= (int)ENoteGrade.GOOD)
                    {
                        if (!slideFinger.ContainsKey(finger.Index))
                        {
                            slideFinger.Add(finger.Index, note.Info.nextId);
                        }
                        else
                        {
                            slideFinger [finger.Index] = note.Info.nextId;
                        }
                    }
                    else if ((int)grade > (int)ENoteGrade.GOOD && grade != ENoteGrade.UNKNOWN)
                    {
                        if (!slideFinger.ContainsKey(finger.Index))
                        {
                            slideFinger.Add(finger.Index, 0);
                        }
                        else
                        {
                            slideFinger [finger.Index] = 0;
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 9
0
 /// <summary>if this note being touch it will return the result of this touch</summary>
 /// <param name="action">which kind of touch action on this note</param>
 /// <param name="fingerId">the fingerIndex of this touch</param>
 public ENoteGrade OnTouch(EFingerAction action, int fingerId)
 {
     if (strategy != null)
     {
         ENoteGrade result = strategy.OnTouch(action, fingerId);
         return(result);
     }
     else
     {
         return(ENoteGrade.UNKNOWN);
     }
 }
Exemplo n.º 10
0
    //FingerUp
    //Only react with the gameNote which type is HOLD
    void FingerUp(LeanFinger finger)
    {
        Vector2 pos = Camera.main.ScreenToWorldPoint(finger.ScreenPosition);

        foreach (GameNote note in gameNotes)
        {
            if (note.IsRendering && note.Info.type == (int)ENoteType.HOLD && note.IsCollide(pos))
            {
                ENoteGrade grade = note.OnTouch(EFingerAction.UP, finger.Index);
                CountScore(grade);
                audio.Play( );
            }
        }
    }
Exemplo n.º 11
0
        public override ENoteGrade OnTouch(EFingerAction action, int fingerId)
        {
            ENoteGrade grade  = ENoteGrade.UNKNOWN;
            float      offset = 0f;

            //if action is down check its grade amd bJuding equals to false
            //bJudging is to prevent the sameNote being judge several times
            if (action == EFingerAction.DOWN && !bJudging)
            {
                offset = Mathf.Abs(NoR2252Application.VideoTime - Note.Info.startTime);
                grade  = GetGrade(offset);
                //if grade is miss or bad just return the result and recycle self
                if (grade == ENoteGrade.BAD || grade == ENoteGrade.MISS)
                {
                    bJudging = true;
                    GetResult(grade);
                }
                //if grade not equal to UNKNOWN MISS BAD then start holding this note
                else if (grade != ENoteGrade.UNKNOWN)
                {
                    bHolding = true;
                    bJudging = true;
                }
            }

            //if player release finger before note end time
            //give it a grade
            //if this note has bJuding about press down action and not get the result take the grade of it
            else if (action == EFingerAction.UP && bJudging && bHolding && !bGetResult)
            {
                bGetResult = true;
                bHolding   = false;
                offset     = Mathf.Abs(NoR2252Application.VideoTime - Note.Info.endTime);
                grade      = GetGrade(offset);
                if (grade == ENoteGrade.UNKNOWN)
                {
                    grade = ENoteGrade.MISS;
                }
                GetResult(grade);
            }
            //if player keep holding return UNKNOWN
            else if (action == EFingerAction.SET)
            {
                if (!bGetResult && bHolding)
                {
                    grade = ENoteGrade.UNKNOWN;
                }
            }
            return(grade);
        }
Exemplo n.º 12
0
        public override ENoteGrade OnTouch(EFingerAction action, int fingerId)
        {
            ENoteGrade grade = ENoteGrade.UNKNOWN;

            //if current video time is in the judge time range or not
            if (NoR2252Application.VideoTime <= Note.Info.endTime - NoR2252Data.Instance.TimeGrade [(int)ENoteGrade.MISS])
            {
                return(grade);
            }
            float offset = Mathf.Abs(NoR2252Application.VideoTime - Note.Info.endTime);

            grade = GetGrade(offset);
            GetResult(grade);
            return(grade);
        }
Exemplo n.º 13
0
    public TextAndAnim SetResult(ENoteGrade grade, Vector2 pos)
    {
        //find not using
        foreach (TextAndAnim t in texts)
        {
            if (!t.IsActive)
            {
                t.text.text = grade.ToString( );
                Vector2 p = main.WorldToScreenPoint(pos);
                t.text.rectTransform.anchoredPosition = p;
                t.IsActive = true;
                t.animation.Play( );
                return(t);
            }
        }
#if (UNITY_EDITOR)
        Debug.Log("can't get result text");
#endif
        return(null);
    }
Exemplo n.º 14
0
 //calculate the score and combo due to the grade
 //if bHoldingHeadMiss set to true plus one more miss grade to NoR2252Application
 //Because if player miss the first tap of Hold note.Player won't get chance to tap the end of hold note
 void CountScore(ENoteGrade grade, bool bHoldingHeadMiss = false)
 {
     if (grade != ENoteGrade.UNKNOWN)
     {
         NoR2252Application.NoteGrade [(int)grade]++;
         if (bHoldingHeadMiss)
         {
             NoR2252Application.NoteGrade [(int)grade]++;
         }
         score += NoR2252Data.Instance.Points [(int)grade];
         combo++;
     }
     if (grade == ENoteGrade.BAD || grade == ENoteGrade.MISS)
     {
         bComboing = false;
         combo     = 0;
     }
     if (combo > NoR2252Application.MaxCombo)
     {
         NoR2252Application.MaxCombo = combo;
     }
 }
Exemplo n.º 15
0
 //Keep update all gameNote on the scene
 //if the note is using
 void UpdateAllGameNote( )
 {
     foreach (GameNote note in gameNotes)
     {
         ENoteGrade grade = ENoteGrade.UNKNOWN;
         //if the note is over its life time will return MISS
         if (note.IsUsing)
         {
             grade = note.Tick( );
         }
         //transfer the grade and count the score if player doesn't press the note and note type should not be hold
         //if note type is hold set holding miss the first tap to true
         if (grade == ENoteGrade.MISS && note.Info.type != (int)ENoteType.HOLD)
         {
             CountScore(grade);
         }
         else if (grade == ENoteGrade.MISS && note.Info.type == (int)ENoteType.HOLD)
         {
             CountScore(grade, true);
         }
     }
 }
Exemplo n.º 16
0
        public override ENoteGrade OnTick( )
        {
            ENoteGrade grade = ENoteGrade.UNKNOWN;

            //decide to show according to the video time and note start time
            if (!Note.IsRendering && Note.Info.startTime - NoR2252Application.PreLoad <= NoR2252Application.VideoTime)
            {
                Note.IsRendering = true;
                Note.View.OnSpawn( );
            }
            if (Note.IsRendering)
            {
                Note.View.Render( );
            }
            //if video time is over the judge time recycle self and set result to miss
            if (!bGetResult && NoR2252Application.VideoTime >= Note.Info.endTime + NoR2252Data.Instance.TimeGrade [(int)ENoteGrade.MISS])
            {
                grade = ENoteGrade.MISS;
                GetResult(grade);
            }
            return(grade);
        }
Exemplo n.º 17
0
 /// <summary>Call this method to get more point</summary>
 /// <remarks>its for hold finished</remarks>
 public void PlusPoint(ENoteGrade grade)
 {
     CountScore(grade);
 }
Exemplo n.º 18
0
 /// <summary>define the action after got the grade</summary>
 protected void GetResult(ENoteGrade grade)
 {
     bGetResult = true;
     Note.View.OnClear(grade);
 }