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


C# Point.Add方法代码示例

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


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

示例1: Install

        public void Install(BaseChip chip, Point point)
        {
            chips[point] = chip;
            if (pointsToNames.ContainsKey(point)) {
                chip.Name = pointsToNames[point];
            }

            foreach (var dir in Direction.Enumerate()) {
                var other = GetChip(point.Add(dir));
                var rw1 = chip.CustomRW() ?? other.CustomRW() ?? new BufferRW();
                var rw2 = chip.CustomRW() ?? other.CustomRW() ?? new BufferRW();
                var channel = new Channel(rw1, rw2);
                chip.Connections[dir.Name] = channel.Terminal2;
                other.Connections[dir.Opposite] = channel.Terminal1;
            }
        }
开发者ID:embix,项目名称:TIS100,代码行数:16,代码来源:Board.cs

示例2: Process

            public void Process(int[][] matrix, int rotations)
            {
                var rows = matrix.Length;
                var columns = matrix[0].Length;
                var resultMatrix = BuildResultMatrix(columns, rows);

                var cycles = Math.Min(rows, columns) / 2;

                var topLeft = new Point(0, 0);
                var bottomRight = new Point(columns - 1, rows - 1);

                for (int i = 0; i < cycles; i++)
                {
                    RotateRectangleInMatrix(matrix, resultMatrix, topLeft, bottomRight, rotations);

                    topLeft.Add(1, 1);
                    bottomRight.Add(-1, -1);
                }

                PrintMatrix(resultMatrix);
            }
开发者ID:lgeeraerts,项目名称:HackerRankSandbox,代码行数:21,代码来源:Program.cs

示例3: Update

        public override void Update(DeviceContext context, TargetBase target, DeviceManager deviceManager, Point screenSize, float dt, float elapsedTime)
        {
            if (AfterStartFreeze)
            {
                // Player moving
                _playerPos =
                    _playerPos.Add(_playerDir.Mul(_playerSpd).Mul(dt)).Clamp(GamesParams.Margin0.Add(_padSize.Half()),
                                                                             GamesParams.Margin1.Sub(_padSize.Half()));

                // Ball moving
                _ballPos = _ballPos.Add(_ballDir.Mul(_ballSpd).Mul(dt));

                // Ball collision with borders
                if (!_ballPos.IsInside(GamesParams.Margin0.Add(_ballSize.Half()),
                                       GamesParams.Margin1.Sub(_ballSize.Half())))
                {
                    _ballDir.Y = -_ballDir.Y;

                    if (_ballPos.X < GamesParams.MarginX0 + 0.001f)
                    {
                        NewGame();
                        _gameManager.Die();
                        return;
                    }

                    if (_ballPos.X > GamesParams.MarginX1 - 0.001f)
                    {
                        _gameManager.Win(500);
                        _ballPos = new Point(0.5f, 0.5f);
                        _ballDir = new Point(1.0f, 0.0f).AddNoise().Normalise();
                        return;
                    }
                }

                _ballPos = _ballPos.Clamp(GamesParams.Margin0.Add(_ballSize.Half()),
                                          GamesParams.Margin1.Sub(_ballSize.Half()));

                // Ball collision with player pad
                if (_ballPos.IsInside(_playerPos.Sub(_padSize.Half()).Sub(_ballSize.Half()),
                                      _playerPos.Add(_padSize.Half()).Add(_ballSize.Half())))
                {
                    _ballDir.X = 1;
                    _ballDir.Y = _ballPos.Sub(_playerPos).Y/_padSize.Half().Y;
                    _ballDir = _ballDir.Normalise();

                    _ballSpd += _ballSpdInc;

                    _gameManager.AddPoints(75);
                }

                // Ball collision with enemy pad
                if (_ballPos.IsInside(_enemyPos.Sub(_padSize.Half()).Sub(_ballSize.Half()),
                                      _enemyPos.Add(_padSize.Half()).Add(_ballSize.Half())))
                {
                    _ballDir.X = -1;
                    _ballDir.Y = _ballPos.Sub(_enemyPos).Y/_padSize.Half().Y;
                    _ballDir = _ballDir.Normalise();

                    _ballSpd += _ballSpdInc;
                }

                // Enemy moving
                if (Math.Abs(_ballPos.Y - _enemyPos.Y) < _padSize.Div(3).Y)
                {
                    _enemyDir.Y = 0;
                }
                else
                {
                    if (_ballPos.Y > _enemyPos.Y)
                        _enemyDir.Y = 1;
                    else
                        _enemyDir.Y = -1;

                    _enemyPos =
                        _enemyPos.Add(_enemyDir.Mul(_enemySpd).Mul(dt)).Clamp(GamesParams.Margin0.Add(_padSize.Half()),
                                                                              GamesParams.Margin1.Sub(_padSize.Half()));
                }
            }

            // Drawing
            var playerBox = _playerPos.ToBox(_padSize);
            var enemyBox = _enemyPos.ToBox(_padSize);
            var ballBox = _ballPos.ToBox(_ballSize);

            context.FillRectangle(screenSize.ApplyTo(playerBox), GamesParams.PlayerColor);
            context.FillRectangle(screenSize.ApplyTo(enemyBox), GamesParams.EnemyColor);

            context.FillRectangle(screenSize.ApplyTo(ballBox), GamesParams.AdditionalColor);

            base.Update(context, target, deviceManager, screenSize, dt, elapsedTime);
        }
