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 } ); }
/// <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 ); }
/// <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)); }
/// <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)); }
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); }
public NonInertiasColUpdater(GameObjInfo objInfo, Sprite[] collideSprites) : base(objInfo) { this.collideSprites = collideSprites; colMethod = new SpriteColMethod(collideSprites); }
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 ); }
public NonInertiasColUpdater( GameObjInfo objInfo, Sprite[] collideSprites ) : base( objInfo ) { this.collideSprites = collideSprites; colMethod = new SpriteColMethod( collideSprites ); }
/// <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 ); }