Exemple #1
0
    public void Restart()
    {
        CurrentScore = 0;
        OnScoreChange?.Invoke(CurrentScore);

        isNewHigh = false;
    }
Exemple #2
0
    private void OnBulletHitPlayer(int score)
    {
        playerScore += score;
        OnScoreChange?.Invoke(score);

        // UnityEngine.Debug.Log("SCORE: " + playerScore);
    }
 private void onScoreChanges()
 {
     if (OnScoreChange != null)
     {
         OnScoreChange.Invoke();
     }
 }
Exemple #4
0
 public void AddScore(int increase)
 {
     if (increase >= 0)
     {
         currentScore += increase;
         OnScoreChange.Invoke();
     }
 }
Exemple #5
0
 public void SubtractScore(double value)
 {
     score -= value;
     if (OnScoreChange != null)
     {
         OnScoreChange.Invoke();
     }
 }
Exemple #6
0
 public void AddScore(double value)
 {
     score += value;
     if (OnScoreChange != null)
     {
         OnScoreChange.Invoke();
     }
 }
Exemple #7
0
 public void SetScore(double newScore)
 {
     score = newScore;
     if (OnScoreChange != null)
     {
         OnScoreChange.Invoke();
     }
 }
    public virtual int AddScore(int _value = 1)
    {
        score += _value;

        OnScoreChange?.Invoke(score);

        return(score);
    }
Exemple #9
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Obstacle") && !gameOver)
     {
         score++;
         OnScoreChange?.Invoke(score);
     }
 }
Exemple #10
0
        private void AddScore(LifeCycleController lifeCycleController)
        {
            lifeCycleController.OnDestroy -= AddScore;
            if (GameManager.Instance.IsFinished)
            {
                return;
            }

            Score += lifeCycleController.GetComponent <ScoreReward>().reward;
            OnScoreChange?.Invoke(Score);
        }
    private void Update()
    {
        if (maxScore < score)
        {
            maxScore = score;
        }

        OnMaxScoreChange?.Invoke(maxScore);

        OnScoreChange?.Invoke(score);
    }
Exemple #12
0
 private void GetPointForAsteroid(int value)
 {
     _score += value;
     OnScoreChange?.Invoke(_score);
     if (_score < targetPointForNewHp)
     {
         return;
     }
     _playerHealthComponent.IncreaseHealthPoint();
     targetPointForNewHp += _initTargetPoint;
 }
Exemple #13
0
    private void AddScore(int score)
    {
        this.score += score;
        OnScoreChange?.Invoke(this.score);

        if (FindObjectsOfType <Brick>().Length == 1)
        {
            OnLevelPause?.Invoke(false);
            OnLevelWin?.Invoke(level);
        }
    }
Exemple #14
0
        void AddEnemyVehicleScore(Enemies.EnemyVehicleData data, Transform enemyPosition, GameObject initiator)
        {
            // if initiator is player, count score
            // if (initiator == gameObject)
            {
                currentScore.DestroyedVehiclesAmount++;
                currentScore.ScorePoints += data.Score;

                OnScoreChange?.Invoke(currentScore);
                OnDestroyVehicle?.Invoke(enemyPosition);
            }
        }
Exemple #15
0
        void AddEnemyScore(Enemies.EnemyData data, Transform enemyPosition, GameObject initiator)
        {
            // if initiator is player, count score
            if (initiator == gameObject)
            {
                currentScore.KillsAmount++;
                currentScore.ScorePoints += data.Score;

                OnScoreChange?.Invoke(currentScore);
                OnKill?.Invoke(enemyPosition);
            }
        }
Exemple #16
0
 public void ChangeScore(int nPoints)
 {
     Score += (nPoints * _scoreMultiply);
     if (Score < 0)
     {
         ClearScore();
     }
     if (OnScoreChange != null)
     {
         OnScoreChange.Invoke();
     }
 }
Exemple #17
0
    public void SubmitPoints(int pieces)
    {
        CurrentScore += _pointsPerPiece * pieces;
        OnScoreChange?.Invoke(CurrentScore);

        if (CurrentScore > HighScore)
        {
            isNewHigh        = true;
            _highScore.Value = CurrentScore;
            OnHighScoreChange?.Invoke(CurrentScore);
        }
    }
    private void SetScore(int score)
    {
        _score = score;
        OnScoreChange?.Invoke(score);

        // TODO: Move this to when the player completes a level, or a game over is reached
        // TODO: High Score only should change when the player is done playing
        // TODO: (and then set it in Player Prefs)
        if (_score > _highScore)
        {
            _highScore = _score;
            SaveHighScore();
            OnHighScoreChange?.Invoke(_highScore);
        }
    }
