Esempio n. 1
0
        /// <summary>
        /// Is there a collision between the two elements ?
        /// </summary>
        /// <param name="e2"></param>
        /// <returns></returns>
        public virtual bool Collide(Hitbox h2)
        {
            if (h2.GetType() == typeof(CircleHitbox) || h2.GetType() == typeof(PositionedCircleHitbox) )
            {
                return Collide(((CircleHitbox)h2).Circle);
            }
            else if (h2.GetType() == typeof(SquareHitbox))
            {
                return Collide(((SquareHitbox)h2).Square);
            }

            return false;
        }
Esempio n. 2
0
        /// <summary>
        /// Create a new displayable element
        /// </summary>
        /// <param name="_location">Where the entity will start</param>
        /// <param name="_spriteRect">Location in spritefile of the sprite</param>
        /// <param name="_speed">Default speed</param>
        /// <param name="scale">Sprite scaling (if not, use Vector2.One) </param>
        /// <param name="angle">Sprite orientation</param>
        /// <param name="timeToLive">Time entity will stay in game (use 'InfiniteTimeToLive' if necessary)</param>
        public Entity(Vector2 _location, Rectangle _spriteRect, Vector2 _speed, Vector2 scale, double angle, double timeToLive)
        {
            this.location = _location;
            this.sRect = _spriteRect;
            this.scale = scale;

            this.dRect = ComputeDstRect(sRect);

            this.speed = _speed;
            this.ttl = timeToLive;
            this.rotation = angle;

            this.hitbox = new CircleHitbox(this, false);

            this.spriteOrigin = Vector2.Zero;

            //New parameters for animated sprites
            this.currentFrame = 0;
            this.frameTime = 0;
            this.totalFrameNumber = 0;
            this.frameCooldown = 0;
            this.initsRect = Rectangle.Empty;
            this.spriteBox = Vector2.Zero;
        }