public void Select(Candy candy) { if (_selected == candy) { return; } if (_selected) { var prevPosition = CandyToMatrixPosition(_selected); var position = CandyToMatrixPosition(candy); if (Adjacent(prevPosition, position)) { _selected.Select(false); _selected = null; StartCoroutine(Swap(prevPosition, position)); } else { _selected.Select(false); _selected = candy; _selected.Select(true); } } else { _selected = candy; _selected.Select(true); } }
public void Select(Candy candy) { if (_selected == candy) return; SoundManager.Instance.Play (SoundType.Select); if (_selected) { var prevPosition = CandyToMatrixPosition (_selected); var position = CandyToMatrixPosition (candy); if (Adjacent (prevPosition, position)) { _selected.Select(false); _selected = null; StartCoroutine(Swap(prevPosition, position)); } else { _selected.Select(false); _selected = candy; _selected.Select(true); } } else { _selected = candy; _selected.Select (true); } }