示例#1
0
 protected virtual void OnScoreChanged(ScoreChangedEventArgs e)
 {
     if (ScoreChanged != null)
     {
         ScoreChanged.Invoke(this, e);
     }
 }
示例#2
0
 public void ResetPlayer()
 {
     _health = 3;
     _score  = 0;
     _mover.ResetPlayer();
     ScoreChanged?.Invoke(_score);
 }
示例#3
0
 private void onScoreChanged()
 {
     if (ScoreChanged != null)
     {
         ScoreChanged.Invoke(Score);
     }
 }
示例#4
0
文件: Game.cs 项目: PzeKnm/GameLib
        protected void UpdateScore(int score)
        {
            ScoreChangedArgs a = new ScoreChangedArgs();

            a.newScore = score;
            ScoreChanged?.Invoke(this, a);
        }
示例#5
0
        public void CalculateAndRaiseScore(string playerUid)
        {
            var successfulPlayers = GetSuccessfulGuessedPlayerCount();
            var player            = Players.FirstOrDefault(p => p.Uid == playerUid);

            if (player != null && !player.HasGuessed)
            {
                var score = (Players.Count - 1 - successfulPlayers) * ScoreMultiplicator;
                //score = 2 - 1 - 0 * 100;
                Log.Debug($"Calculated: ({Players.Count} - 1 - {successfulPlayers}) * {ScoreMultiplicator} = {score}");

                player.Score     += score;
                player.HasGuessed = true;
                ScoreChanged?.Invoke(this, new ScoreChangedEventArgs(player, score));
                //Raise score for drawing player

                var drawingPlayer = GetCurrentlyDrawingPlayer();

                if (drawingPlayer != null)
                {
                    var drawingPlayerScore = (int)(score * DrawerScoreAdditionPercentage);
                    Log.Debug($"Drawing-Score: {drawingPlayerScore}");
                    drawingPlayer.Score += drawingPlayerScore;

                    ScoreChanged?.Invoke(this, new ScoreChangedEventArgs(drawingPlayer, drawingPlayerScore));
                }
            }
        }
示例#6
0
    public void UpdateFrom(String recipeName, IReadOnlyCollection <IDishProperty> dishProperties)
    {
        if (scoreExtractor == null)
        {
            return;
        }

        int dishScore = scoreExtractor.ExtractDataFrom(dishProperties);

        if (memorizeLastDish)
        {
            lastDishTuple = Tuple.Create(recipeName, dishProperties, dishScore);
        }

        if (memorizeBestDish)
        {
            int bestDishScore = bestDishTuple?.Item3 ?? 0;

            if (bestDishScore < dishScore)
            {
                bestDishTuple = Tuple.Create(recipeName, dishProperties, dishScore);
            }
        }

        totalScore += dishScore;

        ScoreChanged?.Invoke(totalScore);

        UpdateScoreString();
    }
示例#7
0
        /// <summary>
        /// Resets the current score to 0, multiplier to 1, and triggers ScoreChanged
        /// </summary>
        public static void ResetScore()
        {
            Score           = 0;
            ScoreMultiplier = 1;

            ScoreChanged?.Invoke();
        }
 public void reset()
 {
     player1.reset(StartValue);
     player2.reset(StartValue);
     winner = PlayerNum.Nobody;
     ScoreChanged?.Invoke(this, new ScoreChangedEventArgs());
 }
示例#9
0
 private void ItemOnScoreChanged(object sender, ScoreChangedEventArgs e)
 {
     if (ScoreChanged != null)
     {
         ScoreChanged.Invoke(this, e);
     }
 }
示例#10
0
        public void applyScore(int score, PlayerNum player)
        {
            int currentScore = getScore(player);
            int remaining    = currentScore - score;

            if (remaining < 0 || remaining == 1)    //No score
            {
                return;
            }

            if (remaining == 0)     //TODO Should we check if it's a double?
            {
                winner = player;
            }

            if (player == PlayerNum.PlayerOne)
            {
                player1.Score -= score;
            }
            if (player == PlayerNum.PlayerTwo)
            {
                player2.Score -= score;
            }

            ScoreChanged?.Invoke(this, new ScoreChangedEventArgs());
        }
