Beispiel #1
0
    public void AddScore(int amount)
    {
        int oldScore = Score;

        Score += amount;
        OnScoreUpdated?.Invoke(this, oldScore, Score);
    }
Beispiel #2
0
    private void CheckResults()
    {
        if (_playerMove == _aiMove)
        {
            OnRoundEnded?.Invoke(null);
            return;
        }

        var result      = (int)_playerMove - (int)_aiMove;
        var roundResult = !(result == -1 || result == 2);

        if (roundResult)
        {
            _playerWins++;
        }
        else
        {
            _aiWins++;
        }

        Debug.Log($"Round result: {roundResult}");

        OnScoreUpdated?.Invoke($"{_playerWins} : {_aiWins}");
        OnRoundEnded?.Invoke(roundResult);
    }
Beispiel #3
0
 public void CollectCars(TrainColor color, int cars)
 {
     CollectedCarsScore.TryGetValue(color, out int score);
     CollectedCarsScore[color] = score + cars;
     OnScoreUpdated?.Invoke();
     CheckVictory();
 }
Beispiel #4
0
 /// <summary>
 /// Called every time the player manages to pass an obstacle
 /// </summary>
 public void AddScore()
 {
     CurrentScore += GameConfig.ScorePerStep;
     // Show score feedback
     // Update ui
     OnScoreUpdated?.Invoke(CurrentScore);
 }
Beispiel #5
0
 internal void DecreaseScore(int amount)
 {
     Score -= amount;
     if (Score < 0)
     {
         Score = 0;
     }
     OnScoreUpdated?.Invoke();
 }
Beispiel #6
0
    // aiChance < 0 => ai plays honestly
    public void Start(float aiChance = -1)
    {
        _playerWins    = 0;
        _aiWins        = 0;
        _aiCheatChance = aiChance;

        OnRoundStarted?.Invoke();
        OnScoreUpdated?.Invoke($"{_playerWins} : {_aiWins}");
        Debug.Log("New game started!");
    }
Beispiel #7
0
    private void OnBlockDestroyed(int pointValueOfBlock)
    {
        score += pointValueOfBlock;
        OnScoreUpdated?.Invoke(score);

        totalNumberOfBlocksInLevel -= 1;
        if (totalNumberOfBlocksInLevel == 0)
        {
            sceneLoader.LoadNextGameLevelScene();
        }
    }
Beispiel #8
0
    private void ResetGame()
    {
        StopAllCoroutines();

        m_state = GameState.Init;

        if (m_pieces != null)
        {
            foreach (PieceController piece in m_pieces)
            {
                if (piece)
                {
                    Destroy(piece.gameObject);
                }
            }
        }

        if (m_boardData)
        {
            m_rows  = m_boardData.Rows;
            m_cols  = m_boardData.Cols;
            m_board = m_boardData.Board.ToArray();
        }
        else
        {
            m_board = new int[m_rows * m_cols];
            for (int i = 0; i < m_board.Length; i++)
            {
                m_board[i] = -1;
            }
        }

        m_pieces = new PieceController[m_rows * m_cols];

        m_score = 0;

        OnScoreUpdated?.Invoke(this, new EventArgs());

        HasAvailablePlays();
    }
Beispiel #9
0
    /**
     * Apply all available merges
     */
    private bool Merge()
    {
        bool merged = false;

        int score = 0;

        foreach (PieceController piece in m_pieces)
        {
            List <PieceController> pieces;

            if (WillMerge(piece, out pieces))
            {
                foreach (PieceController other in pieces)
                {
                    int row = other.Row;
                    int col = other.Col;

                    other.Removed = true;
                    other.Merging = true;

                    score += m_mergeScore;
                }

                merged = true;
            }
        }

        if (score > 0)
        {
            m_score += score;

            OnScoreUpdated?.Invoke(this, new EventArgs());
        }

        return(merged);
    }
Beispiel #10
0
 public void UpdateScore(int value)
 {
     OnScoreUpdated?.Invoke(value);
 }
Beispiel #11
0
 public void IncreaseScore()
 {
     Score += ScorePerFireball;
     OnScoreUpdated?.Invoke();
 }
Beispiel #12
0
 public void Add(uint amount)
 {
     _score += amount;
     OnScoreUpdated?.Invoke(score);
 }
Beispiel #13
0
 void UpdateScore(int score)
 {
     _score += score;
     OnScoreUpdated?.Invoke(_score);
 }
Beispiel #14
0
 public void AddPointsToScore(int points)
 {
     score = score + points >= 0 ? score + points : 0;
     OnScoreUpdated?.Invoke();
 }
Beispiel #15
0
 private void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
 {
     // Broadcast the score so that our UI can update on scene load.
     OnScoreUpdated?.Invoke(score);
 }
Beispiel #16
0
 private void DispatchOnScoreUpdated(int score)
 {
     OnScoreUpdated?.Invoke(score);
 }
 public void UpdateScore(int score)
 {
     playerScore += score;
     OnScoreUpdated?.Invoke();
 }
Beispiel #18
0
    void SetScore(int newVal)
    {
        score = newVal;

        OnScoreUpdated?.Invoke(score);
    }
Beispiel #19
0
 public static void RaiseScoreUpdated(object sender)
 {
     OnScoreUpdated?.Invoke(sender, EventArgs.Empty);
 }
Beispiel #20
0
 public void IncrementScore()
 {
     Score += 1;
     OnScoreUpdated?.Invoke(Score);
 }
Beispiel #21
0
 public void ResetScore()
 {
     Score = 0;
     OnScoreUpdated?.Invoke(Score);
 }
Beispiel #22
0
 public void AddScore(int score)
 {
     currentScore += score;
     OnScoreUpdated?.Invoke(currentScore);
 }
Beispiel #23
0
        private void UpdateScore(int addition)
        {
            Score += addition;

            OnScoreUpdated?.Invoke(Score);
        }