public void OnMouseDown() { if (elementController.canPlay && !hasGoalPosition) { if (selectedElement == null) { SelectElement(this); } else { if (selectedElement == this) { SelectElement(null); } else { if (Mathf.Abs(selectedElement.fieldPosition.x - fieldPosition.x) + Mathf.Abs(selectedElement.fieldPosition.y - fieldPosition.y) == 1) { ElementController.GetInstance().Swap(this, selectedElement, true); SelectElement(null); } else { SelectElement(this); } } } } }
public Game() { elementController = ElementController.GetInstance(); elementController.game = this; }