开发者ID:Maskl,项目名称:MetroRetro,代码行数:91,代码来源:Pong.cs

示例4: contructSquare

        private void contructSquare(
            IList<VertexPositionNormalTexture> verts,
            IList<VertexPositionNormalTexture> vertsShadow,
            int floor,
            Point p,
            int[] cornerElevations)
        {
            var z = floor*4;
            var i = verts.Count;
            addVertex(verts, z, cornerElevations[1], p, 0, 0); //NW 0
            addVertex(verts, z, cornerElevations[3], p, 1, 0); //NE 1
            addVertex(verts, z, cornerElevations[0], p, 0, 1); //SW 2
            addVertex(verts, z, cornerElevations[0], p, 0, 1); //SW 3
            addVertex(verts, z, cornerElevations[3], p, 1, 0); //NE 4
            addVertex(verts, z, cornerElevations[2], p, 1, 1); //SE 5

            if (!CanMoveHere(floor, p, p.Add(0, -1)))
                addSide(vertsShadow, verts[i + 1].Position, verts[i].Position, Vector3.ForwardRH);
            if (!CanMoveHere(floor, p, p.Add(0, 1)))
                addSide(vertsShadow, verts[i + 2].Position, verts[i + 5].Position, Vector3.BackwardRH);
            if (!CanMoveHere(floor, p, p.Add(1, 0)))
                addSide(vertsShadow, verts[i + 1].Position, verts[i + 5].Position, Vector3.Left);
            if (!CanMoveHere(floor, p, p.Add(-1, 0)))
                addSide(vertsShadow, verts[i].Position, verts[i + 2].Position, Vector3.Right);
        }
开发者ID:danbystrom,项目名称:VisionQuest,代码行数:25,代码来源:PlayingField.cs

示例5: GetPosition

 public static Point<int> GetPosition(Point<int> position, Point<int> point)
 { return position.Add(point); }
开发者ID:Fujiwo,项目名称:https-github.com-Fujiwo-FTetris,代码行数:2,代码来源:Tetromino.cs

