Ejemplo n.º 1
0
 private void RespondToCollisionWithBlock(IObject obj, Side side, Rectangle intersectRectangle)
 {
     if (!((obj as Block) != null && (obj as Block).CurrentState is HiddenBlockState))
     {
         if (SideGeneralizer.IsRight(side))
         {
             this.SpinyEgg.CurrentPosition = new Vector2(this.SpinyEgg.CurrentPosition.X - intersectRectangle.Width, this.SpinyEgg.CurrentPosition.Y);
             this.SpinyEgg.CurrentVelocity = new Vector2(-this.SpinyEgg.CurrentVelocity.X, this.SpinyEgg.CurrentVelocity.Y);
         }
         else if (SideGeneralizer.IsLeft(side))
         {
             this.SpinyEgg.CurrentPosition = new Vector2(this.SpinyEgg.CurrentPosition.X + intersectRectangle.Width, this.SpinyEgg.CurrentPosition.Y);
             this.SpinyEgg.CurrentVelocity = new Vector2(-this.SpinyEgg.CurrentVelocity.X, this.SpinyEgg.CurrentVelocity.Y);
         }
         else if (SideGeneralizer.IsTop(side))
         {
             this.SpinyEgg.CurrentPosition = new Vector2(this.SpinyEgg.CurrentPosition.X, this.SpinyEgg.CurrentPosition.Y + intersectRectangle.Height);
             this.SpinyEgg.CurrentVelocity = new Vector2(this.SpinyEgg.CurrentVelocity.X, 0f);
         }
         else if (SideGeneralizer.IsBottom(side))
         {
             this.SpinyEgg.WillBecomeSpiny = true;
             this.SpinyEgg.CurrentPosition = new Vector2(this.SpinyEgg.CurrentPosition.X, this.SpinyEgg.CurrentPosition.Y - intersectRectangle.Height);
             this.SpinyEgg.SetDead();
         }
     }
 }
 private void RespondToCollisionWithMario(Side side, IMario mario)
 {
     if (mario.IsStar)
     {
         this.Shell.SetDead();
     }
     else if (this.Shell.IsMovingHorizontally() && !mario.IsTransitioningFromDamage)
     {
         if (!SideGeneralizer.IsTop(side) || mario.IsStar)
         {
             this.Shell.SetDead();
         }
         else
         {
             this.Shell.CurrentVelocity = new Vector2(0f, this.Shell.CurrentVelocity.Y);
         }
     }
     else if (!this.Shell.IsMovingHorizontally())
     {
         if (side == Side.RightOfTop || SideGeneralizer.IsRight(side))
         {
             this.Shell.GoLeft();
         }
         else if (side == Side.LeftOfTop || SideGeneralizer.IsLeft(side))
         {
             this.Shell.GoRight();
         }
     }
 }
 private void RespondToCollisionWithBlockOrPipe(Side side, Rectangle intersectRect)
 {
     if (SideGeneralizer.IsBottom(side))
     {
         this.Fireball.CurrentPosition     = new Vector2(this.Fireball.CurrentPosition.X, this.Fireball.CurrentPosition.Y - intersectRect.Height);
         this.Fireball.CurrentVelocity     = new Vector2(this.Fireball.CurrentVelocity.X, ProjectileConfig.FireballBounceVelocity);
         this.Fireball.IsAffectedByGravity = true;
     }
     else if (SideGeneralizer.IsLeft(side))
     {
         this.Fireball.CurrentPosition = new Vector2(this.Fireball.CurrentPosition.X + (intersectRect.Width),
                                                     this.Fireball.CurrentPosition.Y);
         this.Fireball.CurrentVelocity = new Vector2(ProjectileConfig.FireballVelocity, this.Fireball.CurrentVelocity.Y);
     }
     else if (SideGeneralizer.IsRight(side))
     {
         this.Fireball.CurrentPosition = new Vector2(this.Fireball.CurrentPosition.X - (intersectRect.Width),
                                                     this.Fireball.CurrentPosition.Y);
         this.Fireball.CurrentVelocity = new Vector2(-ProjectileConfig.FireballVelocity, this.Fireball.CurrentVelocity.Y);
     }
     else if (SideGeneralizer.IsTop(side))
     {
         if (Fireball.IsAffectedByGravity)
         {
             this.Fireball.CurrentPosition = new Vector2(this.Fireball.CurrentPosition.X, this.Fireball.CurrentPosition.Y + intersectRect.Height);
             this.Fireball.CurrentVelocity = new Vector2(this.Fireball.CurrentVelocity.X, 0f);
         }
     }
 }
