コード例 #1
0
        public void AddScore(int score)
        {
            var newScore = statisticModel.Score + score;

            statisticModel.Score = newScore;
            OnScoreChanged?.Invoke(newScore);
        }
コード例 #2
0
        public void LoadGame()
        {
            if (LoadGameString != null)
            {
                PlayerState state = null;
                NewGameString = LoadGameString?.Invoke();

                if (!string.IsNullOrEmpty(NewGameString))
                {
                    state = JsonConvert.DeserializeObject <PlayerState>(NewGameString);
                    Player.LocationName = state.Location;
                    Player.Score        = state.Score;
                    Player.Moves        = state.Moves;
                    OnLocationChanged?.Invoke(this, Player.LocationName);
                    OnScoreChanged?.Invoke(this, Player.Score);
                    OnMovesChanged?.Invoke(this, Player.Moves);
                }

                else
                {
                    Output.WriteLine("Restore failed. No save file exists yet.");
                    return;
                }
            }
            else
            {
                Output.WriteLine("Restore failed. This game is not setup to load games.");
            }
        }
コード例 #3
0
ファイル: Score.cs プロジェクト: Svarog00/Dependence-Game
 public void AddPoints(int points)
 {
     _currentScore += points;
     OnScoreChanged?.Invoke(this, new OnScoreChangedEventArgs {
         score = _currentScore
     });
 }
コード例 #4
0
 private void InitialiseUI()
 {
     OnScoreChanged?.Invoke(newText: _currentGameStats.Score.ToString());
     OnCountDown?.Invoke(newText: "");
     StartPauseWatch?.Invoke("");
     OnAmmoChange?.Invoke(newText: _currentGameStats.Ammo.ToString());
 }
コード例 #5
0
 private void InitNewGame() // Инициализация новой игры
 {
     _score     = 0;
     _livesLeft = _data.Lives;
     OnScoreChanged?.Invoke(_score);
     OnLivesLeftChanged?.Invoke(_livesLeft);
 }
コード例 #6
0
ファイル: GridScript.cs プロジェクト: unitycoder/flipon-tiny
    public void AddPoints(long points)
    {
      score += points;

      player.Score = score;

      OnScoreChanged.Raise(this, score);
    }
コード例 #7
0
 void CleanUpListeners()
 {
     Delegate[] listeners = OnScoreChanged.GetInvocationList();
     foreach (Delegate listener in listeners)
     {
         OnScoreChanged -= (listener as Action <int>);
     }
 }
コード例 #8
0
 public static void AddScore(int value)
 {
     if (GameController.GameStarted)
     {
         score += value;
         OnScoreChanged?.Invoke(score);
     }
 }
コード例 #9
0
    public bool TryFindMatchesAndDestroyThem()
    {
        List <List <GemGridPosition> > allLinkedGemGridPositionList = GetAllMatch3Links();

        bool foundMatch = false;

        List <Vector2Int> explosionGridPositionList = new List <Vector2Int>();

        foreach (List <GemGridPosition> linkedGemGridPositionList in allLinkedGemGridPositionList)
        {
            foreach (GemGridPosition gemGridPosition in linkedGemGridPositionList)
            {
                TryDestroyGemGridPosition(gemGridPosition);
            }

            if (linkedGemGridPositionList.Count >= 4)
            {
                // More than 4 linked
                score += 200;

                // Special Explosion Gem
                GemGridPosition explosionOriginGemGridPosition = linkedGemGridPositionList[0];

                int explosionX = explosionOriginGemGridPosition.GetX();
                int explosionY = explosionOriginGemGridPosition.GetY();

                // Explode all 8 neighbours
                explosionGridPositionList.Add(new Vector2Int(explosionX - 1, explosionY - 1));
                explosionGridPositionList.Add(new Vector2Int(explosionX + 0, explosionY - 1));
                explosionGridPositionList.Add(new Vector2Int(explosionX + 1, explosionY - 1));
                explosionGridPositionList.Add(new Vector2Int(explosionX - 1, explosionY + 0));
                explosionGridPositionList.Add(new Vector2Int(explosionX + 1, explosionY + 0));
                explosionGridPositionList.Add(new Vector2Int(explosionX - 1, explosionY + 1));
                explosionGridPositionList.Add(new Vector2Int(explosionX + 0, explosionY + 1));
                explosionGridPositionList.Add(new Vector2Int(explosionX + 1, explosionY + 1));
            }

            foundMatch = true;
        }

        bool spawnExplosion = match4Explosions;

        if (spawnExplosion)
        {
            foreach (Vector2Int explosionGridPosition in explosionGridPositionList)
            {
                if (IsValidPosition(explosionGridPosition.x, explosionGridPosition.y))
                {
                    GemGridPosition gemGridPosition = grid.GetGridObject(explosionGridPosition.x, explosionGridPosition.y);
                    TryDestroyGemGridPosition(gemGridPosition);
                }
            }
        }

        OnScoreChanged?.Invoke(this, EventArgs.Empty);

        return(foundMatch);
    }
