Ejemplo n.º 1
0
        public void AddNewRowToMatrix()
        {
            bool overflows = _gameManager.GetBubbleMatrix().ShiftOneRow();

            for (int i = 0; i < this._geoInfo.Columns; i++)
            {
                BubbleElement bubble = _CreateBubble(_bubbleContainer.transform, CURRENT_BUBBLE_SCALE, true);
                bubble.IsMoving = false;
                _gameManager.GetBubbleMatrix().AddBubble(bubble, 0, i);
            }

            foreach (var bubble in _controlledBubbles)
            {
                if (bubble != _currentBubble && bubble != _nextBubble)
                {
                    Vector3 position = _gameManager.GetPositionFromCellCoord(_gameManager.GetBubbleMatrix().GetBubbleLocation(bubble));
                    bubble.transform.localPosition = position;
                }
            }

            if (overflows)
            {
                OnChangeGameState(GameState.Loose);
                return;
            }
        }
Ejemplo n.º 2
0
        public void RemoveBubble(BubbleElement bubble, int x, int y)
        {
            if (x < 0 || x > this._rows - 1 || y < 0 || y > this._columns - 1)
            {
                throw new System.ArgumentException("Removing Bubble from wrong coordinates");
            }

            _matrix[x, y] = null;
        }
Ejemplo n.º 3
0
        public void AddBubble(BubbleElement bubble, int x, int y)
        {
            if (x < 0 || x > this._rows - 1 || y < 0 || y > this._columns - 1)
            {
                throw new System.ArgumentException("Adding Bubble to wrong coordinates");
            }

            _matrix[x, y] = bubble;
        }
Ejemplo n.º 4
0
 private Vector3 _OnShootingBubbleArrived(BubbleElement arrivedBubble)
 {
     arrivedBubble.transform.SetParent(_bubbleContainer.transform);
     arrivedBubble.transform.SetAsLastSibling();
     _nextBubble.transform.position = _currentBubbleRoot.transform.position;
     _nextBubble.transform.Translate(Vector3.forward * _gameManager.GetBubbleMatrixGeoInfo().Depth);
     _nextBubble.transform.localScale = CURRENT_BUBBLE_SCALE;
     _currentBubble = _nextBubble;
     _nextBubble    = _CreateBubble(_nextBubbleRoot, NEXT_BUBBLE_SCALE, false);
     return(_gameManager.AdjustPosition(arrivedBubble, arrivedBubble.transform.localPosition));
 }
Ejemplo n.º 5
0
        public Vector3 AdjustPosition(BubbleElement bubble, Vector3 position)
        {
            var y = Convert.ToInt32(Mathf.Floor((position.x - _geoInfo.LeftBorder) / (2 * _geoInfo.BubbleRadius)));
            var x = Convert.ToInt32(Mathf.Floor(_geoInfo.TopBorder - position.y) / (1.8 * _geoInfo.BubbleRadius));

            _matrix.AddBubble(bubble, x, y);

            float newPosY  = (float)(_geoInfo.TopBorder - x * _geoInfo.BubbleRadius * 1.8);
            float newPostX = _geoInfo.LeftBorder + y * _geoInfo.BubbleRadius * 2;

            return(new Vector3(newPostX, newPosY, _geoInfo.Depth));
        }
Ejemplo n.º 6
0
        public void Initialize(Difficulty difficulty)
        {
            _geoInfo       = new BubbleMatrixGeoInfo(_leftBorder, _rightBorder, _topBorder, _rows, _columns, _bubbleRadius);
            _gameManager   = BubbleMatrixManager.GetInstance(_rows, _columns, _geoInfo, difficulty);
            _currentBubble = _CreateBubble(_currentBubbleRoot, CURRENT_BUBBLE_SCALE, false);
            _nextBubble    = _CreateBubble(_nextBubbleRoot, NEXT_BUBBLE_SCALE, false);

            for (int i = 0; i < 4; ++i)
            {
                AddNewRowToMatrix();
            }
        }
Ejemplo n.º 7
0
 public Vector2 GetBubbleLocation(BubbleElement bubble)
 {
     for (int i = 0; i < this._rows; i++)
     {
         for (int j = 0; j < this._columns; j++)
         {
             BubbleElement someBubble = _matrix[i, j];
             if (bubble == someBubble)
             {
                 return(new Vector2(i, j));
             }
         }
     }
     return(new Vector2(-1, -1));
 }
Ejemplo n.º 8
0
 public List <BubbleElement> SearchBubbleNeighbor(BubbleElement bubble, int targetColorIndex)
 {
     return(null);
 }