Beispiel #1
0
        public void OnClick(PointyHexPoint point)
        {
            LinesCell clickedCell = grid[point];

            if (isHoldingCell)
            {
                if (clickedCell.IsEmpty)
                {
                    MoveCell(clickedCell);

                    if (!ClearLinesAroundPoint(point))
                    {
                        AddNewCells();
                    }                     //otherwise, give the player a "free" turn.
                }
                else if (clickedCell == cellThatIsBeingHeld)
                {
                    DropCell();
                }
            }
            else
            {
                if (!clickedCell.IsEmpty)
                {
                    PickUpCell(clickedCell);
                }
            }
        }
Beispiel #2
0
 private void MoveCell(LinesCell clickedCell)
 {
     cellThatIsBeingHeld.HighlightOn = false;
     SwapCells(cellThatIsBeingHeld, clickedCell);
     cellThatIsBeingHeld = null;
     isHoldingCell       = false;
 }
Beispiel #3
0
        private static void SwapCells(LinesCell cell1, LinesCell cell2)
        {
            int  tempColor   = cell1.Type;
            bool tempIsEmpty = cell1.IsEmpty;

            cell1.SetState(cell2.IsEmpty, cell2.Type);
            cell2.SetState(tempIsEmpty, tempColor);
        }
Beispiel #4
0
 private void DropCell()
 {
     cellThatIsBeingHeld.HighlightOn = false;
     cellThatIsBeingHeld             = null;
     isHoldingCell = false;
 }
Beispiel #5
0
 private void PickUpCell(LinesCell clickedCell)
 {
     cellThatIsBeingHeld     = clickedCell;
     isHoldingCell           = true;
     clickedCell.HighlightOn = true;
 }
Beispiel #6
0
        private void SetCellToRandom(LinesCell cell)
        {
            int newColor = (Random.Range(0, colorCount));

            cell.SetState(false, newColor);
        }