Ejemplo n.º 4
0
 private void RespondToCollisionWithBlock(IObject obj, Side side, Rectangle intersectRect)
 {
     if (!((obj as Block) != null && (obj as Block).CurrentState is HiddenBlockState))
     {
         if (SideGeneralizer.IsLeft(side))
         {
             this.Star.CurrentPosition = new Vector2(this.Star.CurrentPosition.X + (intersectRect.Width),
                                                     this.Star.CurrentPosition.Y);
             this.Star.CurrentVelocity = new Vector2(ItemConfig.StarVelocity, this.Star.CurrentVelocity.Y);
         }
         else if (SideGeneralizer.IsRight(side))
         {
             this.Star.CurrentPosition = new Vector2(this.Star.CurrentPosition.X - (intersectRect.Width),
                                                     this.Star.CurrentPosition.Y);
             this.Star.CurrentVelocity = new Vector2(-ItemConfig.StarVelocity, this.Star.CurrentVelocity.Y);
         }
         else if (SideGeneralizer.IsBottom(side))
         {
             this.Star.CurrentPosition = new Vector2(this.Star.CurrentPosition.X, this.Star.CurrentPosition.Y - intersectRect.Height);
             if (!this.Star.Spawning)
             {
                 this.Star.CurrentVelocity = new Vector2(this.Star.CurrentVelocity.X, ItemConfig.StarBounceVelocity);
             }
         }
         else if (SideGeneralizer.IsTop(side))
         {
             this.Star.CurrentPosition = new Vector2(this.Star.CurrentPosition.X, this.Star.CurrentPosition.Y + intersectRect.Height);
             this.Star.CurrentVelocity = new Vector2(ItemConfig.StarVelocity, 0);
         }
     }
 }
 private void RespondToCollisionWithProjectile(Side side)
 {
     if (SideGeneralizer.IsRight(side) || side == Side.RightOfTop || side == Side.RightOfBottom)
     {
         this.Shell.GoLeft();
     }
     else if (SideGeneralizer.IsLeft(side) || side == Side.LeftOfTop || side == Side.LeftOfBottom)
     {
         this.Shell.GoRight();
     }
 }
Ejemplo n.º 6
0
 private void RespondToSide(Side side, Rectangle intersectRect)
 {
     if (SideGeneralizer.IsLeft(side))
     {
         this.RespondToLeft(intersectRect);
     }
     else if (SideGeneralizer.IsRight(side))
     {
         this.RespondToRight(intersectRect);
     }
 }
 private void RespondToCollisionWithEnemy(Side side, IEnemy enemy)
 {
     if (!enemy.IsDead)
     {
         if (SideGeneralizer.IsLeft(side))
         {
             this.FlyingKoopa.GoRight();
         }
         else if (SideGeneralizer.IsRight(side))
         {
             this.FlyingKoopa.GoLeft();
         }
     }
 }
 private void RespondToCollisionWithBlockPipe(Side side, Rectangle intersectRectangle)
 {
     if (SideGeneralizer.IsBottom(side))
     {
         this.Koopa.CurrentPosition = new Vector2(this.Koopa.CurrentPosition.X, this.Koopa.CurrentPosition.Y - intersectRectangle.Height);
         this.Koopa.CurrentVelocity = new Vector2(this.Koopa.CurrentVelocity.X, 0);
     }
     else if (SideGeneralizer.IsRight(side))
     {
         this.Koopa.GoLeft();
     }
     else if (SideGeneralizer.IsLeft(side))
     {
         this.Koopa.GoRight();
     }
 }
 private void RespondToCollisionWithBlock(IObject obj, Side side, Rectangle intersectRectangle)
 {
     if (!((obj as Block) != null && (obj as Block).CurrentState is HiddenBlockState))
     {
         if (SideGeneralizer.IsRight(side))
         {
             this.Shell.GoLeft();
         }
         else if (SideGeneralizer.IsLeft(side))
         {
             this.Shell.GoRight();
         }
         else if (SideGeneralizer.IsBottom(side))
         {
             this.Shell.CurrentPosition = new Vector2(this.Shell.CurrentPosition.X, this.Shell.CurrentPosition.Y - intersectRectangle.Height);
             this.Shell.CurrentVelocity = new Vector2(this.Shell.CurrentVelocity.X, 0);
         }
     }
 }
 private void RespondToCollisionWithShell(Shell shell, Side side)
 {
     if (shell.IsMovingHorizontally())
     {
         this.FlyingKoopa.SetDead();
         GameStats.Points += PointsConfig.EnemyKillWithShell;
     }
     else
     {
         if (SideGeneralizer.IsLeft(side))
         {
             this.FlyingKoopa.GoRight();
         }
         else if (SideGeneralizer.IsRight(side))
         {
             this.FlyingKoopa.GoLeft();
         }
     }
 }
