Exemple #1
0
        private void HandleButtonClick(object sender, EventArgs e)
        {
            IVector2D <int> buttonPosition;
            var             positionWasFound = GridUtils.TryGetPositionOf(sender as Button, this, out buttonPosition);

            if (!positionWasFound)
            {
                throw new IndexOutOfRangeException("The button was not found in the grid.");
            }

            var args = new ButtonGridClickedArgs(buttonPosition);

            ButtonClicked.Invoke(sender, args);
        }
Exemple #2
0
        private void ButtonGrid_ButtonClicked(object sender, ButtonGridClickedArgs args)
        {
            // Determine state of game and handle accordingly.
            switch (gameState)
            {
            case GameState.Placement:
                HandlePlacementPhaseTileClick(tilePosition: args.ButtonPosition);
                break;

            case GameState.InPlay:
                HandleInPlayTileClick(tilePosition: args.ButtonPosition);
                break;
            }
            UpdateVisuals();
        }