本文整理汇总了C#中Sprite.GetApproxRadius方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.GetApproxRadius方法的具体用法?C# Sprite.GetApproxRadius怎么用?C# Sprite.GetApproxRadius使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sprite
的用法示例。
在下文中一共展示了Sprite.GetApproxRadius方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetStrikeDistanceToFirstLevel
/// <summary>
/// Tells you how far along the line of this phasor
/// it would be to strike the <paramref name="other"/> Sprite.
///
/// Gives you NULL if it simply wouldn't hit the other Sprite.
/// </summary>
/// <param name="other">The sprite to check if it hits</param>
/// <returns>Distance along line if hits, NULL if does not</returns>
public float? GetStrikeDistanceToFirstLevel( Sprite other )
{
Vector2 shipHeading = shooter.GetHeading();
// create the ray
Ray thisRay = new Ray(
// starts at the center of
// wherever the owning ship currently is.
new Vector3( shooter.position.X, shooter.position.Y, 0.0f ),
// it goes in the direction the ship is currently facing
new Vector3( shipHeading.X, shipHeading.Y, 0.0f ) );
// treat the other thing as a sphere
BoundingSphere thatSphere = new BoundingSphere(
new Vector3( other.position.X, other.position.Y, 0.0f ), other.GetApproxRadius() );
return FindStrikeDistanceToSphere( thisRay, thatSphere );
}
示例2: GetStrikeDistanceToSecondLevel
/// <summary>
/// Tells you how far along the line of the WRAPPED COPY of this phasor
/// it would be to strike the <paramref name="other"/> Sprite.
///
/// ^
/// +------------------/----+
/// | / |
/// | C |
/// | |
/// | ^ |
/// +------------------/----+
/// /
/// C (wrapped copy)
///
/// Gives you NULL if it simply wouldn't hit the other Sprite.
/// </summary>
/// <param name="other"></param>
/// <returns></returns>
private float? GetStrikeDistanceToSecondLevel( Sprite other )
{
// get the duplicated wrapped ray
Ray? dupeRay = GetDupeRay();
// if the dupe ray exists (the phasor should wrap)
// then proceed with the calculation
if( dupeRay != null )
{
// treat the other thing as a sphere
BoundingSphere thatSphere = new BoundingSphere(
new Vector3( other.position.X, other.position.Y, 0.0f ), other.GetApproxRadius() );
return FindStrikeDistanceToSphere( dupeRay.Value, thatSphere );
}
else // there is no duperay (the original phasor did not intersect any of the walls)
return null; // so return null
}
示例3: Intersects
// Intersection method to tell if this sprite intersects another
// default uses bounding spheres.
public virtual bool Intersects( Sprite other )
{
// construct BoundingSpheres and see if the
// two sprites should collide
BoundingSphere thisSphere = new BoundingSphere(
new Vector3( this.position.X, this.position.Y, 0.0f ), this.GetApproxRadius() );
BoundingSphere thatSphere = new BoundingSphere(
new Vector3( other.position.X, other.position.Y, 0.0f ), other.GetApproxRadius() );
if( thisSphere.Intersects( thatSphere ) )
return true;
else
return false;
}