Ejemplo n.º 11
0
 private void RespondToCollisionWithMario(Side side, IMario mario, Rectangle intersectRect)
 {
     mario.OnTransPipe       = false;
     mario.TouchingTransPipe = false;
     if (this.Pipe is PipeTop)
     {
         PipeTop pipeTop = (PipeTop)this.Pipe;
         if (pipeTop.IsTransitional)
         {
             if (IsAbleToEnterPipe(side, pipeTop, intersectRect))
             {
                 mario.OnTransPipe = true;
             }
             else if ((SideGeneralizer.IsLeft(side) || SideGeneralizer.IsRight(side)) && pipeTop.Side)
             {
                 mario.TouchingTransPipe = true;
             }
         }
     }
 }
 private void RespondToCollisionWithEnemy(Side side, IEnemy enemy, Rectangle intersectRectangle)
 {
     if (!enemy.IsDead)
     {
         if (SideGeneralizer.IsLeft(side))
         {
             this.Lakitu.CurrentPosition = new Vector2(this.Lakitu.CurrentPosition.X + intersectRectangle.Width, this.Lakitu.CurrentPosition.Y);
             this.Lakitu.Rise();
         }
         else if (SideGeneralizer.IsRight(side))
         {
             this.Lakitu.CurrentPosition = new Vector2(this.Lakitu.CurrentPosition.X - intersectRectangle.Width, this.Lakitu.CurrentPosition.Y);
             this.Lakitu.Rise();
         }
         else
         {
             this.Lakitu.Rise();
         }
     }
 }
 private void RespondToCollisionWithPipeBlock(Side side, Rectangle intersectRectangle)
 {
     if (SideGeneralizer.IsBottom(side))
     {
         this.Lakitu.CurrentPosition = new Vector2(this.Lakitu.CurrentPosition.X, this.Lakitu.CurrentPosition.Y - intersectRectangle.Height);
         this.Lakitu.CurrentVelocity = new Vector2(this.Lakitu.CurrentVelocity.X, 0f);
     }
     else if (SideGeneralizer.IsRight(side))
     {
         this.Lakitu.CurrentPosition = new Vector2(this.Lakitu.CurrentPosition.X - intersectRectangle.Width, this.Lakitu.CurrentPosition.Y);
         this.Lakitu.Rise();
     }
     else if (SideGeneralizer.IsLeft(side))
     {
         this.Lakitu.CurrentPosition = new Vector2(this.Lakitu.CurrentPosition.X + intersectRectangle.Width, this.Lakitu.CurrentPosition.Y);
         this.Lakitu.Rise();
     }
     else
     {
         this.Lakitu.CurrentPosition = new Vector2(this.Lakitu.CurrentPosition.X, this.Lakitu.CurrentPosition.Y + intersectRectangle.Height);
         this.Lakitu.CurrentVelocity = new Vector2(this.Lakitu.CurrentVelocity.X, 0f);
     }
 }
Ejemplo n.º 14
0
 private static bool ShouldRespondToSide(Side side, Rectangle intersectRect)
 {
     return(intersectRect.Width / MarioConfig.SideSpeed + MarioConfig.SideSpeed / 2 > intersectRect.Height ||
            SideGeneralizer.IsLeft(side) || SideGeneralizer.IsRight(side));
 }