示例#11
0
    private void InitializePlayer()
    {
        PhotonNetwork.Instantiate(ServiceLocator.PREFABS_PATH + playerCamPrefab.name, Vector3.zero, Quaternion.identity);

        scores.Add(Team.Red, 0);
        scores.Add(Team.Blue, 0);
        ScoreChanged?.Invoke();
    }
示例#12
0
 /// <summary>
 /// Score an asteroid hit by the player.
 /// The added score amount is decided by considering the mass of the asteroid using an animation curve.
 /// </summary>
 /// <param name="mass">The asteroid's mass</param>
 public void ScoreAsteroidHit(float mass)
 {
     if (gameIsInProgress)
     {
         score += Mathf.RoundToInt(asteroidMassToScoreFunction.Evaluate(mass));
         ScoreChanged?.Invoke(score);
     }
 }
示例#13
0
    private void UpdateScore(Vector3 landedPlanetPosition, float landAngle)
    {
        float bonusMultiplier = Mathf.Abs((Mathf.Abs(landAngle) / 90.0f) - 1);

        currentScore += 1 + bonusMultiplier;

        ScoreChanged?.Invoke(currentScore);
    }
示例#14
0
    private void Start()
    {
        Score           = 0;
        ScoreMultiplier = 1;
        TetrominoCount  = 0;
        Level           = 1;

        ScoreChanged?.Invoke();
    }
示例#15
0
        protected void OnScoreChanged()
        {
            this.r_ScoreTextBlock.Text = this.Value.ToString();

            if (ScoreChanged != null)
            {
                ScoreChanged.Invoke();
            }
        }
示例#16
0
        /// <summary>
        /// Adds points to current score and triggers ScoreChanged
        /// </summary>
        /// <param name="points">The number of points to add (can be negative)</param>
        /// <returns>The total points that were added (after applying the multiplier)</returns>
        public static int AddPoints(int points)
        {
            int pts = points * ScoreMultiplier;

            Score += pts;

            ScoreChanged?.Invoke();

            return(pts);
        }
示例#17
0
 private void ScorePoint(string player, int refScore)
 {
     ScoreChanged?.Invoke(player, refScore);
     if (refScore >= maxScore)
     {
         ball.GetComponent <Ball>().StoppedMoving     -= Ball_StoppedMoving;
         ball.GetComponent <Ball>().PassedThroughRing -= Ball_PassedThroughRing;
         MaxScoreReached?.Invoke(player);
     }
 }
示例#18
0
        public void Finish()
        {
            if (_curScore > _bestScore)
            {
                _bestScore = _curScore;
            }

            _lastScore = _curScore;
            _curScore  = 0;
            ScoreChanged?.Invoke(this);
        }
示例#19
0
        /// <summary>
        /// Sets the best score, saves it, and triggers ScoreChanged
        /// </summary>
        public static void SetHighScore()
        {
            if (Score > HighScore)
            {
                HighScore = Score;

                PlayerPrefs.SetInt("HighScore", HighScore);
            }

            ScoreChanged?.Invoke();
        }
示例#20
0
        public void OnHexagonExploded()
        {
            Score += GameParamsDatabase.Instance.ScorePerExplosion;

            if (Score > 0 && Score % GameParamsDatabase.Instance.BombScore == 0)
            {
                BombScoreReached?.Invoke();
            }

            ScoreChanged?.Invoke(Score);
        }
示例#21
0
    public void IncreaseScore()
    {
        _score++;
        int currentMaxScore = saver.MaxScore;

        if (_score > currentMaxScore)
        {
            saver.SaveMaxScoreAmount(_score);
        }
        ScoreChanged?.Invoke(_score);
    }
