public void GenerateParticles(float delay, Vector2 position)
        {
            var newParticleEffect = _simpleObjectPool.GetObjectFromPool();

            newParticleEffect.transform.SetParent(ParticleContainer.transform);
            var particleEffect = newParticleEffect.GetComponent <PowerGemParticleEffect>();

            particleEffect.Reset(delay, position, ParticleTarget);
            Debug.Log("** CREATED " + newParticleEffect.name);
        }
 private void DisplayLevels()
 {
     foreach (var level in Levels)
     {
         var levelIcon    = _iconPool.GetObjectFromPool();
         var levelSummary = level.GetComponent <ILevelDataController>();
         levelIcon.GetComponent <LevelBrowserIconController>().Model = levelSummary;
         levelIcon.transform.SetParent(IconContainer.transform);
     }
 }
        public void ShowScore(int score, Vector3 ballPosition, float delay)
        {
            var newScoreText        = _scoreTextPool.GetObjectFromPool();
            var floatingScoreEffect = newScoreText.GetComponent <FloatingScoreEffect>();

            var textPosition = _camera.WorldToScreenPoint(ballPosition + PositionOffset);

            textPosition = textPosition.RandomOffset(PositionJitter);
            floatingScoreEffect.Reset(delay, score, textPosition);
            newScoreText.transform.SetParent(Container.transform);
        }
Ejemplo n.º 4
0
        public GameObject GenerateBall(BallType type)
        {
            var newBall        = _simpleObjectPool.GetObjectFromPool();
            var ballController = newBall.GetComponent <IBallController>();

            ballController.BallType  = type;
            ballController.Magnitude = BallMagnitude.Standard;

            Logging.Instance.Log(LogLevel.Debug, "Created ball outside of grid, of type : " + type);
            return(newBall);
        }
Ejemplo n.º 5
0
        private void OnOrphansFound(OrphanedBallsEventArgs e)
        {
            foreach (var ballController in e.OrphanedBalls)
            {
                var fallingBall = _simpleObjectPool.GetObjectFromPool();
                fallingBall.transform.SetParent(BallContainer.transform);

                var orphanedBall = ballController.gameObject;
                var ballPosition = orphanedBall.GetComponent <Rigidbody2D>().position;
                fallingBall.GetComponent <Rigidbody2D>().position = ballPosition;
                fallingBall.GetComponent <Rigidbody2D>().AddForce(random.RandomVector(RandomForceMagnitude));

                var ballSprite = ballController.CurrentBallSprite;
                fallingBall.GetComponent <SpriteRenderer>().sprite = ballSprite;
            }
        }
        private void OnBallDestroyed(BallDestroyByGiantLaserEventArgs obj)
        {
            var ball         = obj.BallController;
            var ballPosition = ball.Position;
            var newExplosion = _simpleObjectPool.GetObjectFromPool();

            newExplosion.transform.SetParent(transform);
            newExplosion.transform.position = ballPosition;

            var planetSprite   = ball.CurrentBallSprite;
            var magnitudeScale = ball.Magnitude.GetScale();

            var ballDestroyEffect = newExplosion.GetComponent <BallDestroyedByLaserEffect>();

            ballDestroyEffect.RePlayEffect(planetSprite, magnitudeScale);
            _floatingScoreEffectGenerator.ShowScore(GameConstants.ScorePerBall, ballPosition, 0);
        }
Ejemplo n.º 7
0
        private void DestroyOneBall(IBallController ball, float delay)
        {
            var ballPosition = ball.Position;
            var newExplosion = _simpleObjectPool.GetObjectFromPool();

            newExplosion.transform.SetParent(transform);
            newExplosion.transform.position = ballPosition;

            var planetSprite = ball.CurrentBallSprite;

            var ballDestroyEffect = newExplosion.GetComponent <BallDestroyEffect>();

            ballDestroyEffect.RePlayEffect(delay, planetSprite, ball.HasPowerGem);
            _floatingScoreEffectGenerator.ShowScore(GameConstants.ScorePerBall, ballPosition, delay);
            if (ball.HasPowerGem)
            {
                _powerGemParticleEffectGenerator.GenerateParticles(delay, ballPosition);
            }
        }