Пример #1
0
 private void MakeSelected(Stone selectedStone)
 {
     selectedStone.IsAvailable = false;
     selectedStone.IsSelected  = true;
     ChangeStroke(selectedStone, Colors.StrokeSelected);
     SelectedStones.Add(selectedStone.Location);
 }
Пример #2
0
 public void SelectStone(Stone selectedStone)
 {
     if (selectedStone.IsAvailable && !selectedStone.IsSelected)
     {
         MakeSelected(selectedStone);
         DetermineAvailableStones();
     }
     else if (selectedStone.IsSelected)
     {
         SelectedStones.Remove(selectedStone.Location);
         MakeAvailable(selectedStone);
         DetermineAvailableStones();
     }
 }
Пример #3
0
        private void MakeStoneOfANeighboringColorAvailable(Stone selectedStone, Stone currentStone)
        {
            bool isNeighboring           = IsANeighboringColor(selectedStone.Fill, currentStone.Fill);
            bool sameRow                 = currentStone.Location.Row == selectedStone.Location.Row;
            bool sameColumn              = currentStone.Location.Column == selectedStone.Location.Column;
            bool sameDiagonal            = IsOnTheSameDiagonal(selectedStone, currentStone);
            bool sameRowColumnOrDiagonal = sameRow || sameColumn || sameDiagonal;
            bool colorIsAlreadySelected  = SelectedStones.Where(s => Triangle[s.Row][s.Column].Fill.ToString().Equals(currentStone.Fill.ToString())).Count() > 0;

            if (sameRowColumnOrDiagonal && isNeighboring && !colorIsAlreadySelected)
            {
                MakeAvailable(currentStone);
            }
        }