public void SetPosition(BubbleGrid parentGrid, Dimension position) { neighborsColor = Color.red; this._parentGrid = parentGrid; this.gridPosition = position; if (gridPosition.rows == 0) { isConnected = true; } var firstBubble = this._parentGrid.GetFirstRowBubble(); if (firstBubble != null && firstBubble.isShifted) { this._lastOffset = position.rows % 2 == 0 ? _parentGrid.rowsOffset : 0f; } else { this._lastOffset = position.rows % 2 == 0 ? 0f : _parentGrid.rowsOffset; } isShifted = _lastOffset > 0; this.scenePosition = new Vector3( ((this.gridPosition.columns * _parentGrid.bubbleSize) - _parentGrid.firstBubblePos.x) + _lastOffset + _parentGrid.leftPadding, (((-this.gridPosition.rows * _parentGrid.bubbleSize) + _parentGrid.firstBubblePos.y) + _parentGrid.topPadding), 0f); transform.position = scenePosition; }
public void SetNewLinePosition(BubbleGrid parentGrid, Dimension position) { this._parentGrid = parentGrid; this.gridPosition = position; if (gridPosition.rows == 0) { isConnected = true; } isShifted = this._lastOffset > 0; this.scenePosition = new Vector3( ((this.gridPosition.columns * _parentGrid.bubbleSize) - _parentGrid.firstBubblePos.x) + this._lastOffset + _parentGrid.leftPadding, (((-this.gridPosition.rows * _parentGrid.bubbleSize) + _parentGrid.firstBubblePos.y) + _parentGrid.topPadding), 0f); if (!HandleAnimation(BubbleAnimations.NewLine)) { return; } StopCoroutine("DOMove"); animation = BubbleAnimations.NewLine; StartCoroutine(DOMove(scenePosition, _parentGrid.newLineSpeed, () => { transform.localScale = this._startScale; })); }
public virtual void Start() { int c = UnityEngine.Random.Range(0, 4); switch (c) { case (0): m_Color = Color.red; break; case (1): m_Color = Color.green; break; case (2): m_Color = Color.blue; break; case (3): m_Color = Color.yellow; break; } GetComponent <Renderer>().material.color = m_Color; m_isSeperated = false; m_bubbleGrid = GameObject.FindGameObjectWithTag("BubbleGrid").GetComponent <BubbleGrid>(); }
void Start() { _grid = this.GetComponent <BubbleGrid>(); _visited = new bool[G.rows, G.cols]; cannon.transform.position = GetShooterPosition(); LoadNextLevel(); }
public void SpawnNewBubble(BubbleGrid parentGrid, Dimension position, float offset) { this._parentGrid = parentGrid; this.gridPosition = position; if (gridPosition.rows == 0) { isConnected = true; } if (offset <= -100) { this._lastOffset = position.rows % 2 == 0 ? 0f : _parentGrid.rowsOffset; } else { this._lastOffset = offset; } isShifted = _lastOffset > 0; this.scenePosition = new Vector3( ((this.gridPosition.columns * _parentGrid.bubbleSize) - _parentGrid.firstBubblePos.x) + _lastOffset + _parentGrid.leftPadding, (((-this.gridPosition.rows * _parentGrid.bubbleSize) + _parentGrid.firstBubblePos.y) + _parentGrid.topPadding), 0f); transform.localPosition = this.scenePosition; transform.localScale = Vector3.zero; if (!HandleAnimation(BubbleAnimations.Spawn)) { return; } StopCoroutine("DOScale"); animation = BubbleAnimations.Spawn; StartCoroutine(DOScale(this._startScale, _parentGrid.spawnSpeed)); }