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);
         }
     }
 }
Пример #2
0
 private bool ShouldTakeDamageFromEnemy(Side side, IEnemy enemy)
 {
     if (enemy is Spiny)
     {
         return(!SideGeneralizer.IsTop(side) && !this.Mario.IsStar &&
                this.Mario.PowerLevel() != MarioPowerLevel.Metal && !this.Mario.IsTransitioningFromDamage && !enemy.IsDead);
     }
     else if (enemy is Lakitu)
     {
         return(false);
     }
     else
     {
         if (this.Mario.IsFalling())
         {
             return(!(SideGeneralizer.IsBottom(side) || side == Side.BottomOfLeft || side == Side.BottomOfRight) && !this.Mario.IsStar &&
                    this.Mario.PowerLevel() != MarioPowerLevel.Metal && !this.Mario.IsTransitioningFromDamage && !enemy.IsDead);
         }
         else
         {
             return(!SideGeneralizer.IsBottom(side) && !this.Mario.IsStar &&
                    this.Mario.PowerLevel() != MarioPowerLevel.Metal && !this.Mario.IsTransitioningFromDamage && !enemy.IsDead);
         }
     }
 }
 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);
         }
     }
 }
Пример #5
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 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();
     }
 }
Пример #7
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 RespondToCollisionWithMario(Side side, IMario mario)
 {
     if (SideGeneralizer.IsTop(side) && mario.IsFalling())
     {
         SoundBoard.Stomp.Play();
         this.Lakitu.Kill();
     }
     else if (ShouldDie(mario))
     {
         this.Lakitu.Kill();
     }
 }
        private void RespondToCollisionWithMario(Side side, IObject obj)
        {
            Mario mario = (Mario)obj;

            if (mario.IsStar || mario.PowerLevel() == MarioPowerLevel.Metal)
            {
                this.Spiny.Kill();
            }
            else if (SideGeneralizer.IsBottom(side))
            {
                this.Spiny.Kill();
            }
        }
 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 RespondToCollisionWithMario(Side side, IObject obj)
        {
            Mario mario = (Mario)obj;

            if (mario.IsStar || mario.PowerLevel() == MarioPowerLevel.Metal)
            {
                this.Koopa.SetDead();
            }
            else if (SideGeneralizer.IsTop(side))
            {
                this.Koopa.WillBecomeShell = true;
                this.Koopa.SetStomped();
            }
        }
 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();
     }
 }
Пример #13
0
        private void RespondToCollisionWithPipe(Side side, Rectangle intersectRect)
        {
            if (ShouldRespondToSide(side, intersectRect))
            {
                this.RespondToSide(side, intersectRect);
            }

            else if (SideGeneralizer.IsBottom(side))
            {
                this.RespondToBottom(intersectRect);
            }

            else if (SideGeneralizer.IsTop(side))
            {
                this.RespondToTop(intersectRect);
            }
        }
Пример #14
0
 private void RespondToCollisionWithBlock(Side side, Block block, Rectangle intersectRect)
 {
     if (BlockIsThere(block))
     {
         if (SideGeneralizer.IsTop(side) && !WillMoveThroughBlock(block))
         {
             this.RespondToTop(intersectRect);
         }
         else if (ShouldRespondToSide(side, intersectRect) && !WillMoveThroughBlock(block))
         {
             this.RespondToSide(side, intersectRect);
         }
         else if (SideGeneralizer.IsBottom(side))
         {
             this.RespondToBottom(intersectRect);
         }
     }
 }
 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();
         }
     }
 }
Пример #17
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);
     }
 }
Пример #20
0
 private static bool IsAbleToEnterPipe(Side side, PipeTop pipeTop, Rectangle intersectRect)
 {
     return(SideGeneralizer.IsTop(side) && !pipeTop.Side &&
            (Math.Abs(intersectRect.Center.X - (pipeTop.CurrentPosition.X + pipeTop.Width / 2)) < Level1Config.MarioOnPipeCenterTolerance));
 }
Пример #21
0
 private bool ShouldBounceOffEnemy(Side side, IEnemy enemy)
 {
     return(SideGeneralizer.IsBottom(side) && !this.Mario.IsStar && this.Mario.IsFalling() && !enemy.IsDead);
 }
Пример #22
0
 private bool ShouldBounceOffShell(Side side)
 {
     return(SideGeneralizer.IsBottom(side) && !this.Mario.IsStar);
 }
Пример #23
0
        private bool ShouldTakeDamageFromShell(Side side, IObject obj)
        {
            Shell shell = (Shell)obj;

            return(shell.IsMovingHorizontally() && !(SideGeneralizer.IsBottom(side)) && !this.Mario.IsStar && !this.Mario.IsTransitioningFromDamage);
        }
Пример #24
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));
 }