public Mario() { MaxHorizontalVelocity = GameValues.MarioWalkingSpeed; Velocity = Vector2.Zero; MaxVelocity = new Vector2(MaxHorizontalVelocity, GameValues.PhysicsMaxYVelocity); Acceleration = Vector2.Zero; CollisionRectangle = new Rectangle((int)Position.X, (int)Position.Y, 0, 0); PlayableObjectStateTransitionMachine = new PlayableObjectStateTransitionMachine(this); Lives = GameValues.MarioStartingLives; numberOfFireballs = GameValues.MarioNumberOfFireBalls; fireballs = new Fireball[numberOfFireballs]; fireballs[0] = new Fireball(Vector2.Zero, false, false); fireballs[1] = new Fireball(Vector2.Zero, false, false); deathBuffer = GameValues.MarioDeathBuffer; invisibleBuffer = GameValues.MarioInvisibleBuffer; visibleBuffer = GameValues.MarioVisibleBuffer; takenDamageBuffer = GameValues.MarioTakenDamageBuffer; starBuffer = GameValues.MarioStarBuffer; InAir = false; IsJumping = false; StarPower = false; IsSlidingOnPole = false; TakenDamageState = false; InCoinRoom = false; IsEnteringPipe = false; IsExitingPipe = false; IsBig = false; OnYoshi = false; ReverseYoshiSprites = false; }
public void StaticStateChange(String location, Fireball fireball, IStaticObject staticObject) { if (location == GameValues.CollisionDirectionTop || location == GameValues.CollisionDirectionBottom || staticObject.ToString() == "SuperMario.FloorTile") { fireball.Position = new Vector2(fireball.Position.X, staticObject.CollisionRectangle.Top - fireball.CollisionRectangle.Height); fireball.CollisionRectangle = new Rectangle((int)fireball.Position.X, (int)fireball.Position.Y, fireball.CollisionRectangle.Width, fireball.CollisionRectangle.Height); fireball.Velocity = new Vector2(fireball.Velocity.X, fireball.Velocity.Y * (-1)); } else { fireball.IsAlive = false; } }
public void DynamicStateChange(String location, Fireball fireball, IDynamicObject dynamicObject) { if (dynamicObject.ToString() == "SuperMario.Block") { if (location == GameValues.CollisionDirectionTop || location == GameValues.CollisionDirectionBottom) { new GenericTopOrBottomCollisionCommand(fireball).Execute(); } else { fireball.IsAlive = false; } } else if (dynamicObject.ToString() != "SuperMario.Mario") { fireball.IsAlive = false; } }
public void ThrowFireball() { // Make sure this can only run when Mario is Fire. if (this.PlayableObjectState.ToString().Substring(23, 4) == "Fire") { if (!fireballs[0].IsAlive) { if (this.PlayableObjectState.ToString().Substring(27, 4) == "Left") { fireballs[0] = new Fireball(new Vector2(this.CollisionRectangle.Left, this.CollisionRectangle.Center.Y), false, false); } else if (this.PlayableObjectState.ToString().Substring(27, 5) == "Right") { fireballs[0] = new Fireball(new Vector2(this.CollisionRectangle.Right, this.CollisionRectangle.Center.Y), true, false); } fireballs[0].IsAlive = true; SoundManager.Instance.PlayFireballSound(); } else if (!fireballs[1].IsAlive) { if (this.PlayableObjectState.ToString().Substring(27, 4) == "Left") { fireballs[1] = new Fireball(new Vector2(this.CollisionRectangle.Left, this.CollisionRectangle.Center.Y), false, false); } else if (this.PlayableObjectState.ToString().Substring(27, 5) == "Right") { fireballs[1] = new Fireball(new Vector2(this.CollisionRectangle.Right, this.CollisionRectangle.Center.Y), true, false); } fireballs[1].IsAlive = true; SoundManager.Instance.PlayFireballSound(); } } }
public Enemy(Vector2 position, string enemyState) { Position = position; MaxVelocity = new Vector2(GameValues.EnemyMaxXVelocity, GameValues.PhysicsMaxYVelocity); Acceleration = Vector2.Zero; EnemyStateTransitionMachine = new EnemyStateTransitionMachine(); IsFlipped = false; IsSlidingShell = false; IsTongueCaptured = false; rand = new Random(); randBuffer = 0; Fireball = new Fireball(Vector2.Zero, false, true); koopaShellTimeout = GameValues.EnemyKoopaShellTimeout; deadGoombaTimeout = GameValues.EnemyDeadEnemyTimeout; if (enemyState == "WalkingGoomba") { EnemyState = new WalkingGoomba(position, this); Velocity = new Vector2(-MaxVelocity.X, 0); } else if (enemyState == "RightWalkingKoopa") { EnemyState = new RightWalkingKoopa(position, this); Velocity = new Vector2(MaxVelocity.X, 0); } else if (enemyState == "LeftWalkingKoopa") { EnemyState = new LeftWalkingKoopa(position, this); Velocity = new Vector2(-MaxVelocity.X, 0); } else if (enemyState == "PiranhaPlant") { EnemyState = new PiranhaPlant(position, this); } else if (enemyState == "HidingInsideShellKoopa") { EnemyState = new HidingInsideShellKoopa(position, this); } else if (enemyState == "ComingOutOfShellKoopa") { EnemyState = new ComingOutOfShellKoopa(position, this); } else if (enemyState == "CrawfisLeft") { EnemyState = new CrawfisLeft(position, this); Velocity = new Vector2(-MaxVelocity.X, 0); } else if (enemyState == "BowserLeft") { EnemyState = new BowserLeft(position, this); Velocity = new Vector2(-MaxVelocity.X, 0); } else if (enemyState == "NoEnemy") { EnemyState = new NoEnemy(this); } CollisionRectangle = EnemyState.CollisionRectangle; }
public void AI() { if (randBuffer >= GameValues.EnemyAIRandomBufferMax) { randBuffer = 0; // Select random case from 1 to max - 1 (eg .Next(1, 4) -> random number 1, 2, or 3) int caseNum = rand.Next(1, 7); switch (caseNum) { case 1: // Reverse direction. Velocity = new Vector2(-Velocity.X, Velocity.Y); ChangeState(EnemyState.ToString()); break; case 2: // Make it jump if not in air. if (!InAir) { InAir = true; Velocity = new Vector2(Velocity.X, GameValues.EnemyAINotInAirYVelocity); Physics.Move(this); } else { Physics.Move(this); } break; case 3: // Shoot fireball if (!Fireball.IsAlive) { if (EnemyState.ToString().Substring(30, 4) == "Left") { Fireball = new Fireball(new Vector2(this.CollisionRectangle.Left - 8, this.CollisionRectangle.Center.Y), false, true); } else { Fireball = new Fireball(new Vector2(this.CollisionRectangle.Right, this.CollisionRectangle.Center.Y), true, true); } Fireball.IsAlive = true; SoundManager.Instance.PlayFireballSound(); } break; case 4: // Play SoundClip SoundManager.Instance.PlayYourCodeSucksSound(); break; case 5: // Play Laugh SoundManager.Instance.PlayLaughSound(false); break; case 6: // Play Evil Laugh SoundManager.Instance.PlayLaughSound(true); break; } } else { randBuffer++; } }
public void DynamicStateChange(String location, Enemy enemy, IDynamicObject dynamicObject) { if (dynamicObject.ToString() == "SuperMario.Mario" && Mario.Instance.PlayableObjectState.ToString() != "SuperMario.MarioStates.DeadMario") { if (Mario.Instance.StarPower) { enemy.Velocity = Vector2.Zero; enemy.FlipState(enemy.EnemyState.ToString()); } else if ((location == "Top" || Mario.Instance.CollisionRectangle.Center.Y < dynamicObject.Position.Y) && enemy.EnemyState.ToString() != "SuperMario.EnemyStates.PiranhaPlant") { // Mario lands on top of enemy and kills it. if (enemy.EnemyState.ToString() != "SuperMario.EnemyStates.LeftWalkingKoopa" && enemy.EnemyState.ToString() != "SuperMario.EnemyStates.RightWalkingKoopa" && enemy.EnemyState.ToString() != "SuperMario.EnemyStates.HidingInsideShellKoopa" && enemy.EnemyState.ToString() != "SuperMario.EnemyStates.ComingOutOfShellKoopa") { enemy.Velocity = Vector2.Zero; if (enemy.EnemyState.ToString() == "SuperMario.EnemyStates.WalkingGoomba") { enemy.Position = new Vector2(enemy.Position.X, enemy.Position.Y); enemy.EnemyState = new DeadGoomba(enemy.Position, enemy); enemy.EnemyState.ScoreSprite.ScoringOn = true; HUD.Instance.ScoreHUDCounter += enemy.EnemyState.ScoreValue; } else if (enemy.EnemyState.ToString() == "SuperMario.EnemyStates.CrawfisLeft" || enemy.EnemyState.ToString() == "SuperMario.EnemyStates.CrawfisRight" || enemy.EnemyState.ToString() == "SuperMario.EnemyStates.BowserLeft" || enemy.EnemyState.ToString() == "SuperMario.EnemyStates.BowserRight") { enemy.FlipState(enemy.EnemyState.ToString()); enemy.EnemyState.ScoreSprite.ScoringOn = true; HUD.Instance.ScoreHUDCounter += enemy.EnemyState.ScoreValue; } else if (enemy.EnemyState.ToString() != "SuperMario.EnemyStates.DeadGoomba" && enemy.EnemyState.ToString() != "SuperMario.EnemyStates.BowserDead") { enemy.EnemyState.ScoreSprite.ScoringOn = true; enemy.EnemyState.ScoreSprite = new ScoreSprite(enemy.EnemyState.ScoreSprite.ScoreValue(), enemy.Position, true); enemy.EnemyState = new NoEnemy(enemy); } } else if (enemy.EnemyState.ToString() == "SuperMario.EnemyStates.HidingInsideShellKoopa" || enemy.EnemyState.ToString() == "SuperMario.EnemyStates.ComingOutOfShellKoopa") { if (enemy.IsSlidingShell) { enemy.IsSlidingShell = false; enemy.Velocity = new Vector2(Vector2.Zero.X, enemy.Velocity.Y); } else { if (Mario.Instance.CollisionRectangle.Center.X > enemy.CollisionRectangle.Center.X) { enemy.Velocity = new Vector2(GameValues.EnemyStateMachineKoopaShellXVelocity, enemy.Velocity.Y); } else { enemy.Velocity = new Vector2(-GameValues.EnemyStateMachineKoopaShellXVelocity, enemy.Velocity.Y); } enemy.EnemyState = new HidingInsideShellKoopa(enemy.Position, enemy); enemy.MaxVelocity = new Vector2(GameValues.EnemyStateMachineKoopaShellXVelocity, enemy.MaxVelocity.Y); enemy.IsSlidingShell = true; } } else if (enemy.EnemyState.ToString() == "SuperMario.EnemyStates.PiranhaPlant") { // If Mario hits the top of a piranha plant he should die, this will take place within MarioTransitionMachine. } else { // Turn the Koopa into a shell state. HUD.Instance.ScoreHUDCounter += enemy.EnemyState.ScoreValue; enemy.EnemyState.ScoreSprite.ScoringOn = true; enemy.EnemyState = new HidingInsideShellKoopa(enemy.Position, enemy); enemy.Velocity = Vector2.Zero; } } else if ((location == "Left" || location == null) && Mario.Instance.IsYoshiTongueRight && !enemy.IsTongueCaptured) { Mario.Instance.IsYoshiEating = true; enemy.IsTongueCaptured = true; enemy.Position = new Vector2(Mario.Instance.CollisionRectangle.Right - 10, Mario.Instance.CollisionRectangle.Top); } else if ((location == "Right" || location == null) && Mario.Instance.IsYoshiTongueLeft && !enemy.IsTongueCaptured) { Mario.Instance.IsYoshiEating = true; enemy.IsTongueCaptured = true; enemy.Position = new Vector2(Mario.Instance.CollisionRectangle.Left + 10, Mario.Instance.CollisionRectangle.Top); } else if (enemy.IsTongueCaptured) { if (Mario.Instance.IsYoshiFinishedEating) { HUD.Instance.ScoreHUDCounter += enemy.EnemyState.ScoreValue; enemy.IsTongueCaptured = false; enemy.EnemyState = new NoEnemy(enemy); } else if (Mario.Instance.IsYoshiTongueLeft) { enemy.Position = new Vector2(Mario.Instance.CollisionRectangle.Left + 16, Mario.Instance.CollisionRectangle.Top); } else if (Mario.Instance.IsYoshiTongueRight) { enemy.Position = new Vector2(Mario.Instance.CollisionRectangle.Right - 16, Mario.Instance.CollisionRectangle.Top); } } else if ((enemy.EnemyState.ToString() == "SuperMario.EnemyStates.HidingInsideShellKoopa" || enemy.EnemyState.ToString() == "SuperMario.EnemyStates.ComingOutOfShellKoopa") && !enemy.IsSlidingShell) { if (location == GameValues.CollisionDirectionLeft) { enemy.Velocity = new Vector2(GameValues.EnemyStateMachineKoopaShellXVelocity, enemy.Velocity.Y); enemy.MaxVelocity = new Vector2(GameValues.EnemyStateMachineKoopaShellXVelocity, enemy.MaxVelocity.Y); enemy.Position = new Vector2(enemy.Position.X + GameValues.EnemyStateMachineKoopaShellXPositionOffset, enemy.Position.Y); enemy.EnemyState = new HidingInsideShellKoopa(enemy.Position, enemy); enemy.IsSlidingShell = true; } else if (location == GameValues.CollisionDirectionRight) { enemy.Velocity = new Vector2(-GameValues.EnemyStateMachineKoopaShellXVelocity, enemy.Velocity.Y); enemy.MaxVelocity = new Vector2(GameValues.EnemyStateMachineKoopaShellXVelocity, enemy.MaxVelocity.Y); enemy.Position = new Vector2(enemy.Position.X - GameValues.EnemyStateMachineKoopaShellXPositionOffset, enemy.Position.Y); enemy.EnemyState = new HidingInsideShellKoopa(enemy.Position, enemy); enemy.IsSlidingShell = true; } } } else if (dynamicObject.ToString() == "SuperMario.Block" || dynamicObject.ToString() == "SuperMario.Enemy" || dynamicObject.ToString() == "SuperMario.Fireball") { bool shellEnemyCollision = false; bool blockMovingCollision = false; if (dynamicObject.ToString() == "SuperMario.Enemy" && enemy.EnemyState.ToString() == "SuperMario.EnemyStates.HidingInsideShellKoopa") { foreach (Enemy enemy2 in Level.Instance.Enemies) { if (enemy2.Position.X == dynamicObject.Position.X && enemy2.Position.Y == dynamicObject.Position.Y) { if (enemy2.EnemyState.ToString() == "SuperMario.EnemyStates.WalkingGoomba") { //Goomba death shellEnemyCollision = true; } else if (enemy2.EnemyState.ToString() == "SuperMario.EnemyStates.LeftWalkingKoopa" || enemy2.EnemyState.ToString() == "SuperMario.EnemyStates.RightWalkingKoopa") { //Koopa death shellEnemyCollision = true; } } } } if (dynamicObject.ToString() == "SuperMario.Block") { Block block = dynamicObject as Block; if (block.IsMoving) { enemy.FlipState(enemy.EnemyState.ToString()); blockMovingCollision = true; } } if (shellEnemyCollision || dynamicObject.ToString() == "SuperMario.Fireball") { if (dynamicObject.ToString() == "SuperMario.Fireball") { Fireball fireballTemp = dynamicObject as Fireball; // If it is not an enemy fireball, then kill the enemy. if (!fireballTemp.IsEnemyFireball) { enemy.FlipState(enemy.EnemyState.ToString()); } } else { enemy.FlipState(enemy.EnemyState.ToString()); } } if (!shellEnemyCollision && !blockMovingCollision) { if (location == GameValues.CollisionDirectionTop) { enemy.Position = new Vector2(enemy.Position.X, dynamicObject.CollisionRectangle.Top - enemy.CollisionRectangle.Height); enemy.CollisionRectangle = new Rectangle((int)enemy.Position.X, (int)enemy.Position.Y, enemy.CollisionRectangle.Width, enemy.CollisionRectangle.Height); } else if (location == GameValues.CollisionDirectionBottom) { enemy.Position = new Vector2(enemy.Position.X, dynamicObject.CollisionRectangle.Top - enemy.CollisionRectangle.Height); enemy.CollisionRectangle = new Rectangle((int)enemy.Position.X, (int)enemy.Position.Y, enemy.CollisionRectangle.Width, enemy.CollisionRectangle.Height); } else if (location == GameValues.CollisionDirectionRight) { enemy.Position = new Vector2(dynamicObject.CollisionRectangle.Left - enemy.CollisionRectangle.Width, enemy.Position.Y); enemy.CollisionRectangle = new Rectangle((int)enemy.Position.X, (int)enemy.Position.Y, enemy.CollisionRectangle.Width, enemy.CollisionRectangle.Height); enemy.Velocity = new Vector2(enemy.Velocity.X * (-1), enemy.Velocity.Y); enemy.ChangeState(enemy.EnemyState.ToString()); } else if (location == GameValues.CollisionDirectionLeft) { enemy.Position = new Vector2(dynamicObject.CollisionRectangle.Right, enemy.Position.Y); enemy.CollisionRectangle = new Rectangle((int)enemy.Position.X, (int)enemy.Position.Y, enemy.CollisionRectangle.Width, enemy.CollisionRectangle.Height); enemy.Velocity = new Vector2(enemy.Velocity.X * (-1), enemy.Velocity.Y); enemy.ChangeState(enemy.EnemyState.ToString()); } else { enemy.Position = new Vector2(enemy.Position.X, dynamicObject.CollisionRectangle.Top - enemy.CollisionRectangle.Height); enemy.CollisionRectangle = new Rectangle((int)enemy.Position.X, (int)enemy.Position.Y, enemy.CollisionRectangle.Width, enemy.CollisionRectangle.Height); } } } }
public void PlayFireballSound() { Fireball.Play(); }
public void DynamicStateChange(String collisionDirection, String currentState, IDynamicObject dynamicObject) { if (dynamicObject.ToString() == "SuperMario.Block") { if (playableObject.IsSlidingOnPole) { new MarioSlidesOnFlagPoleCommand(playableObject, dynamicObject).Execute(); finishedCollidingWithFlagPole = true; } else if (finishedCollidingWithFlagPole == true) { if (flagSlideEndBuffer <= 0) { flagSlideEndBuffer = GameValues.MarioStateMachineFlagSlideEndBuffer; new MarioFinishedCollidingWithFlagPoleCommand().Execute(playableObject); } else { flagSlideEndBuffer--; } } else { if (collisionDirection == GameValues.CollisionDirectionTop && !(playableObject.CollisionRectangle.Left >= dynamicObject.CollisionRectangle.Right - GameValues.MarioStateMachineDynamicObjectCollisionRectangleOffset) && !(playableObject.CollisionRectangle.Right <= dynamicObject.CollisionRectangle.Left + GameValues.MarioStateMachineDynamicObjectCollisionRectangleOffset)) { playableObject.Position = new Vector2(playableObject.Position.X, dynamicObject.CollisionRectangle.Bottom); playableObject.CollisionRectangle = new Rectangle((int)playableObject.Position.X, (int)playableObject.Position.Y, playableObject.CollisionRectangle.Width, playableObject.CollisionRectangle.Height); //Reverse Y Velocity for bouncing effect. playableObject.Velocity = new Vector2(playableObject.Velocity.X, playableObject.Velocity.Y * -1); playableObject.Acceleration = new Vector2(playableObject.Acceleration.X, 0.0f); } else if (collisionDirection == GameValues.CollisionDirectionBottom && !(playableObject.CollisionRectangle.Left >= dynamicObject.CollisionRectangle.Right - GameValues.MarioStateMachineDynamicObjectCollisionRectangleOffset) && !(playableObject.CollisionRectangle.Right <= dynamicObject.CollisionRectangle.Left + GameValues.MarioStateMachineDynamicObjectCollisionRectangleOffset)) { new MarioCollidesWithGroundCommand(playableObject).Execute(); playableObject.Position = new Vector2(playableObject.Position.X, dynamicObject.CollisionRectangle.Top - playableObject.CollisionRectangle.Height); playableObject.CollisionRectangle = new Rectangle((int)playableObject.Position.X, (int)playableObject.Position.Y, playableObject.CollisionRectangle.Width, playableObject.CollisionRectangle.Height); } else if (collisionDirection == GameValues.CollisionDirectionRight) { playableObject.Position = new Vector2(dynamicObject.CollisionRectangle.Left - playableObject.CollisionRectangle.Width + 0.9f, playableObject.Position.Y); playableObject.CollisionRectangle = new Rectangle((int)playableObject.Position.X, (int)playableObject.Position.Y, playableObject.CollisionRectangle.Width, playableObject.CollisionRectangle.Height); if (playableObject.Velocity.X > Vector2.Zero.X) { playableObject.Velocity = new Vector2(GameValues.MarioStateMachineCollisionNewXVelocity, playableObject.Velocity.Y); } } else if (collisionDirection == GameValues.CollisionDirectionLeft) { playableObject.Position = new Vector2(dynamicObject.CollisionRectangle.Right, playableObject.Position.Y); playableObject.CollisionRectangle = new Rectangle((int)playableObject.Position.X, (int)playableObject.Position.Y, playableObject.CollisionRectangle.Width, playableObject.CollisionRectangle.Height); if (playableObject.Velocity.X < Vector2.Zero.X) { playableObject.Velocity = new Vector2(GameValues.MarioStateMachineCollisionNewXVelocity, playableObject.Velocity.Y); } } } } else if (dynamicObject.ToString() == "SuperMario.Item") { string itemType = ""; string previousItemType = ""; int itemScoreValue = GameValues.MarioStateMachineInitialItemScoreValue; foreach (Block block in Level.Instance.Blocks) { if (block.Item.Position.X == dynamicObject.Position.X && block.Item.Position.Y == dynamicObject.Position.Y) { itemType = block.Item.ItemState.ToString(); previousItemType = block.Item.PreviousItemState.ToString(); block.Item.PreviousItemState = new NoItem(); itemScoreValue = block.Item.ItemState.ScoreValue; break; } } foreach (Item coin in Level.Instance.Coins) { if (coin.Position.X == dynamicObject.Position.X && coin.Position.Y == dynamicObject.Position.Y) { itemType = coin.ItemState.ToString(); previousItemType = coin.PreviousItemState.ToString(); coin.PreviousItemState = new NoItem(); itemScoreValue = coin.ItemState.ScoreValue; } } if (itemType == "SuperMario.ItemStates.PowerUp" || previousItemType == "SuperMario.ItemStates.PowerUp") { if (!Level.Instance.PowerUpState) { new MarioCollidesWithMushroomCommand(playableObject).Execute(); } else { new MarioCollidesWithFireFlower(playableObject).Execute(); } SoundManager.Instance.GainPowerUp.Play(); HUD.Instance.ScoreHUDCounter += itemScoreValue; } else if (itemType == "SuperMario.ItemStates.Star" || previousItemType == "SuperMario.ItemStates.Star") { new MarioCollidesWithStarCommand(playableObject).Execute(); HUD.Instance.ScoreHUDCounter += itemScoreValue; } else if (itemType == "SuperMario.ItemStates.Mushroom1Up" || previousItemType == "SuperMario.ItemStates.Mushroom1Up") { SoundManager.Instance.GainOneUp.Play(); HUD.Instance.ScoreHUDCounter += itemScoreValue; playableObject.Lives++; } else if (itemType == "SuperMario.ItemStates.FloatingCoin" || previousItemType == "SuperMario.ItemStates.FloatingCoin") { SoundManager.Instance.Coin.Play(); HUD.Instance.CoinHUDCounter += 1; HUD.Instance.ScoreHUDCounter += itemScoreValue; } else if (itemType == "SuperMario.ItemStates.YoshiIdle" || previousItemType == "SuperMario.ItemStates.YoshiIdle") { playableObject.Position = new Vector2(dynamicObject.Position.X, dynamicObject.Position.Y - 10); new MarioCollidesWithYoshi(playableObject).Execute(); } } else if (dynamicObject.ToString() == "SuperMario.Enemy") { // Mario shouldn't react to a Dead Goomba. bool enemyIsDead = false; bool enemyIsStoppedShell = false; Enemy enemy = dynamicObject as Enemy; if (enemy.EnemyState.ToString() == "SuperMario.EnemyStates.DeadGoomba" || enemy.EnemyState.ToString() == "SuperMario.EnemyStates.NoEnemy") { enemyIsDead = true; } if (enemy.EnemyState.ToString() == "SuperMario.EnemyStates.HidingInsideShellKoopa" || enemy.EnemyState.ToString() == "SuperMario.EnemyStates.ComingOutOfShellKoopa") { if (!enemy.IsSlidingShell) { enemyIsStoppedShell = true; } } if (!enemyIsDead) { if (collisionDirection == GameValues.CollisionDirectionBottom || (playableObject.CollisionRectangle.Center.Y < dynamicObject.Position.Y - 1 && playableObject.PlayableObjectState.ToString().Substring(23, 5) == "Small")) { SoundManager.Instance.EnemyStomp.Play(); playableObject.Velocity = new Vector2(playableObject.Velocity.X, GameValues.MarioStateMachineMarioBounceYVelocity); } else if ((playableObject.IsYoshiTongueLeft && collisionDirection == GameValues.CollisionDirectionLeft) || (playableObject.IsYoshiTongueRight && collisionDirection == GameValues.CollisionDirectionRight)) { // Don't let Mario collide with enemy. } else if (collisionDirection != null) { // Need to animate Mario if he goes from small to dead. // Need to prevent Mario from getting hurt if this collision is a shell that is not already moving. if (!enemyIsStoppedShell) { new MarioCollidesWithEnemyCommand(playableObject).Execute(); } } } else { if (collisionDirection == GameValues.CollisionDirectionBottom) { SoundManager.Instance.EnemyStomp.Play(); playableObject.Velocity = new Vector2(playableObject.Velocity.X, GameValues.MarioStateMachineMarioBounceYVelocity); } } } else if (dynamicObject.ToString() == "SuperMario.Fireball") { Fireball fireballTemp = dynamicObject as Fireball; // If it is not an enemy fireball, then kill the enemy. if (fireballTemp.IsEnemyFireball) { new MarioCollidesWithEnemyCommand(playableObject).Execute(); } } }