Esempio n. 1
0
        protected override void Update()
        {
            base.Update();
            if (IsActive)
            {
                transform.Rotate(0, 0, -_input.GetRotation() * _rotationSpeed * Time.deltaTime);
                Rigidbody.AddForce(transform.up * _movingForce * _input.GetMovement());

                if (_input.ActionButtonPressed())
                {
                    if (_timeFromLastShot > _shotDelay)
                    {
                        var laser = _laserSpawner.Spawn() as Laser;
                        if (laser != null)
                        {
                            laser.Setup(_weapon.transform.position, transform.rotation);
                            SignalsManager.Broadcast("PlayAudio", "laser");
                        }

                        _timeFromLastShot = 0f;
                    }
                    else
                    {
                        _timeFromLastShot += Time.deltaTime;
                    }
                }
                else
                {
                    _timeFromLastShot = float.MaxValue;
                }
            }
        }
Esempio n. 2
0
 public void BlowUp()
 {
     GameController.Instance.GameSession.AddScorePoints(_value);
     SignalsManager.Broadcast(_audioSignal.Name, "splash");
     EffectsManager.Instance.Play(GameConfiguration.Instance.PopSettings.BlowUpEffect, _value, transform.position);
     Deactivate();
 }
Esempio n. 3
0
        private void OnTriggerEnter(Collider otherCollider)
        {
            var pathLine = otherCollider.GetComponent <Line>();

            if (pathLine != null)
            {
                _currentLine = pathLine;
                return;
            }

            var platform = otherCollider.GetComponent <Platform>();

            if (platform != null)
            {
                _isOnPlatform = true;
                ProcessPlatform(platform);
                return;
            }

            var pickup = otherCollider.GetComponent <Pickup>();

            if (pickup != null)
            {
                pickup.Trigger();
                return;
            }

            var fallZone = otherCollider.GetComponent <FallZone>();

            if (fallZone != null && !_isOnPlatform)
            {
                ProcessFall();
                SignalsManager.Broadcast(_stateSignal.Name, GameState.End.ToString());
            }
        }
Esempio n. 4
0
 public void Trigger()
 {
     if (GameController.Instance.GameState == GameState.Play)
     {
         _animator.SetTrigger("React");
         SignalsManager.Broadcast(_audioSignal.Name, _soundName);
     }
 }
Esempio n. 5
0
        private void PlayHitEffects(Vector3 hitPoint)
        {
            var hitEffect = _effectsPool.GetNext();

            hitEffect.transform.position = hitPoint;
            this.WaitForSeconds(hitEffect.main.duration, () => _effectsPool.Return(hitEffect));
            SignalsManager.Broadcast(_playAudioSignal.Name, "ball_hit");
        }
Esempio n. 6
0
 public override void OnEnter()
 {
     base.OnEnter();
     this.WaitForSeconds(_waitTime, () =>
     {
         SignalsManager.Broadcast(_stateChangeSignal.Name, GameState.Start.ToString());
     });
 }
Esempio n. 7
0
        public override void Trigger()
        {
            base.Trigger();

            SignalsManager.Broadcast(_audioSignal.Name, _sound);
            GameController.Instance.GameSession.ApplyMultiplier(_multiplier);
            Debug.Log("Trigger Multiplier");
        }
Esempio n. 8
0
 public override void Trigger()
 {
     _renderer.enabled     = false;
     _splashMaterial.color = GameConfiguration.GetColor(_color);
     _particleSystem.Play();
     SignalsManager.Broadcast(_audioSignal.Name, _sound);
     GameController.Instance.GameSession.ApplyColor(_color);
     Debug.Log("Trigger Color");
 }
Esempio n. 9
0
 public void PlayDestroyEffect(Vector3 hitPoint)
 {
     if (!_destroyEffectPlayed)
     {
         Instantiate(_ballView.DestroyEffect, hitPoint, Quaternion.identity, transform.parent);
         SignalsManager.Broadcast(_playAudioSignal.Name, "ball_destroy");
         _destroyEffectPlayed = true;
     }
 }
