Example #1
0
        public static BoundRectangle operator +(BoundRectangle box, Vector2 Addition)
        {
            BoundRectangle newRect = box;

            newRect.X += Addition.X;
            newRect.Y += Addition.Y;
            return(newRect);
        }
 public StaticProjectile(AnimatedSprite sprite, ITargetable target, Game gameRef)
     : base()
 {
     projectileSprite = (AnimatedSprite)sprite.Clone();
     projectileSprite.CurrentAnimation = AnimationKey.Left;
     Target = target;
     projectileSprite.PerformAnimation = true;
     BoundRect = new BoundRectangle(0, 0, sprite.Width, sprite.Height);
     Position  = Target.BoundRect.BottomCenter - new Vector2(projectileSprite.Width / 2, projectileSprite.Height / 2);
 }
Example #3
0
        public bool CollideCheck(IMoveble gameObject)
        {
            BoundRectangle box = gameObject.BoundRect + gameObject.Velocity;

            if ((Right >= box.Left) && (Left <= box.Right))
            {
                if ((Bottom >= box.Top) && (Top <= box.Bottom))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #4
0
 public override void CheckCollision(IMoveble gameObject, Vector2 playerInput)
 {
     if (gameObject.IsKnockedBack)
     {
         return;
     }
     if (BoundRectangle.CollideCheck(gameObject))
     {
         if (gameObject.BoundRect.Bottom > BoundRectangle.Bottom)
         {
             return;
         }
         gameObject.Velocity   = new Vector2(gameObject.Velocity.X, gameObject.Velocity.Y);
         gameObject.IsGrounded = true;
     }
 }
Example #5
0
        public override void CheckCollision(IMoveble gameObject, Vector2 playerInput)
        {
            if (BoundRectangle.CollideCheck(gameObject))
            {
                if ((gameObject.BoundRect.Bottom == BoundRectangle.Top) && (playerInput.Y > 0))
                {
                    gameObject.Velocity = new Vector2(gameObject.Velocity.X, gameObject.Velocity.Y);
                    return;
                }

                if (gameObject.BoundRect.Bottom <= BoundRectangle.Top)
                {
                    if (playerInput.Y <= 0)
                    {
                        gameObject.Velocity   = new Vector2(gameObject.Velocity.X, BoundRectangle.Top - gameObject.BoundRect.Bottom);
                        gameObject.IsGrounded = true;
                    }
                }
            }
        }
 public TargetingProjectile(AnimatedSprite sprite, Spell spell, float speed, ITargetable caster, ITargetable target, Game gameRef)
     : base()
 {
     projectileSprite = (AnimatedSprite)sprite.Clone();
     projectileSprite.CurrentAnimation = AnimationKey.Left;
     Spell     = spell;
     BoundRect = new BoundRectangle(0, 0, sprite.Width, sprite.Height);
     if (caster.Character.IsDirectedRight)
     {
         Position = new Vector2(caster.BoundRect.Right - sprite.Width / 2,
                                caster.Position.Y + caster.BoundRect.Height / 4 - sprite.Height / 2);
     }
     else
     {
         Position = new Vector2(caster.BoundRect.Left - sprite.Width / 2,
                                caster.Position.Y + caster.BoundRect.Height / 4 - sprite.Height / 2);
     }
     Speed  = speed;
     Caster = caster;
     Target = target;
 }
        public override void CheckCollision(IMoveble gameObject, Vector2 playerInput)
        {
            if (BoundRectangle.CollideCheck(gameObject))
            {
                if (gameObject.BoundRect.Bottom <= BoundRectangle.Top)
                {
                    gameObject.Velocity   = new Vector2(gameObject.Velocity.X, BoundRectangle.Top - gameObject.BoundRect.Bottom);
                    gameObject.IsGrounded = true;
                }
                else if (gameObject.BoundRect.Top >= BoundRectangle.Bottom)
                {
                    gameObject.Velocity = new Vector2(gameObject.Velocity.X, BoundRectangle.Bottom - gameObject.BoundRect.Top);
                }

                if (gameObject.BoundRect.Right <= BoundRectangle.Left)
                {
                    gameObject.Velocity = new Vector2(BoundRectangle.Left - gameObject.BoundRect.Right, gameObject.Velocity.Y);
                }
                else if (gameObject.BoundRect.Left >= BoundRectangle.Right)
                {
                    gameObject.Velocity = new Vector2(BoundRectangle.Right - gameObject.BoundRect.Left, gameObject.Velocity.Y);
                }
            }
        }
Example #8
0
 protected BaseObject(Vector2 position, float w, float h, ObjectType objectType)
 {
     ObjectType     = objectType;
     BoundRectangle = new BoundRectangle(position.X, position.Y, w, h);
 }