Exemple #19
0
    void Update()
    {
        if (playerAlive)
        {
            currentTimer += Time.deltaTime;
            if (currentTimer >= TimeToUpdate)
            {
                AdvanceSet();
                currentTimer = 0;
            }

            Score += ScoreRate * Time.deltaTime;
            scoreChange.Invoke(System.Math.Round(Score, 2));
        }
    }
        public void RecieveArrowHit(float precision)
        {
            Judgement j = judgementMeasurements.JudgeHit(precision);

            if (OnJudgementChange != null)
            {
                OnJudgementChange.Invoke(j.name);
            }

            // Hope this works D:
            percentage += ((((float)j.amountOfJudgements - j.judgePosition) / j.amountOfJudgements) / noteData.GetNoteCount) * 100;

            if (OnScoreChange != null)
            {
                OnScoreChange.Invoke(percentage);
            }
        }
Exemple #21
0
        /// <summary>
        /// Reinit player
        /// </summary>
        /// <param name="position">where to spawn player</param>
        /// <param name="defaultVehicleSpeed">if false, speed of player's vehicle will be zero</param>
        public void Reinit(Vector3 position, bool defaultVehicleSpeed = true)
        {
            gameObject.SetActive(true);
            transform.position = position;

            Health = MaxHealth;

            // reset score
            currentScore = new GameScore(Vehicle.MaxHealth);

            // reset vehicle
            Vehicle.Reinit(!defaultVehicleSpeed);

            CameraShaker.Instance?.ResetAnimation();

            State = PlayerState.Ready;
            OnPlayerStateChange(State);

            OnScoreChange?.Invoke(currentScore);
        }
Exemple #22
0
    void OnTriggerEnter2D(Collider2D other)
    {
        switch (other.tag)
        {
        case "PointObject":
            if (OnScoreChange != null)
            {
                OnScoreChange.Invoke(1);     //When create a point object script add variable for point value
                Manager <SoundManager> .Instance.PlaySoundEffect(SoundManager.SoundEffect.Pickup);
            }
            Destroy(other.gameObject);     //When create a point object script create destroy object function to call
            break;

        case "EndLevel":
            if (OnLevelEnd != null)
            {
                OnLevelEnd.Invoke();
                Manager <SoundManager> .Instance.PlaySoundEffect(SoundManager.SoundEffect.EndLevel);
            }
            break;

        case "DestroyPlayer":
            if (OnPlayerDestroyed != null)
            {
                OnPlayerDestroyed.Invoke();
                Manager <InputManager> .Instance.OnCharacterRelease -= ReleaseCharacter;
                Manager <InputManager> .Instance.OnMoveLeft         -= MoveLeft;
                Manager <InputManager> .Instance.OnMoveRight        -= MoveRight;
                Manager <InputManager> .Instance.OnJump             -= Jump;
                Destroy(this.gameObject);
            }
            break;

        default:
            break;
        }
    }
Exemple #23
0
 private void ScoreChanged(int score)
 {
     OnScoreChange?.Invoke(score);
 }
 public void BroadcastScoreChange(Player changedPlayer, int changeBy)
 {
     OnScoreChange?.Invoke(changedPlayer, changeBy);
 }
Exemple #25
0
 public static void ReportScoreChange(int _val)
 {
     OnScoreChange?.Invoke(_val);
 }
Exemple #26
0
 // When a collectable is picked up
 // Update the score
 private void OnCollectablePickup(Collectable collectable)
 {
     Score += collectable.Score;
     OnScoreChange?.Invoke();
 }
Exemple #27
0
 // When a ghost dies, update the score
 private void OnGhostDeath()
 {
     Score += 100;
     OnScoreChange?.Invoke();
 }
Exemple #28
0
 void IncrementLvlScore(float nothing)
 {
     numberOfLvlScore++;
     OnScoreChange.Invoke(numberOfLvlScore);
 }
Exemple #29
0
 public void AddScore(int ScoreToAdd)
 {
     score += ScoreToAdd;
     OnScoreChange?.Invoke(score);
 }
