예제 #1
0
        private void UpdatePoint(IPointsGiver pointsGiver)
        {
            if (!_pointsGivers.Contains(pointsGiver))
            {
                return;
            }

            var pointTxt = "очков";

            _countPoint += pointsGiver.GivePoints();
            if (_countPoint >= 5)
            {
                pointTxt = "очков";
            }
            else if (_countPoint == 1)
            {
                pointTxt = "очко";
            }
            else if (_countPoint < 5)
            {
                pointTxt = "очка";
            }
            _text.text = $"Вы заработали {_countPoint} {pointTxt}";

            pointsGiver.OnPointChange -= UpdatePoint;
            _pointsGivers.Remove(pointsGiver);
        }
예제 #2
0
        public void AddPointsGiver(IPointsGiver pointsGiver)
        {
            if (_pointsGivers.Contains(pointsGiver))
            {
                return;
            }

            _pointsGivers.Add(pointsGiver);
            pointsGiver.OnPointChange += UpdatePoint;
        }