void GemSelectionHandler() { if (mouseRect.Intersects(selectionRect)) { selectedRect = selectionRect; var lastGem = Gem.selectedGem; Gem.selectedGem = gems[selectedRect.Value.Y / 48, selectedRect.Value.X / 48]; if (swappableGems.Contains(Gem.selectedGem)) { Gem.SwapGems(Gem.selectedGem, lastGem); swappableGems.Clear(); return; } swappableGems.Clear(); TrySelect(() => swappableGems.Add(gems[(selectedRect.Value.Y / 48) - 1, (selectedRect.Value.X / 48)])); TrySelect(() => swappableGems.Add(gems[(selectedRect.Value.Y / 48) + 1, (selectedRect.Value.X / 48)])); TrySelect(() => swappableGems.Add(gems[(selectedRect.Value.Y / 48), (selectedRect.Value.X / 48) - 1])); TrySelect(() => swappableGems.Add(gems[(selectedRect.Value.Y / 48), (selectedRect.Value.X / 48) + 1])); } }
void GemSelectionHandler() //called by OnLeftClick() { if (mouseRect.Intersects(selectionRect)) { selectedRect = selectionRect; var lastGem = Gem.selectedGem; Gem.selectedGem = Gems[selectedRect.Value.Y / Size, selectedRect.Value.X / Size]; if (swappableGems.Contains(Gem.selectedGem)) { Gem.SwapGems(Gem.selectedGem, lastGem); swappableGems.Clear(); GameLogic.Instance.CheckWin(Gems); return; } swappableGems.Clear(); TrySelect(() => swappableGems.Add(Gems[(selectedRect.Value.Y / Size) - 1, (selectedRect.Value.X / Size)])); TrySelect(() => swappableGems.Add(Gems[(selectedRect.Value.Y / Size) + 1, (selectedRect.Value.X / Size)])); TrySelect(() => swappableGems.Add(Gems[(selectedRect.Value.Y / Size), (selectedRect.Value.X / Size) - 1])); TrySelect(() => swappableGems.Add(Gems[(selectedRect.Value.Y / Size), (selectedRect.Value.X / Size) + 1])); } }