示例6: Update

        public override void Update(DeviceContext context, TargetBase target, DeviceManager deviceManager, Point screenSize, float dt, float elapsedTime)
        {
            if (AfterStartFreeze)
            {
                _timeToNextPossibleShoot -= dt;
                if (_isShootButtonPressed && _timeToNextPossibleShoot <= 0)
                {
                    var p = _playerPos.Sub(new Point(0, 0.01f));
                    _bulletPos.Add(p);

                    _timeToNextPossibleShoot = ShootInterval;
                }

                // Player moving
                _playerPos =
                    _playerPos.Add(_playerDir.Mul(PlayerSpd).Mul(dt)).Clamp(GamesParams.Margin0.Add(_playerSize.Half()),
                                                                            GamesParams.Margin1.Sub(_playerSize.Half()));

                // Enemies
                for (var e = 0; e < _enemyPos.Count; ++e)
                {
                    var enemyPos = _enemyPos[e];

                    // Enemy reach bottom line
                    _enemyPos[e] = enemyPos.Add(_enemyDir.Mul(EnemySpd).Mul(dt));
                    enemyPos = _enemyPos[e];

                    if (enemyPos.IsInside(GamesParams.Margin0.Sub(_enemySize.Half()).Add(new Point(0, 1)),
                                          GamesParams.Margin1.Add(_enemySize.Half()).Add(new Point(0, 1))))
                    {
                        AddEnemy(e);
                        AddEnemy();
                        AddEnemy();
                    }

                    // Enemy collision with player
                    if (enemyPos.IsInside(_playerPos.Sub(_playerSize.Half()).Sub(_playerSize.Half()),
                                          _playerPos.Add(_playerSize.Half()).Add(_playerSize.Half())))
                    {
                        NewGame();
                        _gameManager.Die();
                        return;
                    }
                }

                // Bullet moving
                for (var i = 0; i < _bulletPos.Count; ++i)
                {
                    var bulletPos = _bulletPos[i];
                    _bulletPos[i] = bulletPos.Add(_bulletDir.Mul(BulletSpd).Mul(dt));
                    bulletPos = _bulletPos[i];

                    // Bullet collision with borders
                    if (!bulletPos.IsInside(GamesParams.Margin0.Sub(_bulletSize.Half()),
                                            GamesParams.Margin1.Add(_bulletSize.Half())))
                    {
                        _bulletPos.RemoveAt(i);
                    }

                    // Bullet collision with enemies
                    for (var e = 0; e < _enemyPos.Count; ++e)
                    {
                        var enemyPos = _enemyPos[e];
                        if (bulletPos.IsInside(enemyPos.Sub(_enemySize.Half()).Sub(_bulletSize.Half()),
                                               enemyPos.Add(_enemySize.Half()).Add(_bulletSize.Half())))
                        {
                            _bulletPos.RemoveAt(i);
                            AddEnemy(e);
                            AddEnemy();
                            _gameManager.AddPoints(50);
                            break;
                        }
                    }
                }
            }

            // Drawing
            foreach (var bullet in _bulletPos)
            {
                var ballBox = bullet.ToBox(_bulletSize);
                context.FillRectangle(screenSize.ApplyTo(ballBox), GamesParams.AdditionalColor);
            }

            foreach (var enemy in _enemyPos)
            {
                var box = enemy.ToBox(_enemySize);
                if (box.Left > GamesParams.MarginX1 || box.Right < GamesParams.MarginX0 || box.Bottom < GamesParams.MarginY0 || box.Top > GamesParams.MarginY1)
                    continue;

                if (box.Left < GamesParams.MarginX0)
                    box.Left = GamesParams.MarginX0;
                if (box.Right > GamesParams.MarginX1)
                    box.Right = GamesParams.MarginX1;
                if (box.Top < GamesParams.MarginY0)
                    box.Top = GamesParams.MarginY0;
                if (box.Bottom > GamesParams.MarginY1)
                    box.Bottom = GamesParams.MarginY1;

                context.FillRectangle(screenSize.ApplyTo(box), GamesParams.EnemyColor);
            }
//.........这里部分代码省略.........
开发者ID:Maskl,项目名称:MetroRetro,代码行数:101,代码来源:Tigers.cs


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