コード例 #10
0
ファイル: GameMode.cs プロジェクト: Syldarion/MemoryMash
    public virtual void UpdateScore(int score)
    {
        OnScoreChangedEventArgs args = new OnScoreChangedEventArgs()
        {
            NewScore = score
        };

        OnScoreChanged.Invoke(this, args);
    }
コード例 #11
0
    void CountScore(int ballsCount)
    {
        score += ballsCount * (increaseCOunt + 1) + (hitsCount + 1) * (increaseCOunt + 1);
        if (levelParams.BestScore < score)
        {
            levelParams.BestScore = score;
        }

        OnScoreChanged?.Invoke(score, levelParams.BestScore);
    }
コード例 #12
0
ファイル: GameController.cs プロジェクト: Malpp/TankGame
        private IEnumerator AddScoreCoroutine()
        {
            while (true)
            {
                yield return(new WaitForSecondsRealtime(1f));

                score++;
                OnScoreChanged?.Invoke(score);
            }
        }
コード例 #13
0
ファイル: ScoreManager.cs プロジェクト: ky0jr/rpg
        public void AddScore(int value)
        {
            Score += value;

            if (Score > highScore)
            {
                PlayerPrefs.SetInt(SaveKey, Score);
            }

            OnScoreChanged?.Invoke(Score);
        }
コード例 #14
0
ファイル: ScoreManager.cs プロジェクト: lukamarijn/SDGGame
    public void UpdateScore()
    {
        score++;
        Debug.Log("Score: " + score);
        OnScoreChanged?.Invoke(score);

        if (score >= 10)
        {
            OnScoreReachedBoundary?.Invoke();
        }
    }
コード例 #15
0
 public void Restart()
 {
     //IsRunning = false;
     //mIsRestarting = true;
     Output.Clear();
     Player.LocationName = World.GetStartingLocation();
     Player.Score        = 0;
     Player.Moves        = 0;
     OnLocationChanged?.Invoke(this, Player.LocationName);
     OnScoreChanged?.Invoke(this, 0);
     OnMovesChanged?.Invoke(this, 0);
 }
コード例 #16
0
        public void SetScore(int newScore)
        {
            var oldScore = _score;

            _score = newScore;

            OnScoreChanged?.Invoke(new ScoreChangedEvent
            {
                OldScore = oldScore,
                NewScore = newScore,
            });
        }
コード例 #17
0
ファイル: GameScoreController.cs プロジェクト: Zubius/pinball
    internal void AddScores(int inc)
    {
        CurrentScores += inc;

        if (CurrentScores > TopScores)
        {
            TopScores         = CurrentScores;
            _topScoresUpdated = true;
        }

        OnScoreChanged?.Invoke();
    }
コード例 #18
0
        public void OnChipClicked(Word w)
        {
            GameScoreClientService.ValidateWord(w);
            var newScore = GetPoints();
            var diff     = newScore - _score;

            _score = newScore;
            Score  = _score.ToString();

            OnScoreChanged?.Invoke(newScore, diff);

            StateHasChanged();
        }
