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

        isNewHigh = false;
    }
예제 #2
0
 private void onScoreChanges()
 {
     if (OnScoreChange != null)
     {
         OnScoreChange.Invoke();
     }
 }
예제 #3
0
    private void OnBulletHitPlayer(int score)
    {
        playerScore += score;
        OnScoreChange?.Invoke(score);

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

        OnScoreChange?.Invoke(score);

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

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

        OnMaxScoreChange?.Invoke(maxScore);

        OnScoreChange?.Invoke(score);
    }
예제 #12
0
 private void GetPointForAsteroid(int value)
 {
     _score += value;
     OnScoreChange?.Invoke(_score);
     if (_score < targetPointForNewHp)
     {
         return;
     }
     _playerHealthComponent.IncreaseHealthPoint();
     targetPointForNewHp += _initTargetPoint;
 }
예제 #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);
        }
    }
예제 #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);
            }
        }
예제 #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);
            }
        }
예제 #16
0
 public void ChangeScore(int nPoints)
 {
     Score += (nPoints * _scoreMultiply);
     if (Score < 0)
     {
         ClearScore();
     }
     if (OnScoreChange != null)
     {
         OnScoreChange.Invoke();
     }
 }
예제 #17
0
    public void SubmitPoints(int pieces)
    {
        CurrentScore += _pointsPerPiece * pieces;
        OnScoreChange?.Invoke(CurrentScore);

        if (CurrentScore > HighScore)
        {
            isNewHigh        = true;
            _highScore.Value = CurrentScore;
            OnHighScoreChange?.Invoke(CurrentScore);
        }
    }
예제 #18
0
    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);
        }
    }
예제 #19
0
        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);
            }
        }
예제 #20
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);
        }
예제 #21
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;
        }
    }
예제 #22
0
    void Start()
    {
        cycloneConfig             = new CycloneConfig(cycloneParent);
        levelManager              = new LevelManager(levelParent, this);
        cameraManager             = new CameraManager(Camera.main, this);
        cycloneConfig.speed       = 10;
        cycloneConfig.maxPull     = 4;
        cycloneConfig.innerRadius = 10;
        cycloneConfig.outerRadius = 30;
        scoreDelegate            += scaleScore;
        //levelManager.loadLevel(1);

        foreach (EndZone e in FindObjectsOfType <EndZone>())
        {
            endzoneDictionary.Add(e.assocTeam, e);
        }
        blackPanel.color   = Color.clear;
        gameEndText.color  = Color.clear;
        endScore.color     = Color.clear;
        numShots.color     = Color.clear;
        finalMessage.color = Color.clear;
        cameraManager.tutorialCameraAnim();
        //levelManager.loadLevel(1);
    }
예제 #23
0
 public void BroadcastScoreChange(Player changedPlayer, int changeBy)
 {
     OnScoreChange?.Invoke(changedPlayer, changeBy);
 }
예제 #24
0
 public static void ReportScoreChange(int _val)
 {
     OnScoreChange?.Invoke(_val);
 }
예제 #25
0
 // When a collectable is picked up
 // Update the score
 private void OnCollectablePickup(Collectable collectable)
 {
     Score += collectable.Score;
     OnScoreChange?.Invoke();
 }
예제 #26
0
 // When a ghost dies, update the score
 private void OnGhostDeath()
 {
     Score += 100;
     OnScoreChange?.Invoke();
 }
예제 #27
0
 void IncrementLvlScore(float nothing)
 {
     numberOfLvlScore++;
     OnScoreChange.Invoke(numberOfLvlScore);
 }
예제 #28
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));
    }
예제 #29
0
 private void ScoreChanged(int score)
 {
     OnScoreChange?.Invoke(score);
 }
예제 #30
0
 public void AddScore(int ScoreToAdd)
 {
     score += ScoreToAdd;
     OnScoreChange?.Invoke(score);
 }