/// <summary>
        /// Handles the tapping of a image once guessing phase has started
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="ev"></param>
        private void OnTapped(object sender, EventArgs ev)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            bool found;

            try
            {
                Image img = sender as Image;
                found = _sequentialGamePlayViewModel.CheckSequence(img);
                if (found)
                {
                    Image sImage = new Image {
                        Source = img.Source
                    };

                    if (SelectedImageStackLayout.Children.Count > 2)
                    {
                        SelectedImageStackLayout.Children.RemoveAt(0);
                    }
                    SelectedImageStackLayout.Children.Add(sImage);
                }
                else
                {
                    Failed.IsVisible = true;
                    SequenceStackLayout.Children.Clear();
                    Content = Failed;
                }
                if (_sequentialGamePlayViewModel.CheckIsRoundComplete())
                {
                    GameStat.Level = _sequentialGamePlayViewModel.GameModel.Level;
                    UpdateStatusHelper.UpdateStatus(GameStat);
                    SequenceStackLayout.Children.Clear();
                    NextRound();
                }
            }
            catch (Exception e)
            {
                //todo look at what might fail and how to handle
                Console.WriteLine(e);
                throw;
            }
            finally
            {
                IsBusy = false;
            }
        }
Example #2
0
        /// <summary>
        /// Handles the tapping of a image once guessing phase has started
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="ev"></param>
        private void OnTapped(object sender, EventArgs ev)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            bool found;

            try
            {
                Grid.IsEnabled = false;
                Image img = sender as Image;
                found = _whatYouSeeGamePlayViewModel.CheckSelections(img);
                if (found)
                {
                    if (img != null)
                    {
                        img.Opacity   = 0.5;
                        img.IsEnabled = false;
                    }
                }
                else
                {
                    StackLayout.IsVisible = false;
                    Failed.IsVisible      = true;
                }

                if (_whatYouSeeGamePlayViewModel.CheckIsRoundComplete())
                {
                    GameStatus.Level = _whatYouSeeGamePlayViewModel.GameModel.Level;
                    UpdateStatusHelper.UpdateStatus(GameStatus);

                    NextRound();
                }
            }
            catch (Exception e)
            {
                //todo look at what might fail and how to handle
                Console.WriteLine(e);
                throw;
            }
            finally
            {
                Grid.IsEnabled = true;
                IsBusy         = false;
            }
        }
        /// <summary>
        /// Handles the clicking of a button once guessing phase has started
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="ev"></param>
        private void OnTapped(object sender, EventArgs ev)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;
            bool found = false;

            try
            {
                Grid.IsEnabled = false;
                Button btn = sender as Button;

                if (_colourComplexGamePlayViewModel.Mode == Mode.Text)
                {
                    found = _colourComplexGamePlayViewModel.CheckSequenceText(btn.Text);
                }
                else if (_colourComplexGamePlayViewModel.Mode == Mode.Color)
                {
                    found = _colourComplexGamePlayViewModel.CheckSequenceColour(btn.TextColor);
                }
                if (found)
                {
                    Label label = new Label
                    {
                        Text           = btn.Text,
                        TextColor      = System.Drawing.Color.FromName(btn.Text),
                        FontSize       = 25,
                        FontAttributes = FontAttributes.Bold,
                        Margin         = new Thickness(0, 2, 5, 0)
                    };

                    if (SelectedStackLayout.Children.Count > 2)
                    {
                        SelectedStackLayout.Children.RemoveAt(0);
                    }
                    SelectedStackLayout.Children.Add(label);
                }
                else
                {
                    Failed.IsVisible = true;
                    SequenceStackLayout.Children.Clear();
                    Content = Failed;
                }
                if (_colourComplexGamePlayViewModel.CheckIsRoundComplete())
                {
                    GameStatus.Level = _colourComplexGamePlayViewModel.GameModel.Level;
                    UpdateStatusHelper.UpdateStatus(GameStatus);

                    NextRound();
                }
            }
            catch (Exception e)
            {
                //TODO: throw the exception and handle it properly idiot !!
                Console.WriteLine(e);
                throw;
            }
            finally
            {
                Grid.IsEnabled = true;
                IsBusy         = false;
            }
        }