public static void HandleCollision(IPlayer marioPlayer, IEnemy enemy, Game1.Side side) { Mario mario = (Mario)marioPlayer; if (!mario.IsInSpecialAnimationState()) { if (mario.IsStarMario() && !side.Equals(Game1.Side.None)) { enemy.BeFlipped(); } else if (side.Equals(Game1.Side.Left) || side.Equals(Game1.Side.Right) || side.Equals(Game1.Side.Top)) { mario.TakeDamage(); } //case mario on enemy else if (side.Equals(Game1.Side.Bottom)) { int bounceVelocity = -4; // case enemy is goomba if (enemy is Goomba) { Goomba localGoomba = (Goomba)enemy; localGoomba.KillEnemy(); mario.SetVerticalVelocity(bounceVelocity); } if (enemy is Koopa) { Koopa localKoopa = (Koopa)enemy; localKoopa.KillEnemy(); mario.SetVerticalVelocity(bounceVelocity); } if (!WorldManager.spriteSet.players[0].GetTouchedGround()) { WorldManager.spriteSet.players[0].IncrementEnemyMultiplier(); } } } }
public static void HandleCollision(Fireball fireball, IEnemy enemy, Game1.Side side) { EnemyGravityHandler gravity = new EnemyGravityHandler(); if (side != Game1.Side.None) { if (enemy is Goomba) { Goomba localGoomba = (Goomba)enemy; localGoomba.BeFlipped(); gravity.ApplyGravityToEnemy(localGoomba); } if (enemy is Koopa) { Koopa localKoopa = (Koopa)enemy; localKoopa.BeFlipped(); gravity.ApplyGravityToEnemy(localKoopa); } fireball.ChangeState(); } }
public GoombaStompedState(Goomba goomba) { this.goomba = goomba; this.goomba.goombaSprite = new GoombaStompedSprite(); }
public NightmareState(Goomba myGoomba) { this.goomba = myGoomba; this.goomba.goombaSprite = new NightmareSprite(); }
public GoombaDeadState(Goomba myGoomba) { this.goomba = myGoomba; this.goomba.goombaSprite = new GoombaDeadSprite(); }
public GoombaRightMovingState(Goomba myGoomba) { this.goomba = myGoomba; this.goomba.goombaSprite = new GoombaSprite(); }
public void CheckGoombaCollisions(List <IBlock> blocks, List <IPipe> pipes, List <IEnemy> goombas, List <IEnemy> koopas) { Game1.Side collisionType = Game1.Side.None; GeneralCollisionDetector generalDetector = new GeneralCollisionDetector(); EnemyGravityHandler gravityHandler = new EnemyGravityHandler(); for (int loop = 0; loop < goombas.Count; loop++) { Goomba goomba = (Goomba)goombas.ElementAt(loop); Rectangle currentGoomba = goomba.GetRectangle(); bool goombaIsSupported = false; for (int secondLoop = loop + 1; secondLoop < goombas.Count; secondLoop++) { Goomba secondGoomba = (Goomba)goombas.ElementAt(secondLoop); Rectangle currentSecondGoomba = secondGoomba.GetRectangle(); collisionType = generalDetector.DetermineCollision(currentGoomba, currentSecondGoomba); EnemyEnemyCollisionHandler.HandleCollision(goomba, secondGoomba, collisionType); } foreach (Koopa koopa in koopas) { Rectangle currentKoopa = koopa.GetRectangle(); collisionType = generalDetector.DetermineCollision(currentGoomba, currentKoopa); EnemyEnemyCollisionHandler.HandleCollision(goomba, koopa, collisionType); } foreach (IPipe pipe in pipes) { Rectangle currentPipe = pipe.GetRectangle(); collisionType = generalDetector.DetermineCollision(currentGoomba, currentPipe); EnemyPipeCollisionHandler.HandleCollision(goomba, pipe, collisionType); if (collisionType.Equals(Game1.Side.Bottom) || (currentPipe.Top - currentGoomba.Bottom <= 3 && generalDetector.IsAlongSameYAxis(currentGoomba, currentPipe))) { goombaIsSupported = true; } } foreach (IBlock block in blocks) { Rectangle currentBlock = block.GetRectangle(); collisionType = generalDetector.DetermineCollision(currentGoomba, currentBlock); EnemyBlockCollisionHandler.HandleCollision(goomba, block, collisionType); if (collisionType.Equals(Game1.Side.Bottom) || (currentBlock.Top - currentGoomba.Bottom <= 3 && generalDetector.IsAlongSameYAxis(currentGoomba, currentBlock))) { goombaIsSupported = true; } } if (!goombaIsSupported) { gravityHandler.ApplyGravityToEnemy(goomba); } else { goomba.SetGrounded(); } } }