示例#22
0
 public void InvokScoreChanged(params string[] studentIDList)
 {
     if (studentIDList.Length == 0)
     {
         return;
     }
     if (ScoreChanged != null)
     {
         ScoreChangedEventArgs args = new ScoreChangedEventArgs(studentIDList);
         ScoreChanged.Invoke(this, args);
     }
 }
示例#23
0
        protected override void OnUpdate()
        {
            var scoreComponent = GetSingleton <ScoreComponent>();

            if (scoreComponent.OldScores == scoreComponent.Scores)
            {
                return;
            }
            ScoreChanged?.Invoke(scoreComponent.Scores);
            scoreComponent.OldScores = scoreComponent.Scores;
            SetSingleton(scoreComponent);
        }
示例#24
0
    public void IncreaseScore()
    {
        _score++;
        ScoreChanged?.Invoke(_score);

        var highScore = PlayerPrefs.GetInt("highScore");

        if (_score > highScore)
        {
            PlayerPrefs.SetInt("highScore", _score);
        }
    }
示例#25
0
        /// <summary>
        /// Should be called on each point win
        /// </summary>
        /// <param name="playerXGotPoint">True if player X wins the point, False if player Y wins the point</param>
        public void Increment(bool playerXGotPoint)
        {
            if (IncrementPoints(playerXGotPoint))
            {
                _currentGame = new Point();
                if (IncrementGame(playerXGotPoint))
                {
                    _sets.Add(new Point());
                }
            }

            ScoreChanged?.Invoke(GetCurrentScore());
        }
示例#26
0
        public void UpdateScore()
        {
            int   nGroups    = 0;
            float totalScore = 0;

            foreach (GroupData groupData in GroupDatas)
            {
                totalScore += groupData.GetAvgScore();
                nGroups    += 1;
            }

            AverageScore = totalScore / nGroups;
            ScoreChanged?.Invoke(AverageScore);
        }
    private void AddScore(PlayerType playerType)
    {
        IncreasePoints(playerType, matchPoints);
        matchPoints = 0;

        byte score = IncreaseScore(playerType);

        ScoreChanged?.Invoke(playerType, score);

        if (currentGameMode != GameMode.MenuMode && score >= winScore)
        {
            FinishMatch(playerType);
        }
    }
示例#28
0
        private void ResetGame()
        {
            IsBlackPlayerCurrent  = true;
            _isPlayerBeforePassed = false;
            CurrentPlayerChanged?.Invoke();

            Board.EmptyBoard();
            Score = new Dictionary <BoardColor, int>
            {
                { BoardColor.Black, 0 },
                { BoardColor.White, 0 }
            };
            ScoreChanged?.Invoke(BoardColor.Black);
            ScoreChanged?.Invoke(BoardColor.White);
        }
示例#29
0
 private void OnGameFinished(GameFinishedArgs gameFinished)
 {
     IsGameOver = true;
     if (gameFinished.Result == GameResult.Win)
     {
         int currentScore = Scores[gameFinished.Winner.Team];
         scores[gameFinished.Winner.Team] = currentScore + 1;
         ScoreChanged?.Invoke(Scores);
         TeamAndLineWon?.Invoke(new ValueTuple <Team, LineWin>(gameFinished.Winner.Team, gameFinished.LineWin));
     }
     else
     {
         TeamAndLineWon?.Invoke(new ValueTuple <Team, LineWin>(Team.None, LineWin.None));
     }
 }
示例#30
0
        /// <summary>
        /// Start a new game: create a new ship, initialize the variables, & fire the necessary event handlers.
        /// </summary>
        private void StartGame()
        {
            GameObject shipGO = Instantiate(shipPrefab, Vector3.zero, Quaternion.identity);

            ship           = shipGO.GetComponent <Ship>();
            ship.Impacted += OnShipImpacted;

            numberOfLives    = startingNumberOfLives;
            score            = 0;
            gameIsInProgress = true;

            GameStarted?.Invoke();
            NumberOfLivesChanged?.Invoke(numberOfLives);
            ScoreChanged?.Invoke(score);
        }