当前位置: 首页>>代码示例>>C#>>正文


C# Field.RefreshPipes方法代码示例

本文整理汇总了C#中Field.RefreshPipes方法的典型用法代码示例。如果您正苦于以下问题:C# Field.RefreshPipes方法的具体用法?C# Field.RefreshPipes怎么用?C# Field.RefreshPipes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Field的用法示例。


在下文中一共展示了Field.RefreshPipes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FieldTest

        public FieldTest()
        {
            this.Width = DefaultWidth;
            this.Height = DefaultHeight;

            var f = new Field(6, 4)
                {
                    ShowSelection = true
                };

            #region round the corners
            f.Tiles[0, 0].Hide();
            f.Tiles[f.Tiles.SizeX - 1, 0].Hide();
            f.Tiles[f.Tiles.SizeX - 1, f.Tiles.SizeY - 1].Hide();
            f.Tiles[0, f.Tiles.SizeY - 1].Hide();
            #endregion

            f[2, 0] = new SimplePipe.PumpToLeft();

            f[1, 0] = new SimplePipe.RightToBottom();
            f[1, 1] = new SimplePipe.Vertical();
            f[1, 2] = new SimplePipe.TopToRight();
            f[2, 2] = new SimplePipe.Cross();
            f[3, 2] = new SimplePipe.Horizontal();
            f[4, 2] = new SimplePipe.LeftToDrain();

            f[2, 1] = new SimplePipe.RightToBottom();
            f[2, 3] = new SimplePipe.TopToLeft();
            f[3, 1] = new SimplePipe.Horizontal();
            f[4, 1] = new SimplePipe.TopToLeft();
            f[4, 0] = new SimplePipe.LeftToBottom();
            f[3, 0] = new SimplePipe.RightToDrain();
            f[1, 3] = new SimplePipe.PumpToRight();

            f[4, 2].Output.Drain = f[1, 3].Input.Pump;

            // show a hole in the floor
            f.Tiles[3, 0].Drain.Visibility = System.Windows.Visibility.Visible;
            f.Tiles[4, 2].Drain.Visibility = System.Windows.Visibility.Visible;

            // user must click on the pump to activate it
            f.Tiles[2, 0].Overlay.MouseLeftButtonUp +=
                delegate
                {
                    f[2, 0].Input.Pump();
                };

            // when a user adds a pipe on top of another
            // we need to call this to force a zorder sort
            f.RefreshPipes();

            var x = (DefaultWidth - f.Tiles.Width) / 2;
            var y = (DefaultHeight - f.Tiles.Height) / 2;

            f.Container.MoveTo(x, y).AttachTo(this);

            #region overlay
            var Overlay = new Canvas
            {
                Width = DefaultWidth,
                Height = DefaultHeight,
            }.AttachTo(this);

            new Rectangle
            {
                Fill = Brushes.White,
                Width = DefaultWidth,
                Height = DefaultHeight,
                Opacity = 0
            }.AttachTo(Overlay);

            f.Tiles.Overlay.MoveTo(x, y).AttachTo(Overlay);
            #endregion
        }
开发者ID:skdhayal,项目名称:avalonpipemania,代码行数:74,代码来源:FieldTest.cs

示例2: InteractiveFieldTest

        public InteractiveFieldTest()
        {
            this.Width = DefaultWidth;
            this.Height = DefaultHeight;

            var f = new Field(8, 8)
            {
                DefaultPipeColor = Colors.Green
            };

            #region round the corners
            f.Tiles[0, 0].Hide();
            f.Tiles[f.Tiles.SizeX - 1, 0].Hide();
            f.Tiles[f.Tiles.SizeX - 1, f.Tiles.SizeY - 1].Hide();
            f.Tiles[0, f.Tiles.SizeY - 1].Hide();
            #endregion

            f[2, 0] = new SimplePipe.PumpToLeft();

            f[1, 0] = new SimplePipe.RightToBottom();
            f[1, 1] = new SimplePipe.Vertical();
            f[1, 2] = new SimplePipe.TopToRight();
            f[2, 2] = new SimplePipe.Cross();
            f[3, 2] = new SimplePipe.Horizontal();
            f[4, 2] = new SimplePipe.LeftToDrain();

            f[2, 1] = new SimplePipe.RightToBottom();
            f[2, 3] = new SimplePipe.TopToLeft();
            f[3, 1] = new SimplePipe.Horizontal();
            f[4, 1] = new SimplePipe.TopToLeft();
            f[4, 0] = new SimplePipe.LeftToBottom();
            f[3, 0] = new SimplePipe.RightToDrain();
            f[1, 3] = new SimplePipe.PumpToRight();
            f[2, 4] = new SimplePipe.PumpToRight();
            f[3, 5] = new SimplePipe.BonusPickup();

            f[4, 2].Output.Drain = f[1, 3].Input.Pump;

            // show a hole in the floor
            f.Tiles[3, 0].Drain.Visibility = System.Windows.Visibility.Visible;
            f.Tiles[4, 2].Drain.Visibility = System.Windows.Visibility.Visible;

            // user must click on the pump to activate it
            f.Tiles[2, 0].Overlay.MouseLeftButtonUp +=
                delegate
                {
                    if (f[2, 0].HasWater)
                        return;

                    f[2, 0].Input.Pump();
                };

            f.Tiles[2, 4].Overlay.MouseLeftButtonUp +=
                delegate
                {
                    if (f[2, 4].HasWater)
                        return;

                    f[2, 4].Input.Pump();
                };

            // when a user adds a pipe on top of another
            // we need to call this to force a zorder sort
            f.RefreshPipes();

            var x = (DefaultWidth - f.Tiles.Width) / 2;
            var y = (DefaultHeight - f.Tiles.Height) / 2;

            f.Container.MoveTo(x, y).AttachTo(this);

            var CurrentTile = default(SimplePipe);

            var CurrentTileCanvas = new Canvas
            {
                Width = DefaultWidth,
                Height = DefaultHeight
            }.AttachTo(this);

            var ExplosionCanvas = new Canvas
            {
                Width = DefaultWidth,
                Height = DefaultHeight
            }.AttachTo(this);

            double CurrentTileX = 0;
            double CurrentTileY = 0;

            Action CurrentTileNext =
                delegate
                {
                    CurrentTile = SimplePipe.BuildablePipes.Random()();

                    CurrentTile.Container.Opacity = 0.7;
                    CurrentTile.Container.MoveTo(CurrentTileX, CurrentTileY);
                    CurrentTile.Container.AttachTo(CurrentTileCanvas);
                    CurrentTile.OverlayBlackAnimationStart();
                };

            CurrentTileNext();

//.........这里部分代码省略.........
开发者ID:skdhayal,项目名称:avalonpipemania,代码行数:101,代码来源:InteractiveFieldTest.cs


注:本文中的Field.RefreshPipes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。