public override bool CollisionResponse(AbstractGameObject gameObject, Side side, GameTime gameTime)
        {
            if (State is PowerupRevealState || IsCollided)
            {
                return(false);
            }

            if (gameObject is Mario)
            {
                IsCollided = true;
                EventManager.Instance.TriggerPowerupCollectedEvent(this, (Mario)gameObject);
            }
            else if (gameObject is AbstractBlock)
            {
                if (side == Side.Bottom)
                {
                    Velocity = new Vector2(Velocity.X, 0);
                    Gravity  = false;
                }
                else if (side == Side.Left)
                {
                    Velocity = new Vector2(2, Velocity.Y);
                }
                else if (side == Side.Right)
                {
                    Velocity = new Vector2(-2, Velocity.Y);
                }
            }
            else
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
 public override bool CollisionResponse(AbstractGameObject gameObject, Side side, GameTime gameTime)
 {
     if (gameObject is AbstractBlock)
     {
         if (side == Side.Bottom)
         {
             Velocity = new Vector2(Velocity.X, -5);
             BounceCount++;
         }
         else
         {
             //KILL fireball
             Destroyed = true;
             Velocity  = Vector2.Zero;
         }
     }
     else if (gameObject is Mario && !(Owner is Mario))
     {
         Destroyed = true;
         Velocity  = Vector2.Zero;
     }
     else if (gameObject is AbstractEnemy && Owner is Mario)
     {
         Destroyed = true;
         Velocity  = Vector2.Zero;
     }
     return(false);
 }
Esempio n. 3
0
 public override void FixClipping(Vector2 correction, AbstractGameObject obj1, AbstractGameObject obj2)
 {
     //TODO move this into states? poweurp
     if (!(obj1 is AbstractEnemy) || (obj1 is PiranhaObject))
     {
         Position = new Vector2(Position.X + correction.X, Position.Y + correction.Y);
         BoundingBox.UpdateHitBox(Position, Sprite);
     }
 }
 public override bool CollisionResponse(AbstractGameObject gameObject, Side side, GameTime gameTime)
 {
     if (gameObject is Mario && side == Side.Bottom)
     {
         State.Bump((Mario)gameObject);
         return(true);
     }
     return(false);
 }
Esempio n. 5
0
        public override bool CollisionResponse(AbstractGameObject gameObject, Side side, GameTime gameTime)
        {
            if (IsCollided)
            {
                return(IsCollided);
            }

            IsCollided = State.CollisionResponse(gameObject);
            return(IsCollided);
        }
Esempio n. 6
0
 public override bool CollisionResponse(AbstractGameObject gameObject, Side side, GameTime gameTime)
 {
     if (gameObject is Mario && side == Side.Top)
     {
         if (((Mario)gameObject).ActionState.Action == States.MarioAction.Crouch && WarpEnd != null)
         {
             EventManager.Instance.TriggerPlayerWarpingEvent(this, WarpEnd, (Mario)gameObject);
         }
     }
     return(base.CollisionResponse(gameObject, side, gameTime));
 }
Esempio n. 7
0
 public FireBall(ISprite sprite, AbstractGameObject player, Vector2 position) : base(sprite, player, position)
 {
     Gravity = true;
     if (Owner.Orientation == Facing.Right)
     {
         Velocity = new Vector2(5f, 0);
     }
     else
     {
         Velocity = new Vector2(-5f, 0);
     }
 }
Esempio n. 8
0
        public override bool CollisionResponse(AbstractGameObject gameObject, Side side, GameTime gameTime)
        {
            if (side == Side.Bottom)
            {
                Gravity = false;
            }

            bool retVal1 = PowerupStateBowser.CollisionResponse(gameObject, side, gameTime);
            bool retVal2 = ActionStateBowser.CollisionResponse(gameObject, side, gameTime);

            return(retVal1 || retVal2);
        }
Esempio n. 9
0
        public override bool CollisionResponse(AbstractGameObject gameObject, Side side, GameTime gameTime)
        {
            if (side == Side.Bottom)
            {
                Gravity = false;
            }

            if (gameObject is Mario && !(((Mario)gameObject).PowerupState is MarioInvincibility2))
            {
                if (side.Equals(Side.Top))
                {
                    EventManager.Instance.TriggerEnemyDefeatedEvent(this, (Mario)gameObject);
                    PowerupState.BecomeDead();
                    return(true);
                }
            }
            else if (gameObject is AbstractBlock)
            {
                if (side == Side.Left)
                {
                    Velocity    = new Vector2(EnemyHorizontalMovementSpeed, Velocity.Y);
                    Orientation = Facing.Right;
                }
                else if (side == Side.Right)
                {
                    Velocity    = new Vector2(-EnemyHorizontalMovementSpeed, Velocity.Y);
                    Orientation = Facing.Left;
                }
                else if (side == Side.Bottom)
                {
                    if (((AbstractBlock)gameObject).Bumper != null)
                    {
                        EventManager.Instance.TriggerEnemyDefeatedEvent(this, ((AbstractBlock)gameObject).Bumper);
                        PowerupState.BecomeDead();
                    }
                    Velocity = new Vector2(Velocity.X, 0);
                }

                return(true);
            }
            else if (gameObject is FireBall)
            {
                var fireball = (FireBall)gameObject;
                if (fireball.Owner is Mario)
                {
                    EventManager.Instance.TriggerEnemyDefeatedEvent(this, (Mario)fireball.Owner);
                    PowerupState.BecomeDead();
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 10
0
 public override void FixClipping(Vector2 correction, AbstractGameObject obj1, AbstractGameObject obj2)
 {
     if (obj1 is AbstractBlock && obj1.Visible)
     {
         Position = new Vector2(Position.X + correction.X, Position.Y + correction.Y);
         BoundingBox.UpdateHitBox(Position, Sprite);
     }
     else if (obj2 is AbstractBlock && obj2.Visible)
     {
         Position = new Vector2(Position.X + correction.X, Position.Y + correction.Y);
         BoundingBox.UpdateHitBox(Position, Sprite);
     }
 }
Esempio n. 11
0
        public override bool CollisionResponse(AbstractGameObject gameObject, Side side, GameTime gameTime)
        {
            if (revealedBrick != null)
            {
                return(revealedBrick.CollisionResponse(gameObject, side, gameTime));
            }

            if (gameObject is Mario && side == Side.Bottom && gameObject.Velocity.Y <= 0)
            {
                Bump();
                return(true);
            }
            return(false);
        }
Esempio n. 12
0
 public override bool CollisionResponse(AbstractGameObject gameObject, Side side, GameTime gameTime)
 {
     if (gameObject is FireBall)
     {
         var fireball = (FireBall)gameObject;
         if (fireball.Owner is Mario)
         {
             EventManager.Instance.TriggerEnemyDefeatedEvent(this, (Mario)fireball.Owner);
             PowerupState.BecomeDead();
             return(true);
         }
     }
     return(false);
 }
Esempio n. 13
0
        public override bool CollisionResponse(AbstractGameObject gameObject, Side side, GameTime gameTime)
        {
            ManageBouncing(gameObject, side);
            ManageFlagPoleCount(gameObject, side);

            if ((((gameObject is HiddenBrickObject && side != Side.Top && !gameObject.Visible) ||
                  (gameObject is HiddenBrickObject && side == Side.Top && !gameObject.Visible && (ActionState is MarioFall2))) ||
                 gameObject is CoinObject || gameObject is GreenMushroomObject))
            {
                return(false);
            }

            bool retVal1 = PowerupState.CollisionResponse(gameObject, side, gameTime);
            bool retVal2 = ActionState.CollisionResponse(gameObject, side, gameTime);

            return(retVal1 || retVal2);
        }
Esempio n. 14
0
        public override void FixClipping(Vector2 correction, AbstractGameObject obj1, AbstractGameObject obj2)
        {
            if (State is PowerupRevealState)
            {
                return;
            }

            if ((obj1 is AbstractBlock && obj1.Visible) || obj1 is Mario)
            {
                Position = new Vector2(Position.X + correction.X, Position.Y + correction.Y);
                BoundingBox.UpdateHitBox(Position, Sprite);
            }
            else if ((obj2 is AbstractBlock && obj2.Visible) || obj2 is Mario)
            {
                Position = new Vector2(Position.X + correction.X, Position.Y + correction.Y);
                BoundingBox.UpdateHitBox(Position, Sprite);
            }
        }
Esempio n. 15
0
 private void ManageBouncing(AbstractGameObject gameObject, Side side)
 {
     if (gameObject is AbstractEnemy && side.Equals(Side.Bottom))
     {
         if (bouncing)
         {
             BounceCount += 1;
         }
         else
         {
             bouncing = true;
         }
     }
     else if (side.Equals(Side.Bottom))
     {
         BounceCount = 0;
         bouncing    = false;
     }
 }
Esempio n. 16
0
        private void ManageFlagPoleCount(AbstractGameObject gameObject, Side side)
        {
            if (gameObject is Flagpole && side.Equals(Side.Right))
            {
                poleBottom = gameObject.BoundingBox.Dimensions.Bottom;
                poleTop    = gameObject.BoundingBox.Dimensions.Top;
                poleHeight = poleBottom - poleTop;

                increment = poleHeight / 5;

                if (Position.Y == poleTop)
                {
                    Lives++;
                }
                else if (Position.Y > poleTop && Position.Y <= poleTop + increment)
                {
                    height = 4000;
                }
                else if (Position.Y > poleTop + increment && Position.Y <= poleTop + (increment + increment))
                {
                    height = 2000;
                }
                else if ((Position.Y > (poleTop + (increment + increment))) && (Position.Y <= poleTop + (increment + increment + increment)))
                {
                    height = 800;
                }
                else if (Position.Y <= poleBottom - increment && Position.Y > poleTop + (increment + increment + increment))
                {
                    height = 400;
                }
                else if (Position.Y <= poleBottom + 5 && Position.Y > poleBottom - increment)
                {
                    height = 100;
                }

                EventManager.Instance.TriggerPlayerHitPoleEvent(height, this);
            }
        }
 public virtual void FixClipping(Vector2 correction, AbstractGameObject obj1, AbstractGameObject obj2)
 {
     //most things don't actually fix any clipping
 }
 /// <summary>
 /// returns true if the collision was meaningful/did something that would have to be rechecked
 /// </summary>
 /// <param name="gameObject"></param>
 /// <param name="side"></param>
 /// <param name="gameTime"></param>
 /// <returns></returns>
 public virtual bool CollisionResponse(AbstractGameObject gameObject, Side side, GameTime gameTime)
 {
     return(false);
 }
Esempio n. 19
0
 public override bool CollisionResponse(AbstractGameObject gameObject, Side side, GameTime gameTime)
 {
     return(base.CollisionResponse(gameObject, side, gameTime));
 }
Esempio n. 20
0
 public override void FixClipping(Vector2 correction, AbstractGameObject obj1, AbstractGameObject obj2)
 {
     //don't delete this
 }