Esempio n. 10
0
        private void StartGame()
        {
            _asteroidsSpawner.RestartSpawn();

            var spaceShip = _shipSpawner.Spawn() as Ship;

            if (spaceShip != null)
            {
                spaceShip.Setup(ShipSettings.Instance);
            }

            SignalsManager.Broadcast(_gameStartedSignal.Name);
        }
Esempio n. 11
0
        private void OnHitRacketAction()
        {
            _hitsCount++;
            SignalsManager.Broadcast(_scoreChangeSignal.Name, _hitsCount);

            if (_hitsCount % GameConfiguration.Instance.RacketSizeDecreaseRate == 0)
            {
                DecreaseRacketSize(_topRacket);
                DecreaseRacketSize(_bottomRacket);

                SignalsManager.Broadcast(_racketsSizeChangeSignal.Name);
            }
        }
Esempio n. 12
0
        private void Shoot(Cell cell)
        {
            _isActive = false;
            _firstPop.Move(cell, () =>
            {
                cell.Attach(_firstPop);
                cell.React();
                cell.Merge();
            });

            SignalsManager.Broadcast(_audioSignal.Name, "shoot");
            Reload();
        }
Esempio n. 13
0
        protected override void OnContactHandlerEntered(SpaceObject spaceObject)
        {
            if (spaceObject.Type == SpaceObjectType.Asteroid)
            {
                return;
            }

            if (spaceObject.Type == SpaceObjectType.Laser)
            {
                SignalsManager.Broadcast(_destroyedSignal.Name, _scorePoints);
                SignalsManager.Broadcast("PlayAudio", "destroyed");
                Deactivate();
            }
        }
Esempio n. 14
0
        public void AddScorePoints(int scorePoints)
        {
            Score += scorePoints;
            SignalsManager.Broadcast(_scoreSignal.Name, Score);

            var level = GameConfiguration.GetLevelByScore(Score);

            if (level > Level)
            {
                Level = level;
                SignalsManager.Broadcast(_levelSignal.Name, level);
                SaveLevelAndScore();
            }
        }
Esempio n. 15
0
 public void ApplyColor(string color)
 {
     if (color != Color)
     {
         Color = color;
         _ball.ApplyColor(color);
         _path.ApplyColor(color);
         SignalsManager.Broadcast(_colorSignal.Name, color);
     }
     else
     {
         Lives++;
         SignalsManager.Broadcast(_livesSignal.Name, Lives);
     }
 }
Esempio n. 16
0
        public void OnShipDestroyed()
        {
            _shipSpawner.Flush();
            _lives--;

            if (_lives > 0)
            {
                SignalsManager.Broadcast(_livesCountChangedSignal.Name, _lives);
                this.WaitForSeconds(GameConfiguration.Instance.DelayBetweenSessions, StartGame);
            }
            else
            {
                GameController.Instance.SetState(GameState.GameOver);
            }
        }
Esempio n. 17
0
        public void Enhance(int level)
        {
            var value = _value;

            for (var i = 1; i < level; i++)
            {
                value *= 2;
            }

            GameController.Instance.GameSession.AddScorePoints(value);
            Setup(value);

            SignalsManager.Broadcast(_audioSignal.Name, "merge");
            EffectsManager.Instance.Play(GameConfiguration.Instance.PopSettings.MergeEffect, _value, transform.position);
        }
Esempio n. 18
0
        public void IncreaseScore()
        {
            ++CurrentScore;

            //Use variable from configuration here
            if (CurrentScore % 10 == 0)
            {
                SignalsManager.Broadcast("PassedLineSection");
            }

            if (BestScore > 0)
            {
                if (CurrentScore > BestScore)
                {
                    SignalsManager.Broadcast("BestScoreBeaten");
                }
            }
        }
Esempio n. 19
0
        public void SubtractLive(bool all = false)
        {
            if (all)
            {
                Lives = 0;
            }
            else
            {
                Lives--;
            }

            if (Lives > 0)
            {
                SignalsManager.Broadcast(_livesSignal.Name, Lives);
            }
            else
            {
                _ball.BlowUp();
                GameController.Instance.SetState(GameState.End);
            }
        }
