public void GetAllControllers() { if (bonusController == null) { var bonus = Core.GetCore.GetController <BonusController>(); if (bonus != null) { bonusController = bonus; } } if (paddleController == null) { var paddle = Core.GetCore.GetController <PaddleController>(); if (paddle != null) { paddleController = paddle; } } if (ballController == null) { var ball = Core.GetCore.GetController <BallController>(); if (ball != null) { ballController = ball; } } isNeedControllers = false; }
public BonusController(Sprite[] bonusSprites, GameObject bonusPrefab) { spriteDict = new Dictionary <int, Sprite>() { { 0, bonusSprites[0] }, { 1, bonusSprites[1] }, { 2, bonusSprites[2] }, { 3, bonusSprites[3] }, }; bonusActions = new Dictionary <int, Action <Bonus> >() { { 0, ExtraBall }, { 1, IncreasePaddleLenght }, { 2, SpeedUpBalls }, { 3, SLowDownBalls }, }; this.bonusPrefab = bonusPrefab; currentBonuses = new List <Bonus>(); poolBonuses = new Queue <Bonus>(); coreUI = Core.GetCoreUI; var core = Core.GetCore; paddleController = core.GetController <PaddleController>(); gameController = core.GetController <GameController>(); ballController = core.GetController <BallController>(); }
private void Awake() { _paddle = FindObjectOfType <PaddleController>(); if (_paddle == null) { Debug.LogError("No PaddleController was found"); return; } _offset = new Vector3(0, _paddle.BallOffset, 0); _rigidbody2D = GetComponent <Rigidbody2D>(); if (_rigidbody2D == null) { Debug.LogError("No Rigidbody2D component on the ball object"); return; } _audioSource = GetComponent <AudioSource>(); if (_audioSource == null) { Debug.LogError("No AudioSource component on the ball object"); return; } }