public void ReigsterSelf(IBubble bubble) { chainedBubbles.Clear(); chainedBubbles = new List <IBubble>(); chainedBubbles.Add(bubble); ((IBubbleDetect)bubble).RegisterNeighbors(); }
public void Update() { if (Input.GetMouseButton(0)) { Vector2 posi = shootPosition.position; RaycastHit2D hit2D = Physics2D.Raycast(posi, new Vector2(Input.mousePosition.x, Input.mousePosition.y) - (new Vector2(posi.x, posi.y)), Mathf.Infinity); if (hit2D) { Debug.Log(hit2D.transform.name); _currentSelection = hit2D.transform.GetComponent <IBubble>(); _targetPosi = _currentSelection.GetNearestAvailableNeighbour(hit2D.point); ShootBubble(); } } else if (Input.touchCount > 0) { Vector2 posi = shootPosition.position; RaycastHit2D hit2D = Physics2D.Raycast(posi, new Vector2(Input.GetTouch(0).position.x, Input.GetTouch(0).position.y) - (new Vector2(posi.x, posi.y)), Mathf.Infinity); if (hit2D) { Debug.Log(hit2D.transform.name); _currentSelection = hit2D.transform.GetComponent <IBubble>(); _targetPosi = _currentSelection.GetNearestAvailableNeighbour(hit2D.point); } } if (_previousTargetPosi != _targetPosi) { //DisplayPrediction(_targetPosi); } _previousTargetPosi = _targetPosi; }
private void MergeAndCreateNew(IBubble inBubble) { foreach (var bubble in _checkedBubbles) { bubble.Merge(inBubble); } BubbleManager.Instance.CreateBubble(inBubble.BubbleCoordinate().x, inBubble.BubbleCoordinate().y, _mergeResult); StartAfterDelay(inBubble); }
private async void StartAfterDelay(IBubble inBubble) { await Task.Delay(400); BubbleManager.Instance.GetBubble(inBubble.BubbleCoordinate().x, inBubble.BubbleCoordinate().y).StartMerge(); await Task.Delay(100); if (_mergeResult <= 2048) { BubbleManager.Instance.GetBubble(inBubble.BubbleCoordinate().x, inBubble.BubbleCoordinate().y).Pop(); } }
public List <IBubble> GetMatchingNeighbors() { Collider2D[] cols = Physics2D.OverlapCircleAll(new Vector2(transform.position.x, transform.position.y), Game.Manager.bubbleRadius, 1 << LayerMask.NameToLayer("Bubble")); List <IBubble> matchingNeighbors = new List <IBubble>(); foreach (Collider2D col in cols) { IBubble bubble = col.GetComponent <IBubble>(); if (bubble == null) { continue; } if (bubble != this && bubble.BubbleColor == BubbleColor) { matchingNeighbors.Add(bubble); } } //this.DebugError( "neighborCount: " + matchingNeighbors.Count + " ID " + this.ID ) ; return(matchingNeighbors); }
public void SetNode(int x, int y, IBubble bubble) { _bubbles[_gridManager.Nodes[x, y]] = bubble; bubble.BubbleTransform().GetComponent <Bubble>().CurrentNode = _gridManager.Nodes[x, y]; }
public MergeHandler(IBubble invoker) { _invoker = invoker; }