Beispiel #1
0
    public void AddScore()
    {
        CurrentScore++;
        OnScoreChanged?.Invoke(Mathf.Min(CurrentScore, MaxScore), MaxScore);

        if (CurrentScore >= MaxScore)
        {
            FinishGame();
        }
    }
Beispiel #2
0
    public bool CheckIfNewHighscore()
    {
        bool newHighScore = GetHighscore() < currentScore;

        if (newHighScore)
        {
            NewHighscore?.Invoke(currentScore);
        }

        return(newHighScore);
    }
 public void Accept()
 {
     _store.Score += _store.CurrentCard.AcceptValue;
     _onScoreChange?.Invoke(_store.Score);
 }
Beispiel #4
0
 public void IncrementScore()
 {
     Score++;
     onScore.Invoke(Score);
 }
Beispiel #5
0
 public void GainScore(int amount)
 {
     scoreData.newScore += amount;
     OnScoreSet.Invoke(this);
 }
Beispiel #6
0
        private void checkInputDirection()
        {
            if (Input.GetButtonDown(player.playerButtons.horizontal) || Input.GetButtonDown(player.playerButtons.vertical))
            {
                if (sequence.ArrowQueue.Count > 0)
                {
                    float     distance = Mathf.Abs(this.transform.position.y - sequence.ArrowQueue.Peek().transform.position.y);
                    ScoreType score;
                    if (Input.GetAxisRaw(player.playerButtons.horizontal) == 1 && sequence.peekArrowScript.direction == Direction.right ||
                        Input.GetAxisRaw(player.playerButtons.vertical) == -1 && sequence.peekArrowScript.direction == Direction.down ||
                        Input.GetAxisRaw(player.playerButtons.horizontal) == -1 && sequence.peekArrowScript.direction == Direction.left ||
                        Input.GetAxisRaw(player.playerButtons.vertical) == 1 && sequence.peekArrowScript.direction == Direction.up)
                    {
                        score = CalculateScore(distance);

                        sequence.peekArrowScript.clicked = true;
                        consecutiveHits++;

                        if (consecutiveHits > 9)
                        {
                            streakText.text = consecutiveHits.ToString();
                            if (consecutiveHits == 10)
                            {
                                streakText.transform.position = TextPos - Vector3.up * 0.2f;
                                streakText.GetComponent <RectTransform>().DOMoveY(TextPos.y, 0.3f);
                                streakText.DOFade(0, 0f);
                                streakText.DOFade(1, 0.3f);
                            }
                            else
                            {
                                streakText.GetComponent <RectTransform>().DOScale(streakText.font.faceInfo.scale * 1.2f, 0.15f);
                                streakText.GetComponent <RectTransform>().DOScale(streakText.font.faceInfo.scale / 1.2f, 0.15f);
                            }
                            if (consecutiveHits == 30)
                            {
                                Color[] clr = new Color[4];
                                ColorUtility.TryParseHtmlString("#E7DC00FF", out clr[0]);
                                ColorUtility.TryParseHtmlString("#FAF9B2FF", out clr[1]);
                                ColorUtility.TryParseHtmlString("#FFEC00FF", out clr[2]);
                                ColorUtility.TryParseHtmlString("#A14811FF", out clr[3]);
                                TMP_ColorGradient grd = ScriptableObject.CreateInstance("TMP_ColorGradient") as TMP_ColorGradient;
                                grd.topLeft     = clr[0];
                                grd.topRight    = clr[1];
                                grd.bottomLeft  = clr[2];
                                grd.bottomRight = clr[3];
                                streakText.colorGradientPreset = grd;
                            }
                            if (consecutiveHits == 50)
                            {
                                Color[] clr = new Color[4];
                                ColorUtility.TryParseHtmlString("#36AB14FF", out clr[0]);
                                ColorUtility.TryParseHtmlString("#FFFB00FF", out clr[1]);
                                ColorUtility.TryParseHtmlString("#46FF00FF", out clr[2]);
                                ColorUtility.TryParseHtmlString("#023F2CFF", out clr[3]);
                                TMP_ColorGradient grd = ScriptableObject.CreateInstance("TMP_ColorGradient") as TMP_ColorGradient;
                                grd.topLeft     = clr[0];
                                grd.topRight    = clr[1];
                                grd.bottomLeft  = clr[2];
                                grd.bottomRight = clr[3];
                                streakText.colorGradientPreset = grd;
                            }
                        }

                        //Animacao
                        transform.parent.GetComponentInChildren <Animator>().SetInteger("consecutiveHits", consecutiveHits);
                        transform.parent.GetComponentInChildren <Animator>().SetBool("failed", false);
                        transform.parent.GetChild(0).GetChild(0).GetComponentInChildren <Animator>().SetInteger("consecutiveHits", consecutiveHits);
                        transform.parent.GetChild(0).GetChild(0).GetComponentInChildren <Animator>().SetBool("failed", false);
                    }
                    else
                    {
                        streakText.colorGradientPreset = FirstStreakColor;
                        FailArrow();
                        Debug.Log("Wrong Arrow!");
                        score = ScoreType.wrongArrow;

                        streakText.GetComponent <RectTransform>().DOScale(streakText.rectTransform.localScale * 1.2f, 0.1f);
                        //streakText.GetComponent<RectTransform>().DOScale(0, 0.2f);
                        streakText.DOFade(0, 0.2f);
                        streakText.GetComponent <RectTransform>().localScale = Vector3.one;
                        streakText.GetComponent <RectTransform>().DOScale(Vector3.one, 0f);
                        streakText.transform.position = TextPos;
                        //streakText.text = "";
                        //Animacao
                        consecutiveHits = 0;
                        transform.parent.GetComponentInChildren <Animator>().SetInteger("consecutiveHits", consecutiveHits);
                        transform.parent.GetComponentInChildren <Animator>().SetBool("failed", true);
                        transform.parent.GetChild(0).GetChild(0).GetComponentInChildren <Animator>().SetInteger("consecutiveHits", consecutiveHits);
                        transform.parent.GetChild(0).GetChild(0).GetComponentInChildren <Animator>().SetBool("failed", true);
                    }

                    //InstantiateScoreText(score);
                    onScoreChange.Invoke(score);
                }
            }
        }
Beispiel #7
0
 public void ResetScore()
 {
     leftScore  = 0;
     rightScore = 0;
     onScore.Invoke(leftScore, rightScore);
 }
Beispiel #8
0
 public void AddToScore(int value)
 {
     currentScore += value;
     NewScore?.Invoke(currentScore);
     // OnNewScore.Invoke(currentScore);
 }