/// <summary> /// Check if there is a move for player to play /// </summary> /// <returns></returns> private bool LeftMoveCheck() { bool leftMove = false; for (int x = 0; x < this.grid.width && !leftMove; x++) { for (int y = 0; y < this.grid.height && !leftMove; y++) { Vector2 source = new Vector2(x, y); List <Vector2> coords = new List <Vector2>(); coords = selectionMoves.GetSelectionPattern(source); // Get suitable moves for the coord leftMove = this.Explode(new MatchElement(coords), simulate: false).IsActionValid; // Send explode to see if there is any check } } return(leftMove); }
/// <summary> /// When a hexagon is clicked, deselect previous selected hexagons. Calculate grid coord position and available other two hexagon element to complete selection to three hexagon. /// Find their middle anchored coordination and return it. /// </summary> /// <param name="anchoredPositions"></param> /// <returns></returns> public Vector2 ClickedHexagons(Vector2 anchoredPositions) { DeselectHexagons(); Vector2 coordPosition = positionCalculator.AnchoredToCoord(anchoredPositions); selectedCoords = touchMoves.GetSelectionPattern(coordPosition); SetSelectedHexagons(); List <Vector2> selectedAnchored = new List <Vector2>(); foreach (Vector2 vector in selectedCoords) { selectedAnchored.Add(positionCalculator.CoordToAnchored(vector)); } Vector2 middleCoord = positionCalculator.SetMiddleCoord(selectedAnchored); return(middleCoord); }