示例#1
0
 public ObstacleCommon( string name, GameObjInfo objInfo, Vector2 pos, float azi,
     string texAssetPath, Vector2 origin, float scale, Color color, float layerDepth, Vector2[] keyPoints )
 {
     this.name = name;
     this.objInfo = objInfo;
     this.pos = pos;
     this.azi = azi;
     this.sprite = new Sprite( BaseGame.RenderEngine, BaseGame.ContentMgr, texAssetPath, true );
     this.sprite.SetParameters( origin, pos, scale, azi, color, layerDepth, SpriteBlendMode.AlphaBlend );
     this.keyPoints = keyPoints;
     this.colMethod = new SpriteColMethod( new Sprite[] { this.sprite } );
 }
示例#2
0
 /// <summary>
 /// 检测与精灵对象是否冲突
 /// </summary>
 /// <param name="spriteChecker"></param>
 /// <returns></returns>
 public CollisionResult CheckCollisionWithSprites ( SpriteColMethod spriteChecker )
 {
     foreach (Sprite spriteA in spriteChecker.colSprites)
     {
         foreach (Sprite spriteB in this.colSprites)
         {
             CollisionResult result = Sprite.IntersectPixels( spriteA, spriteB );
             if (result.IsCollided)
                 return result;
         }
     }
     return new CollisionResult( false );
 }
示例#3
0
 /// <summary>
 /// 检测与精灵对象是否冲突
 /// </summary>
 /// <param name="spriteChecker"></param>
 /// <returns></returns>
 public CollisionResult CheckCollisionWithSprites(SpriteColMethod spriteChecker)
 {
     foreach (Sprite spriteA in spriteChecker.colSprites)
     {
         foreach (Sprite spriteB in this.colSprites)
         {
             CollisionResult result = Sprite.IntersectPixels(spriteA, spriteB);
             if (result.IsCollided)
             {
                 return(result);
             }
         }
     }
     return(new CollisionResult(false));
 }
示例#4
0
        /// <summary>
        /// 检测与精灵对象是否冲突
        /// </summary>
        /// <param name="spriteChecker"></param>
        /// <returns></returns>
        public CollisionResult CheckCollisionWithSprites(SpriteColMethod spriteChecker)
        {
            foreach (Sprite sprite in spriteChecker.ColSprites)
            {
                CollisionResult result = sprite.CheckOutBorder(borderRect);
                if (result.IsCollided)
                {
                    float originX = result.NormalVector.X;
                    float originY = result.NormalVector.Y;

                    float x, y;

                    if (Math.Abs(originX) > 0.5)
                    {
                        x = 1;
                    }
                    else
                    {
                        x = 0;
                    }
                    if (Math.Abs(originY) > 0.5)
                    {
                        y = 1;
                    }
                    else
                    {
                        y = 0;
                    }

                    x *= Math.Sign(originX);
                    y *= Math.Sign(originY);


                    return(new CollisionResult(result.InterPos, new Vector2(x, y)));
                }
            }
            return(new CollisionResult(false));
        }
示例#5
0
 public NonInertiasColUpdater(GameObjInfo objInfo, Vector2 pos, Vector2 vel, float azi, float angVel, Sprite[] collideSprites)
     : base(objInfo, pos, vel, azi, angVel)
 {
     this.collideSprites = collideSprites;
     colMethod           = new SpriteColMethod(collideSprites);
 }
示例#6
0
 public NonInertiasColUpdater(GameObjInfo objInfo, Sprite[] collideSprites)
     : base(objInfo)
 {
     this.collideSprites = collideSprites;
     colMethod           = new SpriteColMethod(collideSprites);
 }
示例#7
0
 public NonInertiasColUpdater( GameObjInfo objInfo, Vector2 pos, Vector2 vel, float azi, float angVel, Sprite[] collideSprites )
     : base( objInfo, pos, vel, azi, angVel )
 {
     this.collideSprites = collideSprites;
     colMethod = new SpriteColMethod( collideSprites );
 }
示例#8
0
 public NonInertiasColUpdater( GameObjInfo objInfo, Sprite[] collideSprites )
     : base( objInfo )
 {
     this.collideSprites = collideSprites;
     colMethod = new SpriteColMethod( collideSprites );
 }
示例#9
0
        /// <summary>
        /// 检测与精灵对象是否冲突
        /// </summary>
        /// <param name="spriteChecker"></param>
        /// <returns></returns>
        public CollisionResult CheckCollisionWithSprites( SpriteColMethod spriteChecker )
        {

            foreach (Sprite sprite in spriteChecker.ColSprites)
            {
                CollisionResult result = sprite.CheckOutBorder( borderRect );
                if (result.IsCollided)
                {
                    float originX = result.NormalVector.X;
                    float originY = result.NormalVector.Y;

                    float x, y;

                    if (Math.Abs( originX ) > 0.5)
                        x = 1;
                    else
                        x = 0;
                    if (Math.Abs( originY ) > 0.5)
                        y = 1;
                    else
                        y = 0;

                    x *= Math.Sign( originX );
                    y *= Math.Sign( originY );


                    return new CollisionResult( result.InterPos, new Vector2( x, y ) );
                }
            }
            return new CollisionResult( false );
        }