public void RemoveBrick(BricksAbstract _brick) { if (_brick != null) { unusedBricks.Enqueue(_brick); brickArray[(int)_brick.GetIndex.x, (int)_brick.GetIndex.y] = null; activeBricks.Remove(_brick); _brick.gameObject.SetActive(false); } }
public TextFeedbackBehaviour GetText(BricksAbstract brickValue) { TextFeedbackBehaviour temp = textPool.Dequeue(); temp.gameObject.SetActive(true); temp.SetFeedback(brickValue.GetScore.ToString(), GameConstants.GetColorFromBrick(brickValue.GetColor), brickValue.transform.position, scoreObject.transform.position); textPool.Enqueue(temp); return(temp); }
public BricksAbstract GetBrickAt(Vector2 _index) { BricksAbstract tempBrick = null; try { tempBrick = brickArray[(int)_index.x, (int)_index.y]; } catch (System.Exception) { } return(tempBrick); }
public void GetNeighbours() { Vector2[] indexes = new Vector2[] { new Vector2((int)brickIndexes.x, (int)brickIndexes.y - 1), new Vector2((int)brickIndexes.x + 1, (int)brickIndexes.y), new Vector2((int)brickIndexes.x, (int)brickIndexes.y + 1), new Vector2((int)brickIndexes.x - 1, (int)brickIndexes.y) }; //top, right, bottom, left BricksAbstract[] bricks = new BricksAbstract[indexes.Length]; for (int i = 0; i < bricks.Length; i++) { bricks[i] = BricksManager.SP.GetBrickAt(indexes[i]); } neighbours = bricks; }
public void CreateBox(int _yLength) { for (int i = 0; i < GameConstants.COLUMNCOUNT; i++) { for (int j = 0; j < _yLength; j++) { BricksAbstract _temp = unusedBricks.Dequeue(); brickArray[i, j] = _temp; _temp.gameObject.SetActive(true); _temp.SetPosition(i, j); _temp.SetPosToSide(Random.Range(-15f, 15f)); Sprite _tempSpr = GetRandomBrickSprite(); _temp.SetSprite(_tempSpr, GetColorFromSprite(_tempSpr)); activeBricks.Add(_temp); } } }
/// <summary> /// Ads a row on top of all (at y == 0) /// </summary> public void AddRowOnTop() { if (unusedBricks.Count > GameConstants.COLUMNCOUNT) { MoveAllBricksOneDown(); for (int i = 0; i < GameConstants.COLUMNCOUNT; i++) { BricksAbstract _tempBrick = unusedBricks.Dequeue(); _tempBrick.gameObject.SetActive(true); brickArray[i, 0] = _tempBrick; _tempBrick.SetPosition(i, 0); _tempBrick.SetPosToTop(Random.Range(2f, 5f)); Sprite _temp = GetRandomBrickSprite(); _tempBrick.SetSprite(_temp, GetColorFromSprite(_temp)); activeBricks.Add(_tempBrick); } } }
private void OnCollisionEnter2D(Collision2D collision) { BricksAbstract ab = collision.gameObject.GetComponent <BricksAbstract>(); if (ab != null) { ab.HitBrick(ballPower); FeedbackController.SP.GetText(ab); MatchManager.SP.AddScore(ab.GetScore); hitWiggle.StartTween(0.2f); return; } BorderBehaviour bb = collision.gameObject.GetComponent <BorderBehaviour>(); if (bb != null) { BounceOff(collision.contacts[0].point); } }
public void MoveBrick(BricksAbstract _movedBrick, Vector2 _newPos, int _tryCount, bool randomDelay = false, bool _forceMove = false) { if (isEmpty(_newPos)) { Vector2 _prefPos = _movedBrick.GetIndex; _movedBrick.SetGoalPosition((int)_newPos.x, (int)_newPos.y, randomDelay); brickArray[(int)_newPos.x, (int)_newPos.y] = _movedBrick; brickArray[(int)_prefPos.x, (int)_prefPos.y] = null; } else { if (_forceMove) { BricksAbstract _temp = GetBrickAt(_newPos); Vector2 _prefPos = _movedBrick.GetIndex; _movedBrick.SetGoalPosition((int)_newPos.x, (int)_newPos.y, randomDelay); brickArray[(int)_newPos.x, (int)_newPos.y] = _movedBrick; brickArray[(int)_prefPos.x, (int)_prefPos.y] = null; if (_temp != null) { if (_tryCount <= 0) { Vector2 _tempPos = FindEmptyPlace(); MoveBrick(_temp, _tempPos, 1); } else { _newPos.y++; MoveBrick(_temp, _newPos, _tryCount--); } } } } }