Example #1
0
    private void RegisterPoint(Block block)
    {
        if (block == null)
        {
            Debug.Break();
        }
        int scoreToAdd = block.Points;

        if (_previousBlockTypeHit == BlockType.Proppeler)
        {
            // bonus if you hit the first time: 100%
            scoreToAdd = (scoreToAdd * 2);

            // bonus points based on distance from proppeler to sphere
            // the bigger the better
            var distance     = Vector3.Distance(_previousHitPoint, _currentHitPoint);
            var percentToHit = UsefullUtils.GetValuePercent(distance, _maxPossibleDistance);

            float bonusDistancePoints;
            if (percentToHit > 40)  // bigger value decreases points
            {
                // bonus points based on distance from a contact point to proppeler
                // the smaller the better
                distance = Vector3.Distance(_pastPreviousHitPoint, _previousHitPoint);
                var percentToProppeler = UsefullUtils.GetValuePercent(distance, _maxPossibleDistance);
                percentToProppeler = percentToHit - percentToProppeler;

                bonusDistancePoints = UsefullUtils.GetPercent(scoreToAdd, percentToProppeler);
                scoreToAdd         += (int)Mathf.Ceil(bonusDistancePoints);
            }

            bonusDistancePoints = UsefullUtils.GetPercent(scoreToAdd, percentToHit);
            scoreToAdd         += (int)Mathf.Ceil(bonusDistancePoints);


            // score is a bit high, so lets trim it down a bit.
            //
            // WE CAN REMOVE THIS LATER
            //
            //var percentToDecrease =
            scoreToAdd = (int)Mathf.Ceil(UsefullUtils.GetPercent(scoreToAdd, 60));

            Score += scoreToAdd;
        }
        else
        {
            Score += scoreToAdd;
        }

        ScoreText.text = Score.ToString();
        Game.Instance.CanvasController.ShowcasePoints(scoreToAdd, _currentHitPoint);
    }
Example #2
0
    public void StopRecording()
    {
        _fullElapsedTime = DateTime.Now - _fullStartTime;

        float fullTime = 0;

        ReplayOptions.ForEach(rp => fullTime += rp.Seconds);

        PercentOffset = Mathf.Floor(UsefullUtils.GetValuePercent(_fullElapsedTime.Seconds, fullTime));

        _startRecord = false;
        Game.Instance.Ball.CanStopRecording = false;

        PlayRecordButton.interactable = true;
    }
 private float GetCarretPositionPercent(float heightOfCarretFromTopOfPage)
 {
     // Debug.Log("heightOfCarretFromTopOfPage: " + heightOfCarretFromTopOfPage);
     // Debug.Log("Content.sizeDelta.y: " + Content.sizeDelta.y);
     return(UsefullUtils.GetValuePercent(heightOfCarretFromTopOfPage, Content.sizeDelta.y));
 }