Esempio n. 20
0
        private void OnCollisionEnter(Collision otherCollision)
        {
            var hitPoint = otherCollision.contacts[0].point;

            var racket = otherCollision.gameObject.GetComponentInParent <Racket>();

            if (racket != null)
            {
                var hitFactor = CalculateHitFactor(transform.position, otherCollision.transform.position, otherCollision.collider.bounds.size.x);
                racket.React(hitFactor);

                if (racket.Type == RacketType.Top)
                {
                    _rigidbody.velocity = new Vector2(hitFactor, -1).normalized *_bouncingSpeed;
                }
                else if (racket.Type == RacketType.Bottom)
                {
                    _rigidbody.velocity = new Vector2(hitFactor, 1).normalized *_bouncingSpeed;
                }

                SignalsManager.Broadcast(_hitRacketSignal.Name);
            }
            else
            {
                var bound = otherCollision.gameObject.GetComponent <Bound>();
                if (bound != null)
                {
                    if (HitVerticalBounds(bound.Type))
                    {
                        PlayDestroyEffect(hitPoint);
                        Destroy(gameObject);
                        return;
                    }
                }
            }

            PlayHitEffects(hitPoint);
        }
Esempio n. 21
0
        public void React()
        {
            if (_pop == null)
            {
                return;
            }

            _pop.React();
            SignalsManager.Broadcast(_audioSignal.Name, "slap");

            this.WaitForSeconds(_rectDelayTime, () =>
            {
                var neighbors = GridUtils.GetNeighbors(this);
                for (var i = 0; i < neighbors.Count; i++)
                {
                    var cell = neighbors[i];
                    if (cell.Pop != null)
                    {
                        cell.Pop.React();
                    }
                }
            });
        }
Esempio n. 22
0
        private bool HitVerticalBounds(BoundType boundType)
        {
            var hit = false;

            switch (boundType)
            {
            case BoundType.Top:
            {
                hit = true;
                SignalsManager.Broadcast(_hitTopBoundSignal.Name);
                break;
            }

            case BoundType.Bottom:
            {
                hit = true;
                SignalsManager.Broadcast(_hitBottomBoundSignal.Name);
                break;
            }
            }

            return(hit);
        }
Esempio n. 23
0
 private void OnLevelChange(int level)
 {
     _level.text = string.Format(LocalizationManager.GetString("Level"), level);
     SignalsManager.Broadcast(_audioSignal.Name, _sound);
     NotificationManager.Show(new TextNotification(LocalizationManager.GetString("NewLevel")), 2f);
 }
Esempio n. 24
0
 public override void Broadcast()
 {
     SignalsManager.Broadcast(Signal.Name, Parameter);
 }
Esempio n. 25
0
 public void Merge()
 {
     TryMerge(() => SignalsManager.Broadcast(_updateSignal.Name));
 }
Esempio n. 26
0
 public void BlowUp()
 {
     _renderer.enabled = false;
     SignalsManager.Broadcast(_audioSignal.Name, _failSound);
     NotificationManager.Show(new TextNotification(LocalizationManager.GetString("Ouch")), 2f);
 }
Esempio n. 27
0
 private void OnPointerDown(PointerEventData eventData)
 {
     SignalsManager.Broadcast(_stateChangeSignal.Name, GameState.Play.ToString());
 }
Esempio n. 28
0
 private void OnLevelChange(int level)
 {
     UpdateLevel(level, GameController.Instance.GameSession.Score);
     SignalsManager.Broadcast(_audioSignal.Name, "new_level");
 }
Esempio n. 29
0
 protected override void OnContactHandlerEntered(SpaceObject spaceObject)
 {
     base.OnContactHandlerEntered(spaceObject);
     SignalsManager.Broadcast("PlayAudio", "ship_destroyed");
     Deactivate();
 }
Esempio n. 30
0
 protected override void FireDeactivated()
 {
     base.FireDeactivated();
     SignalsManager.Broadcast(_destroyedSignal.Name);
 }