Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of Tile
        /// </summary>
        /// <param name="isHollow"></param>
        /// <param name="texture"></param>
        /// <param name="position"></param>
        /// <remarks>This creates a Tile with a hitbox which (x,y) is the center of the tile texture.
        /// The formula is :
        ///    int w = TextureManager.TextureSize.X
        ///    int h = TextureManager.TextureSize.Y
        ///    int x = position.X - w / 2
        ///    int y = position.Y - h / 2
        ///    hitbox = new Rectangle(x, y, w/2, h/2)</remarks>
        public Tile(bool isHollow, string texture, Vector2D position)
        {
            this.isHollow = isHollow;
            this.position = position;
            this.screenPosition = CoordinateSystemConverter.WorldToPixels(this.position);
            this.hitbox = new RectanglePhysicsObject(position, true);

            if (texture != "cmd:none")
                GetSprite(texture);
        }
Exemplo n.º 2
0
        public override bool CollidesWith(IPhysicObject other)
        {
            RectanglePhysicsObject rpo = ExceptionHelper.AssertIsTAndReturnCasted <RectanglePhysicsObject>(other, "RectanglePhysicsObject.Collides()");

            return(rpo.hitbox.Intersects(this.hitbox));
        }