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


C# Point.Normalize方法代码示例

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


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

示例1: GhostMoveAction

 public GhostMoveAction(Player player,Point target)
 {
     m_player = player;
     m_target = target;
     m_isFinished = false;
     m_v = new Point(target.X - m_player.X, target.Y - m_player.Y);
     m_v.Normalize(2);
 }
开发者ID:geniushuai,项目名称:DDTank-3.0,代码行数:8,代码来源:GhostMoveAction.cs

示例2: DotProduct

 public void DotProduct()
 {
     var point1 = new Point(1, 1);
     point1.Normalize();
     var point2 = new Point(-1, 1);
     point2.Normalize();
     Assert.AreEqual(0.0f, point1.DotProduct(point2));
     Assert.AreEqual(0.7071f, point1.DotProduct(Point.UnitY), 0.0001f);
 }
开发者ID:hillwhite,项目名称:DeltaEngine,代码行数:9,代码来源:PointTests.cs

示例3: StartGhostMoving

        public void StartGhostMoving()
        {
            if (TargetPoint.IsEmpty)
                return;

            Point pv = new Point(TargetPoint.X - X, TargetPoint.Y - Y);
            Point target = TargetPoint;
            if (pv.Length() > 160)
            {
                pv.Normalize(160);
            }

            m_game.AddAction(new GhostMoveAction(this, new Point(X + pv.X, Y + pv.Y)));
        }
开发者ID:geniushuai,项目名称:DDTank-3.0,代码行数:14,代码来源:Player.cs

示例4: StartMoving

        public override void StartMoving()
        {
            m_actions = new List<BombAction>();

            while (m_isLiving)
            {
                m_lifeTime += 0.04F;
                Point pos = CompleteNextMovePoint(0.04F);
              
                MoveTo(pos.X,pos.Y);

                if (m_isLiving)
                {
                    if (Math.Round(m_lifeTime * 100) % 40 == 0 && pos.Y > 0)
                        m_game.AddTempPoint(pos.X, pos.Y);

                    if (m_controled && vY > 0)
                    {
                        Player player = m_map.FindNearestEnemy(m_x, m_y, 300, m_owner);

                        if (player != null)
                        {
                            Point v = new Point(player.X - m_x, player.Y - m_y);
                            v.Normalize(1000);
                            setSpeedXY(v.X, v.Y);
                            m_actions.Add(new BombAction(m_lifeTime, ActionType.CHANGE_SPEED, v.X, v.Y, 0,0));
                            //使炮弹不受重力和风力和空气阻力的影响
                            UpdateForceFactor(0, 0, 0);
                            m_controled = false;
                        }
                    }
                }
            }
        }
开发者ID:geniushuai,项目名称:DDTank-3.0,代码行数:34,代码来源:SimpleBomb.cs

示例5: Normalize

 public void Normalize()
 {
     var point = new Point(0.3f, -0.4f);
     point.Normalize();
     Assert.AreEqual(new Point(0.6f, -0.8f), point);
 }
开发者ID:hillwhite,项目名称:DeltaEngine,代码行数:6,代码来源:PointTests.cs

示例6: OnRefresh

        protected override void OnRefresh()
        {
            RotarySwitch rotarySwitch = Visual as RotarySwitch;
            if (rotarySwitch != null)
            {
                _imageRect.Width = rotarySwitch.Width;
                _imageRect.Height = rotarySwitch.Height;
                _image = ConfigManager.ImageManager.LoadImage(rotarySwitch.KnobImage);
                _imageBrush = new ImageBrush(_image);
                _center = new Point(rotarySwitch.Width / 2d, rotarySwitch.Height / 2d);

                _lines = new GeometryDrawing();
                _lines.Pen = new Pen(new SolidColorBrush(rotarySwitch.LineColor), rotarySwitch.LineThickness);

                _labels.Clear();

                Vector v1 = new Point(_center.X, 0) - _center;
                double lineLength = v1.Length * rotarySwitch.LineLength;
                double labelDistance = v1.Length * rotarySwitch.LabelDistance;
                v1.Normalize();
                GeometryGroup lineGroup = new GeometryGroup();
                Brush labelBrush = new SolidColorBrush(rotarySwitch.LabelColor);
                foreach (RotarySwitchPosition position in rotarySwitch.Positions)
                {
                    Matrix m1 = new Matrix();
                    m1.Rotate(position.Rotation);

                    if (rotarySwitch.DrawLines)
                    {
                        Vector v2 = v1 * m1;

                        Point startPoint = _center;
                        Point endPoint = startPoint + (v2 * lineLength);

                        lineGroup.Children.Add(new LineGeometry(startPoint, endPoint));
                    }

                    if (rotarySwitch.DrawLabels)
                    {
                        FormattedText labelText = rotarySwitch.LabelFormat.GetFormattedText(labelBrush, position.Name);
                        labelText.TextAlignment = TextAlignment.Center;
                        labelText.MaxTextWidth = rotarySwitch.Width;
                        labelText.MaxTextHeight = rotarySwitch.Height;

                        if (rotarySwitch.MaxLabelHeight > 0d && rotarySwitch.MaxLabelHeight < rotarySwitch.Height)
                        {
                            labelText.MaxTextHeight = rotarySwitch.MaxLabelHeight;
                        }
                        if (rotarySwitch.MaxLabelWidth > 0d && rotarySwitch.MaxLabelWidth < rotarySwitch.Width)
                        {
                            labelText.MaxTextWidth = rotarySwitch.MaxLabelWidth;
                        }

                        Point location = _center + (v1 * m1 * labelDistance);
                        if (position.Rotation <= 10d || position.Rotation >= 350d)
                        {
                            location.X -= labelText.MaxTextWidth / 2d;
                            location.Y -= labelText.Height;
                        }
                        else if (position.Rotation < 170d)
                        {
                            location.X -= (labelText.MaxTextWidth - labelText.Width) / 2d;
                            location.Y -= labelText.Height / 2d;
                        }
                        else if (position.Rotation <= 190d)
                        {
                            location.X -= labelText.MaxTextWidth / 2d;
                        }
                        else
                        {
                            location.X -= (labelText.MaxTextWidth + labelText.Width) / 2d;
                            location.Y -= labelText.Height / 2d;
                        }

                        _labels.Add(new SwitchPositionLabel(labelText, location));
                    }
                }
                _lines.Geometry = lineGroup;
                _lines.Freeze();
            }
            else
            {
                _image = null;
                _imageBrush = null;
                _lines = null;
                _labels.Clear();
            }
        }
开发者ID:Heliflyer,项目名称:helios,代码行数:88,代码来源:RotarySwitchRenderer.cs


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