Beispiel #1
0
 public override void Select()
 {
     Toolbox.Instance.gameState.MoneyCounter += SellPrice;
     if (All.Count(s => s is Sellable) == 1)
     {
         EndAnimation.Play();
     }
     Destroy(gameObject);
 }
Beispiel #2
0
        private void AnimationCommandExtension_BindingContextChanged(object sender, EventArgs e)
        {
            var bo = (BindableObject)sender;

            try
            {
                //Command wrap
                var command = new Command(async() =>
                {
                    var control         = (View)((GestureRecognizer)sender).Parent;
                    var animationToPlay = StartAnimation ?? new DefaultAnimation();
                    try
                    {
                        if (control != null)
                        {
                            await animationToPlay.Play(control);
                        }
                    }
                    catch
                    {
                        Debug.WriteLine($"{nameof(AnimationCommandExtension)}.StartAnimation Exception");
                    }

                    try
                    {
                        var baseCommand = (ICommand)MarkupExtensionHelper.ExtractMember(bo, (Binding)Binding);
                        if (baseCommand != null && baseCommand.CanExecute(_parameter))
                        {
                            baseCommand.Execute(_parameter);
                        }
                    }
                    catch (Exception exception)
                    {
                        Debug.WriteLine(exception.Message);
                    }

                    try
                    {
                        if (EndAnimation != null && control != null)
                        {
                            await EndAnimation.Play(control);
                        }
                    }
                    catch
                    {
                        Debug.WriteLine($"{nameof(AnimationCommandExtension)}.EndAnimation Exception");
                    }
                });

                bo.SetValue(_property, command);
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
                bo.SetValue(_property, null);
            }
        }