コード例 #1
0
        private void RestoringPositionalBinding(object sender, PositionalEventArgs <TBoard> e)
        {
            Dispatcher.Invoke((Action) delegate()
            {
                foreach (UIElement child in this.Children)
                {
                    if (!(child is PositionalUI <TBoard>))
                    {
                        continue;
                    }

                    PositionalUI <TBoard> childUI = child as PositionalUI <TBoard>;

                    if (childUI.Logic.Equals(e.Positional))
                    {
                        DoubleAnimation animateOpacity = new DoubleAnimation();
                        animateOpacity.From            = 0;
                        animateOpacity.To        = 1;
                        animateOpacity.Duration  = TimeSpan.Parse("0:0:2");
                        animateOpacity.BeginTime = TimeSpan.Parse("0:0:0.75");
                        childUI.BeginAnimation(OpacityProperty, animateOpacity);

                        break;
                    }
                }
            });
        }
コード例 #2
0
        private void RemovingPositionalBinding(object sender, PositionalEventArgs <TBoard> e)
        {
            Dispatcher.Invoke((Action) delegate()
            {
                foreach (UIElement child in this.Children)
                {
                    // we do not bother with things that are not of type PositionalUI onwards
                    if (!(child is PositionalUI <TBoard>))
                    {
                        continue;
                    }

                    PositionalUI <TBoard> childUI = child as PositionalUI <TBoard>;

                    if (childUI.Logic.Equals(e.Positional))
                    {
                        Children.Remove(childUI);
                        break;
                    }
                }
            });

            // wow the image is removed from the BoardUI.
            // but the collidable still exists in the Board, so monkey will seem to collide with empty air. Let's remove that, shall we?
            foreach (Positional <TBoard> p in Board.CollisionManager.CollidableList)
            {
                if (p.Equals(e.Positional))
                {
                    Board.CollisionManager.CollidableList.Remove(p as Collidable <TBoard>);
                    break;
                }
            }
        }
コード例 #3
0
        private void TempRemovingPositionalBinding(object sender, PositionalEventArgs <TBoard> e)
        {
            Dispatcher.Invoke((Action) delegate()
            {
                foreach (UIElement child in this.Children)
                {
                    if (!(child is PositionalUI <TBoard>))
                    {
                        continue;
                    }

                    PositionalUI <TBoard> childUI = child as PositionalUI <TBoard>;

                    if (childUI.Logic.Equals(e.Positional))
                    {
                        childUI.Opacity = 0;
                        break;
                    }
                }
            });
        }