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); } } }
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 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 (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.Koopa.SetDead(); } else if (SideGeneralizer.IsTop(side)) { this.Koopa.WillBecomeShell = true; this.Koopa.SetStomped(); } }
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); } }
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 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)); }