當前位置: 首頁>>代碼示例>>C#>>正文


C# PointF.Normalize方法代碼示例

本文整理匯總了C#中System.Drawing.PointF.Normalize方法的典型用法代碼示例。如果您正苦於以下問題:C# PointF.Normalize方法的具體用法?C# PointF.Normalize怎麽用?C# PointF.Normalize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Drawing.PointF的用法示例。


在下文中一共展示了PointF.Normalize方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ProjectAlong

        /// <summary>
        /// Projects a PointF along a specified direction
        /// </summary>
        public static PointF ProjectAlong(this PointF This, PointF direction)
        {
            var normalDirection = direction.Normalize();
            var dist = This.DotProduct(normalDirection);

            return normalDirection.ScaledBy(dist);
        }
開發者ID:hogjosh,項目名稱:splat,代碼行數:10,代碼來源:PointExtensions.cs

示例2: CalculateVelocityVectors

 private void CalculateVelocityVectors(float velocity)
 {
     var vector = new PointF(_targetLocation.X - _floatX, _targetLocation.Y - _floatY);
     vector = vector.Normalize(velocity);
     VelocityX = vector.X;
     VelocityY = vector.Y;
 }
開發者ID:jsnklpn,項目名稱:RampartClone,代碼行數:7,代碼來源:CannonBall.cs

示例3: BombImp

        private void BombImp()
        {
            List<Living> playersAround = m_map.FindHitByHitPiont(GetCollidePoint(), m_radius);
            foreach (Living p in playersAround)
            {
                if (p.IsNoHole || p.NoHoleTurn)
                {
                    p.NoHoleTurn = true;
                    digMap = false;
                }
                p.SyncAtTime = false;
            }
            m_owner.SyncAtTime = false;
            try
            {

                //TrieuLSL DIG DIG DIG
                if (digMap)
                {
                    m_map.Dig(m_x, m_y, m_shape, null);
                }
                m_actions.Add(new BombAction(m_lifeTime, ActionType.BOMB, m_x, m_y, digMap ? 1 : 0, 0));

                switch (m_type)
                {
                    case BombType.FORZEN:
                        foreach (Living p in playersAround)
                        {
                            if (m_owner is SimpleBoss && new IceFronzeEffect(100).Start(p))
                            {
                                m_actions.Add(new BombAction(m_lifeTime, ActionType.FORZEN, p.Id, 0, 0, 0));
                            }
                            else
                            {
                                if (new IceFronzeEffect(2).Start(p))
                                {
                                    m_actions.Add(new BombAction(m_lifeTime, ActionType.FORZEN, p.Id, 0, 0, 0));
                                }
                                else
                                {
                                    m_actions.Add(new BombAction(m_lifeTime, ActionType.FORZEN, -1, 0, 0, 0));
                                    m_actions.Add(new BombAction(m_lifeTime, ActionType.UNANGLE, p.Id, 0, 0, 0));
                                }
                            }
                        }
                        break;
                    case BombType.TRANFORM:
                        //炸彈的飛行時間必須超過1
                        if (m_y > 10 && m_lifeTime > 0.04f)
                        {
                            //炸彈最後的落腳地點必須為空,否則向後退5像素
                            if (m_map.IsEmpty(m_x, m_y) == false)
                            {
                                PointF v = new PointF(-vX, -vY);
                                v = v.Normalize(5);
                                m_x -= (int)v.X;
                                m_y -= (int)v.Y;
                            }
                            m_owner.SetXY(m_x, m_y);
                            m_owner.StartMoving();
                            m_actions.Add(new BombAction(m_lifeTime, ActionType.TRANSLATE, m_x, m_y, 0, 0));
                            m_actions.Add(new BombAction(m_lifeTime, ActionType.START_MOVE, m_owner.Id, m_owner.X, m_owner.Y, m_owner.IsLiving ? 1 : 0));
                        }
                        break;
                    case BombType.CURE:
                        foreach (Living p in playersAround)
                        {
                            double plus = 0;
                            if (playersAround.Count > 1)
                                plus = 0.4;
                            else
                                plus = 1;
                            int blood = (int)(((Player)m_owner).PlayerDetail.SecondWeapon.Template.Property7 * Math.Pow(1.1, ((Player)m_owner).PlayerDetail.SecondWeapon.StrengthenLevel) * plus);
                            p.AddBlood(blood);
                            if (p is Player)
                            {
                                ((Player)p).TotalCure += blood;
                            }
                            m_actions.Add(new BombAction(m_lifeTime, ActionType.CURE, p.Id, p.Blood, blood, 0));
                            //Console.WriteLine("治療{0},血量{1}", blood, p.Blood);
                        }
                        break;
                    default:
                        foreach (Living p in playersAround)
                        {
                            //Console.WriteLine("炸彈ID{0}", m_info.Name);
                            //判斷npc之間的陣營
                            if (m_owner.IsFriendly(p) == true)
                            {
                                continue;
                            }

                            int damage = MakeDamage(p);
                            int critical = 0;
                            if (damage != 0)
                            {
                                critical = MakeCriticalDamage(p, damage);//暴擊
                                m_owner.OnTakedDamage(m_owner, ref damage, ref damage);
                                if (p.TakeDamage(m_owner, ref damage, ref critical, "爆炸"))
                                {
//.........這裏部分代碼省略.........
開發者ID:geniushuai,項目名稱:DDTank-3.0,代碼行數:101,代碼來源:SimpleBomb.cs

示例4: GenerateVector

 public static PointF GenerateVector()
 {
     var vector = new PointF(rand.Next(-100, 100), rand.Next(-100, 100));
     return vector.Normalize();
 }
開發者ID:efgefg0001,項目名稱:Tanks,代碼行數:5,代碼來源:MathUtils.cs


注:本文中的System.Drawing.PointF.Normalize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。