Exemple #30
0
    private void CalculateNewScore()
    {
        //bool isHaveScoreLevel = false;
        ScoreData.ScoreLevel playerScoreLevel = ScoreData.ScoreLevel.Regular;

        if (perfectSlicing)
        {
            playerScoreLevel = ScoreData.ScoreLevel.Awesome;
            Debug.Log("PERFECT!");
        }
        else
        {
            //We get a list of the real sizes of all slices, determine their overall size and then modify the list so that it will contain the percentage rather than real size
            List <double> slicesInPercentage = SlicesSizesInDoubles();
            double        overallSize        = 0;

            // get overall size
            for (int i = 0; i < slicesInPercentage.Count; i++)
            {
                overallSize += slicesInPercentage[i];
            }
            // calculate the (new) percetage
            for (int i = 0; i < slicesInPercentage.Count; i++)
            {
                slicesInPercentage[i] = ((slicesInPercentage[i] / overallSize) * 100);
                Debug.Log("slicesInPercentage[i] = " + (slicesInPercentage[i]));
            }

            List <double> differences = new List <double>();
            // if fractions
            bool isFractions = (currentLevel.Cakes[currentCakeIndex].fractions != null && currentLevel.Cakes[currentCakeIndex].fractions.Length > 0);
            if (isFractions)
            {
                Fraction[]    fractions = currentLevel.Cakes[currentCakeIndex].fractions;
                List <double> slicesSupposedToBeInPercentage = new List <double>();
                for (int i = 0; i < fractions.Length; i++)
                {
                    double sliceSupposedToBeInPercentage =
                        ((double)fractions[i].numerator / (double)fractions[i].denominator) * 100;
                    Debug.Log("sliceSupposedToBeInPercentage = " + sliceSupposedToBeInPercentage);
                    slicesSupposedToBeInPercentage.Add(sliceSupposedToBeInPercentage);
                }
                //List<ScoreData.ScoreLevel> scoreLevels = new List<ScoreData.ScoreLevel>();

                foreach (double sliceSupposedToBeInPercentage in slicesSupposedToBeInPercentage)
                {
                    double difference;
                    double smallestDifference      = 100;
                    int    smallestDifferenceIndex = 0;
                    for (int i = 0; i < slicesInPercentage.Count; i++)
                    {
                        difference = Math.Abs(slicesInPercentage[i] - sliceSupposedToBeInPercentage);
                        if (difference < smallestDifference)
                        {
                            smallestDifference      = difference;
                            smallestDifferenceIndex = i;
                        }
                    }
                    Debug.Log("smallestDifference = " + smallestDifference);
                    slicesInPercentage.RemoveAt(smallestDifferenceIndex);
                    differences.Add(smallestDifference);
                    //ScoreData.ScoreLevel sliceScoreLevel = ScoreData.ScoreLevel.Regular;
                }
            }
            else
            {
                double sliceSupposedToBeInPercentage = ((1 / (double)currentLevel.Cakes[currentCakeIndex].numberOfSlices) * 100);
                Debug.Log("sliceSupposedToBeInPercentage = " + sliceSupposedToBeInPercentage);
                for (int i = 0; i < slicesInPercentage.Count; i++)
                {
                    differences.Add(Math.Abs(slicesInPercentage[i] - sliceSupposedToBeInPercentage));
                }
            }

            double differencesAverage = 0;
            for (int i = 0; i < differences.Count; i++)
            {
                differencesAverage += differences[i];
            }
            differencesAverage /= differences.Count;
            Debug.Log("differencesAverage = " + differencesAverage);

            ScoreData.ScoreLevel[] ScoreLevelArr = (ScoreData.ScoreLevel[])Enum.GetValues(typeof(ScoreData.ScoreLevel));
            foreach (ScoreData.ScoreLevel possibleScoreLevel in ScoreLevelArr)
            {
                if (possibleScoreLevel != ScoreData.ScoreLevel.Regular)//might not be nesssry
                {
                    if (differencesAverage <= (double)possibleScoreLevel)
                    {
                        playerScoreLevel = possibleScoreLevel;
                        break;
                    }
                }
            }
            //Phew....
        }

        Debug.Log(playerScoreLevel.ToString());
        int bonuslessScoreToAdd = (int)Enum.Parse(typeof(ScoreData.ScorePointsByLevel), playerScoreLevel.ToString());

        bonuslessScoreToAdd = (int)((double)bonuslessScoreToAdd * (ScoreData.NumberOfSlicesScoreNormaliser * slicesToSlice));
        int bonus = 0;

        if (playerScoreLevel == ScoreData.ScoreLevel.Awesome)
        {
            bonus = comboCounter * ScoreData.COMBO_MULTIPLIER;
            comboCounter++;
        }
        else
        {
            comboCounter = 0;
        }
        if (PowerUps.goldenKnifeIsActive)
        {
            Debug.Log("goldenKnifeIsActive, multiplyin score.");
            bonuslessScoreToAdd *= 2; //TODO: do we care whter this is hardcoded or not?
            bonus *= 2;               //TODO: do we care whter this is hardcoded or not?
        }
        OnScoreChange?.Invoke(bonuslessScoreToAdd, bonus, playerScoreLevel);
        //comboCounter = (playerScoreLevel == ScoreData.ScoreLevel.Awesome ? (comboCounter + 1) : 0);
        Debug.Log("comboCounter = " + comboCounter);
        Debug.Log("scoreToAdd = " + (bonuslessScoreToAdd + bonus));
    }