Ejemplo n.º 1
0
    public void AddScore(int amount)
    {
        int oldScore = Score;

        Score += amount;
        OnScoreUpdated?.Invoke(this, oldScore, Score);
    }
Ejemplo n.º 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);
    }
Ejemplo n.º 3
0
 public void CollectCars(TrainColor color, int cars)
 {
     CollectedCarsScore.TryGetValue(color, out int score);
     CollectedCarsScore[color] = score + cars;
     OnScoreUpdated?.Invoke();
     CheckVictory();
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 5
0
 internal void DecreaseScore(int amount)
 {
     Score -= amount;
     if (Score < 0)
     {
         Score = 0;
     }
     OnScoreUpdated?.Invoke();
 }
Ejemplo n.º 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!");
    }
Ejemplo n.º 7
0
    private void OnBlockDestroyed(int pointValueOfBlock)
    {
        score += pointValueOfBlock;
        OnScoreUpdated?.Invoke(score);

        totalNumberOfBlocksInLevel -= 1;
        if (totalNumberOfBlocksInLevel == 0)
        {
            sceneLoader.LoadNextGameLevelScene();
        }
    }
Ejemplo n.º 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();
    }
Ejemplo n.º 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);
    }
Ejemplo n.º 10
0
 public void UpdateScore(int value)
 {
     OnScoreUpdated?.Invoke(value);
 }
Ejemplo n.º 11
0
 public void IncreaseScore()
 {
     Score += ScorePerFireball;
     OnScoreUpdated?.Invoke();
 }
Ejemplo n.º 12
0
 public void Add(uint amount)
 {
     _score += amount;
     OnScoreUpdated?.Invoke(score);
 }
Ejemplo n.º 13
0
 void UpdateScore(int score)
 {
     _score += score;
     OnScoreUpdated?.Invoke(_score);
 }
Ejemplo n.º 14
0
 public void AddPointsToScore(int points)
 {
     score = score + points >= 0 ? score + points : 0;
     OnScoreUpdated?.Invoke();
 }
Ejemplo n.º 15
0
 private void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
 {
     // Broadcast the score so that our UI can update on scene load.
     OnScoreUpdated?.Invoke(score);
 }
Ejemplo n.º 16
0
 private void DispatchOnScoreUpdated(int score)
 {
     OnScoreUpdated?.Invoke(score);
 }
Ejemplo n.º 17
0
 public void UpdateScore(int score)
 {
     playerScore += score;
     OnScoreUpdated?.Invoke();
 }
Ejemplo n.º 18
0
    void SetScore(int newVal)
    {
        score = newVal;

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

            OnScoreUpdated?.Invoke(Score);
        }