Beispiel #1
0
    protected virtual void Score(int s, Vector2?pos = null, bool flashBottom = true, int sndIdx = 0)
    {
        int    _score;
        string _text;
        Color  _color;

        switch (s)
        {
        default:
            _score = badScore;
            _text  = "Miss";
            _color = Color.grey;
            ++Scoring.missCount;
            break;

        case 1:
            _score = goodScore;
            _text  = "Good";
            _color = Color.red;    //green
            ++Scoring.goodCount;
            break;

        case 2:
            _score = perfectScore;
            _text  = "Perfect";
            _color = Color.yellow;
            ++Scoring.perfectCount;
            break;
        }
        RhythmGameManager.UpdateScore(_score);
        lastScorePos = pos == null?GetExit().center : pos.Value;

        if (coloringParts.Length > 0 && !noAnim && s >= 1)
        {
            BlockEnlarge.Create(noteImages[sndIdx], _color, lastScorePos.Value, lastScorePos.Value + new Vector2(panel == PanelType.Left ? BlockSize.x : -BlockSize.x, BlockSize.y), rt.parent);
        }

        if (s >= 1)
        {
            if (sound.Length > 0 && allScores.Count == 0 && s == 1)
            {
                sound[0].Play(1);                                                     // 按到good时声效不会按时播放
            }
            if (flashBottom && coloringParts.Length > 0)
            {
                Bottom.SetColor(panel, coloringParts[0].color * 0.75f);                                          // 底边变色
            }
        }
        else
        {
            if (sound.Length > 0 && allScores.Count == 0)
            {
                sound[0].Play(0);                                           // 按到miss时声效不会按时播放
            }
            FlyingText.Create(_text, _color, lastScorePos.Value, rt.parent);
        }
        allScores.Add(new ScoreRecord(Time.time - createTime, s));
        OnScored?.Invoke(s);
    }