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


C# Sprite.GetApproxRadius方法代码示例

本文整理汇总了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 );
    }
开发者ID:superwills,项目名称:SPW_Classic,代码行数:28,代码来源:Sprite.cs

示例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
    }
开发者ID:superwills,项目名称:SPW_Classic,代码行数:36,代码来源:Sprite.cs

示例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;
    }
开发者ID:superwills,项目名称:SPW_Classic,代码行数:17,代码来源:Sprite.cs


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