コード例 #19
0
        public void AddScore(float value)
        {
            Score += value;

            comboTimer.Reset();
            if (!comboTimer.IsAwake)
            {
                comboTimer.Start();
            }
            Combo += value;

            OnScoreChanged?.Invoke();
        }
コード例 #20
0
    private void OnTriggerEnter(Collider other)
    {
        MinigameItem item = other.GetComponent <MinigameItem>();

        if (item.scored)
        {
            return;
        }
        goals++;
        score += (int)((transform.position - player.transform.position).magnitude * 2 + (transform.position - other.transform.position).magnitude * 10);
        OnScoreChanged?.Invoke(score);
        item.scored = true;
    }
コード例 #21
0
ファイル: ScoreManager.cs プロジェクト: rmuqsith/rpg
        public void Reset()
        {
            Score = 0;

            if (PlayerPrefs.HasKey(SaveKey))
            {
                highScore = PlayerPrefs.GetInt(SaveKey);
            }
            else
            {
                highScore = 0;
            }

            OnScoreChanged?.Invoke(Score);
        }
コード例 #22
0
    public void ChangeScore(int value)
    {
        if (value < 0)
        {
            value = _pointsToLose;
        }
        Score += value;

        if (Score <= 0)
        {
            Score = 0;
        }
        Save();
        OnScoreChanged?.Invoke();
    }
コード例 #23
0
ファイル: ScoreManager.cs プロジェクト: ky0jr/rpg
        public void Initialize()
        {
            scoreCanvas.Initialized();

            Score = 0;

            if (PlayerPrefs.HasKey(SaveKey))
            {
                highScore = PlayerPrefs.GetInt(SaveKey);
            }
            else
            {
                highScore = 0;
            }

            OnScoreChanged?.Invoke(Score);
        }
コード例 #24
0
        /// <summary>
        /// Añade o resta puntos a un equipo.
        /// </summary>
        /// <param name="Team">Color del equipo.</param>
        /// <param name="Points">Puntos que va a dar/quitar.</param>
        public void AddPointsToTeam(Team Team, int Points, RoomUser User)
        {
            int TeamId = (int)Team;

            teamPoints[TeamId] += Points;

            if (teamPoints[TeamId] < 0)
            {
                teamPoints[TeamId] = 0;
            }

            List <RoomItem> Items = teamItems[TeamId];

            foreach (RoomItem Item in Items)
            {
                if (IsScoreboard(Item.GetBaseItem().InteractionType))
                {
                    Item.ExtraData = teamPoints[TeamId].ToString();
                    Item.UpdateState();
                }
            }

            OnScoreChanged?.Invoke(null, new TeamScoreChangedArgs(teamPoints[TeamId], Team, User));
        }
コード例 #25
0
 public void CallOnScoreChanged(EventData ob = null) => OnScoreChanged?.Invoke(ob);
コード例 #26
0
 public void AddScore(int count) // Изменение кол-ва очков
 {
     _score += count;
     OnScoreChanged?.Invoke(_score);
 }
コード例 #27
0
 private void Start()
 {
     Score = 0f;
     OnScoreChanged?.Invoke();
 }
コード例 #28
0
 private void ChageScore(int newScore)
 {
     _value = newScore;
     OnScoreChanged?.Invoke(_value);
 }
コード例 #29
0
 /**
  * Static trigger to execute score change. The value for change can bei either +/-, event does not care where
  * it comes from or whether the change is positive or negative.
  */
 public static void TriggerScoreChange(int value)
 {
     OnScoreChanged?.Invoke(value);
 }
コード例 #30
0
ファイル: ScoreKeeper.cs プロジェクト: Shad0X/Asteroids
    public event Action <int> OnScoreChanged; //does it need the "event" part ???

    private void SetScore(int value)          //kinda pointless, since the Score VARIABLE already has a private set, no ?
    {
        Score = value;
        OnScoreChanged?.Invoke(Score);
    }