本文整理汇总了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);
}
示例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;
}
示例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, "爆炸"))
{
//.........这里部分代码省略.........
示例4: GenerateVector
public static PointF GenerateVector()
{
var vector = new PointF(rand.Next(-100, 100), rand.Next(-100, 100));
return vector.Normalize();
}