예제 #1
0
        /// <inheritdoc/>
        public void OnBallHit(IPlayerBallController ballController)
        {
            if (IsDead())
            {
                return;
            }

            var currentLiveHint      = _brickParameters.Lives[_currentLiveId].hitScore;
            var brickHintEventParams = new BrickWasHitEventParams(currentLiveHint);

            _messageDispatcher.Rise(this, brickHintEventParams);

            _currentLiveId++;
            if (IsDead())
            {
                var deathScore             = _brickParameters.BrickLiveScore;
                var brickPosition          = _brickParameters.BrickTransform.position;
                var brickDeathsEventParams = new BrickWasDestroyedEventParams(deathScore, brickPosition);

                var effectPosition = _brickParameters.BrickTransform.position;
                var effectRotation = _brickParameters.BrickTransform.rotation;
                _effectPool.AddEffectRequest(_brickParameters.DeathEffect, effectPosition, effectRotation);

                _messageDispatcher.Rise(this, brickDeathsEventParams);
                Object.Destroy(_brickParameters.BrickTransform.gameObject);
            }
            else
            {
                var currentLive = _brickParameters.Lives[_currentLiveId];
                _brickParameters.BrickSpriteHolder.sprite = currentLive.LiveSprite;
            }
        }
예제 #2
0
        private void OnBrickDestroyed(object source, BrickWasDestroyedEventParams brickDestroyedEventParams)
        {
            if (_onLevelLoading)
            {
                return;
            }

            _currentScore += brickDestroyedEventParams.ScoreCost;
            _scoreToText.SetScore(_currentScore);

            _leftedBrick--;
            _leftBrickCounter.SetScore(_leftedBrick);

            CheckWinCondition();
        }
예제 #3
0
        private void OnBrickDestroyed(object source, BrickWasDestroyedEventParams eventParams)
        {
            var spawnPosition = eventParams.BrickPosition;

            var cumulativePart = 0;
            var randomValue    = Random.Range(0, _allRangesSum);

            foreach (var bonusContainer in _bonuseWithDropRate)
            {
                cumulativePart += bonusContainer.ChanceValue;
                if (cumulativePart > randomValue)
                {
                    if (bonusContainer.BonusPrefab != null)
                    {
                        var bonus = Instantiate(bonusContainer.BonusPrefab, spawnPosition, Quaternion.identity, _myTransform);
                        bonus.BonusManager = this;
                    }
                    return;
                }
            }
        }