/// <summary>
 /// Clear current selectin
 /// </summary>
 void ClearSelection()
 {
     foreach (GameObject obj in SelectedTiles)
     {
         RemoveSelection(obj.transform);
     }
     SelectedTiles.Clear();
 }
Пример #2
0
        public void OnTileClicked(object sender, MahjongTile ClickedTile)
        {
            SelectedTiles.Add(ClickedTile);

            if (SelectedTiles.Count == 2)
            {
                if (SelectedTiles[0] == SelectedTiles[1])
                {
                    SelectedTiles.RemoveAt(1);
                    return;
                }

                int x1 = SelectedTiles[0].TileVector.X;
                int y1 = SelectedTiles[0].TileVector.Y;
                int z1 = SelectedTiles[0].TileVector.Z;
                int x2 = SelectedTiles[1].TileVector.X;
                int y2 = SelectedTiles[1].TileVector.Y;
                int z2 = SelectedTiles[1].TileVector.Z;

                bool FirstTileAccessible  = TileStore[x1 - 1, y1, z1] == null || TileStore[x1 + 1, y1, z1] == null;
                bool SecondTileAccessible = TileStore[x2 - 1, y2, z2] == null || TileStore[x2 + 1, y2, z2] == null;
                bool SameTile             = SelectedTiles[0].GetTileIndex() == SelectedTiles[1].GetTileIndex();

                if (FirstTileAccessible && SecondTileAccessible && SameTile)
                {
                    Console.WriteLine("Tile able to destroy");
                }
                else
                {
                    SelectedTiles[0].IsHovered = false;
                    SelectedTiles[0].IsClicked = false;
                    SelectedTiles[0].TileCanvas.Invalidate();
                    SelectedTiles[1].IsHovered = false;
                    SelectedTiles[1].IsClicked = false;
                    SelectedTiles[1].TileCanvas.Invalidate();
                    SelectedTiles.Clear();
                    return;
                }

                WindowHandle.Controls.Remove(SelectedTiles[0].TileCanvas);
                WindowHandle.Controls.Remove(SelectedTiles[1].TileCanvas);

                TileStore[x1, y1, z1] = null;
                TileStore[x2, y2, z2] = null;

                SelectedTiles.Clear();

                if (!CheckForCompletition())
                {
                    WindowHandle.PopulateBoard(WindowHandle);
                }
            }
        }
Пример #3
0
 public static void DeselectAll(TileTab tab)
 {
     SelectedTiles.Clear();
 }