public static void handleCollision(Mario mario, IItemObjects item, ICollision side) { ICommand command; if (!(side.returnCollisionSide().Equals(CollisionSide.None))) { handleMarioMovement(mario, item, side); command = chooseCorrectCommand(item, mario); command.Execute(); mario.ScoreEvent(item.ScoreData()); handleAchievements(item); } }
private static void executeCollisionCommand(Mario mario, IBlock block, Game1 game) { BlockType type = block.returnBlockType(); ICommand command; if (type.Equals(BlockType.QuestionCoin)) { command = new MarioQuestionCoinBlockCollisionCommand(block, game); command.Execute(); } else if (type.Equals(BlockType.QuestionSuperMushroomFireFlower) && mario.Small && !mario.Fire) { command = new QuestionSuperMushroomCommand(block, game); command.Execute(); } else if (type.Equals(BlockType.QuestionSuperMushroomFireFlower) && !mario.Small) { command = new QuestionFireFlowerCommand(block, game); command.Execute(); } else if (type.Equals(BlockType.QuestionIceFlower)) { command = new QuestionIceFlowerCommand(block, game); command.Execute(); } else if (type.Equals(BlockType.QuestionStar)) { command = new QuestionStarCommand(block, game); command.Execute(); } else if (type.Equals(BlockType.Hidden)) { command = new MarioHiddenBlockCollisionCommand(block, game); command.Execute(); } else if (type.Equals(BlockType.BrickCoin)) { command = new BrickBlockDispenserCommand(mario, block, game); command.Execute(); } else if (type.Equals(BlockType.Brick) && ((!mario.Small) || (mario.Star))) { command = new BigMarioBrickBlockCollisionCommand(mario, block, game); command.Execute(); } }
private static void handleAchievements(IBlock block, Mario mario) { BlockType type = block.returnBlockType(); if (type.Equals(BlockType.BrickCoin)) { AchievementEventTracker.hiddenDispenserAcievement(); } else if (type.Equals(BlockType.Brick) && ((!mario.Small) || (mario.Star))) { AchievementEventTracker.brickSmashedAcievement(); } else if (type.Equals(BlockType.QuestionCoin)) { AchievementEventTracker.questionCoinAcievement(); } }
public void questionBlockTestLeft() { bool passed = true; BlockSpriteTextureStorage.Load(game.Content); MarioSpriteFactory.Load(game.Content); IPlayer mario = new Mario(390, 400); IBlock question = new Blocks(400, 400, BlockType.Question); CollisionDetector collisionDetector = new CollisionDetector(); ICollision side = collisionDetector.getCollision(mario.returnCollisionRectangle(), question.returnCollisionRectangle()); if (passed && side.returnCollisionSide().Equals(CollisionSide.Left)) { Console.WriteLine("QuestionBlockTestLeft Passed"); } else { Console.WriteLine("QuestionBlockTestLeft failed"); } }
public void PipeTestRight() { bool passed = true; MiscGameObjectTextureStorage.Load(game.Content); MarioSpriteFactory.Load(game.Content); IPlayer mario = new Mario(410, 400); IEnviromental pipe = new Pipe(400, 400); CollisionDetector collisionDetector = new CollisionDetector(); ICollision side = collisionDetector.getCollision(mario.returnCollisionRectangle(), pipe.returnCollisionRectangle()); if (passed && side.returnCollisionSide().Equals(CollisionSide.Right)) { Console.WriteLine("PipeRight Test Passed"); } else { Console.WriteLine("PipeRight failed"); } }
public void HiddenBlockTestTop() { bool passed = true; BlockSpriteTextureStorage.Load(game.Content); MarioSpriteFactory.Load(game.Content); IPlayer mario = new Mario(400, 400); IBlock hidden = new Blocks(400, 415, BlockType.Hidden); CollisionDetector collisionDetector = new CollisionDetector(); ICollision side = collisionDetector.getCollision(mario.returnCollisionRectangle(), hidden.returnCollisionRectangle()); if (passed && side.returnCollisionSide().Equals(CollisionSide.Top)) { Console.WriteLine("HiddenBlockTop Test Passed"); } else { Console.WriteLine("HiddenBlockTop failed"); } }
public void GroundBlockTestRight() { bool passed = true; BlockSpriteTextureStorage.Load(game.Content); MarioSpriteFactory.Load(game.Content); IPlayer mario = new Mario(410, 400); IBlock ground = new Blocks(400, 400, BlockType.Ground); CollisionDetector collisionDetector = new CollisionDetector(); ICollision side = collisionDetector.getCollision(mario.returnCollisionRectangle(), ground.returnCollisionRectangle()); if (passed && side.returnCollisionSide().Equals(CollisionSide.Right)) { Console.WriteLine("GroundBlockRight Test Passed"); } else { Console.WriteLine("GroundBlockRight failed"); } }
public void PlatformingBlockTestBottom() { bool passed = true; BlockSpriteTextureStorage.Load(game.Content); MarioSpriteFactory.Load(game.Content); IPlayer mario = new Mario(400, 400); IBlock platform = new Blocks(400, 385, BlockType.Platforming); CollisionDetector collisionDetector = new CollisionDetector(); ICollision side = collisionDetector.getCollision(mario.returnCollisionRectangle(), platform.returnCollisionRectangle()); if (passed && side.returnCollisionSide().Equals(CollisionSide.Bottom)) { Console.WriteLine("PlatformBlockBottom Test Passed"); } else { Console.WriteLine("PlatformBlockBottom failed"); } }
public MarioDuck(Mario mario) { this.mario = mario; if (mario.Fire) { sprite = new AnimatedSprite(MarioSpriteFactory.CreateMarioFireDuckSprite(), UtilityClass.one, UtilityClass.one, mario.Location, UtilityClass.generalTotalFramesAndSpecializedRows); } else if (mario.Ice) { sprite = new AnimatedSprite(MarioSpriteFactory.CreateMarioIceDuckSprite(), UtilityClass.one, UtilityClass.one, mario.Location, UtilityClass.generalTotalFramesAndSpecializedRows); } else if (mario.Small) { sprite = new AnimatedSprite(MarioSpriteFactory.CreateMarioSmallStillSprite(), UtilityClass.one, UtilityClass.one, mario.Location, UtilityClass.generalTotalFramesAndSpecializedRows); } else { sprite = new AnimatedSprite(MarioSpriteFactory.CreateMarioDuckSprite(), UtilityClass.one, UtilityClass.one, mario.Location, UtilityClass.generalTotalFramesAndSpecializedRows); } }
public EndingSequenceMario(Mario mario, bool smallMario, bool fireMario, bool iceMario, TimeStat time) { this.location = mario.Location; endActions = mario.actions; endStats = mario.stats; timeStats = time; timeStats.SaveTime(); this.smallMario = smallMario; endSequenceFinished = false; atFlagpoleBottom = false; flagAtBottom = false; offBlock = false; flagpoleAnimation = true; fallOffBlockAnimation = false; walkingToCastle = false; slideSpeed = UtilityClass.slideSpeed; walkSpeed = UtilityClass.endMarioWalkSpeed; decayRate = UtilityClass.endMarioDecayRate; waitToLeaveFlagpole = UtilityClass.waitToLeaveFlagpole; endMarioSprite = new EndingSequenceMarioSprite(location, smallMario, fireMario, iceMario); }
public static void handleCollision(Mario mario, IBlock block, ICollision side, Game1 game) { if (!(side.returnCollisionSide().Equals(CollisionSide.None)) && !(block.returnBlockType().Equals(BlockType.Hidden))) { handleMarioMovement(mario, block, side); } else if (block.returnBlockType().Equals(BlockType.Hidden)) { if (!(side.returnCollisionSide().Equals(CollisionSide.None)) && (block.checkForSpecalizedSideCollision())) { handleMarioMovement(mario, block, side); } } if (side.returnCollisionSide().Equals(CollisionSide.Bottom)) { SoundEffectFactory.Bump(); executeCollisionCommand(mario, block, game); handleAchievements(block, mario); } }
private static void handleMarioMovement(Mario mario, IBlock block, ICollision side) { Rectangle blockRectangle = block.returnCollisionRectangle(); Rectangle marioRectangle = mario.returnCollisionRectangle(); Rectangle intersectionRectangle = Rectangle.Intersect(marioRectangle, blockRectangle); int locationDiffToChange = UtilityClass.zero; if (side.returnCollisionSide().Equals(CollisionSide.Left)) { locationDiffToChange = intersectionRectangle.Width; int newMarioX = (int)mario.Location.X - locationDiffToChange; mario.Location = new Vector2(newMarioX, mario.Location.Y); mario.rigidbody.HorizontalCollision(); } else if (side.returnCollisionSide().Equals(CollisionSide.Right)) { locationDiffToChange = intersectionRectangle.Width; int newMarioX = (int)mario.Location.X + locationDiffToChange; mario.Location = new Vector2(newMarioX, mario.Location.Y); mario.rigidbody.HorizontalCollision(); } else if (side.returnCollisionSide().Equals(CollisionSide.Top)) { locationDiffToChange = intersectionRectangle.Height; int newMarioY = (int)mario.Location.Y - locationDiffToChange; mario.Location = new Vector2(mario.Location.X, newMarioY); mario.rigidbody.BottomCollision(); } else if (side.returnCollisionSide().Equals(CollisionSide.Bottom)) { locationDiffToChange = intersectionRectangle.Height; int newMarioY = (int)mario.Location.Y + locationDiffToChange; mario.Location = new Vector2(mario.Location.X, newMarioY); mario.rigidbody.TopCollision(); } }
public LevelStorage LoadLevel() { LevelStorage storage = new LevelStorage(camera); using (var levelfile = TitleContainer.OpenStream(@"Content\" + LevelName)) { using (var sr = new StreamReader(levelfile)) { var ObjectType = sr.ReadLine(); ObjectType.Trim(); while (ObjectType != "<!-- END -->") { if (ObjectType == "<BrickBlock>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IBlock GameObject; GameObject = new BrickBlock(XVal, YVal, BlockType.Brick); storage.blocksList.Add(GameObject); BreakableBlockStats.TotalAvailable++; ObjectType = sr.ReadLine(); ObjectType.Trim(); } else if (ObjectType == "<BoxCoin>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IItemObjects GameObject; GameObject = new BoxCoin(XVal, YVal); storage.itemList.Add(GameObject); CoinStats.TotalAvailable++; ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<FireFlower>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IItemObjects GameObject; GameObject = new FireFlower(XVal, YVal); storage.itemList.Add(GameObject); FireFlowerStats.TotalAvailable++; ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<IceFlower>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IItemObjects GameObject; GameObject = new IceFlower(XVal, YVal); storage.itemList.Add(GameObject); //FireFlowerStats.TotalAvailable++; ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<Goomba>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IEnemyObject GameObject; GameObject = new Goomba(XVal, YVal); storage.enemiesList.Add(GameObject); GoombaStats.TotalAvailable++; ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<GroundBlock>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IBlock GameObject; GameObject = new Blocks(XVal, YVal, BlockType.Ground); storage.blocksList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<HiddenBlock>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IBlock GameObject; GameObject = new HiddenBlock(XVal, YVal, BlockType.Hidden); storage.blocksList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<CoinDispenserBlock>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IBlock GameObject; GameObject = new BrickBlockCoinDispenser(XVal, YVal, BlockType.BrickCoin); storage.blocksList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<Koopa>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IEnemyObject GameObject; GameObject = new Koopa(XVal, YVal); storage.enemiesList.Add(GameObject); KoopaStats.TotalAvailable++; ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<OneUpMushroom>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IItemObjects GameObject; GameObject = new OneUpMushroom(XVal, YVal); storage.itemList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<Pipe>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IEnviromental GameObject; GameObject = new Pipe(XVal, YVal); storage.enviromentalObjectsList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<PlatformingBlock>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IBlock GameObject; GameObject = new Blocks(XVal, YVal, BlockType.Platforming); storage.blocksList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<QuestionStarBlock>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IBlock GameObject; GameObject = new QuestionStarBlock(XVal, YVal, BlockType.QuestionStar); storage.blocksList.Add(GameObject); SuperStarStats.TotalAvailable++; ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<QuestionCoinBlock>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IBlock GameObject; GameObject = new QuestionCoinBlock(XVal, YVal, BlockType.QuestionCoin); storage.blocksList.Add(GameObject); CoinStats.TotalAvailable++; ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<QuestionSuperMushroomFireFlowerBlock>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IBlock GameObject; GameObject = new QuestionSuperMushroomFireFlower(XVal, YVal, BlockType.QuestionSuperMushroomFireFlower); storage.blocksList.Add(GameObject); FireFlowerStats.TotalAvailable++; ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<QuestionIceFlowerBlock>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IBlock GameObject; GameObject = new QuestionIceFlower(XVal, YVal, BlockType.QuestionIceFlower); storage.blocksList.Add(GameObject); //FireFlowerStats.TotalAvailable++; ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<SuperMushroom>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IItemObjects GameObject; GameObject = new SuperMushroom(XVal, YVal); storage.itemList.Add(GameObject); SuperMushroomStats.TotalAvailable++; ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<SuperStar>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IItemObjects GameObject; GameObject = new SuperStar(XVal, YVal); storage.itemList.Add(GameObject); SuperStarStats.TotalAvailable++; ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<Mario>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IPlayer GameObject; GameObject = new Mario(XVal, YVal); storage.player = GameObject; ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<BlueBrickBlock>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IBlock GameObject; GameObject = new BlueBrickBlock(XVal, YVal, BlockType.BlueBrick); storage.blocksList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<BlueGroundBlock>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IBlock GameObject; GameObject = new BlueGroundBlock(XVal, YVal, BlockType.BlueGround); storage.blocksList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<UndergroundPipe>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IEnviromental GameObject = new Pipe(XVal, YVal); ((Pipe)GameObject).setUnderground(); storage.enviromentalObjectsList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<RightFacingPipeEdge>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IEnviromental GameObject = new RightFacingPipeEdge(XVal, YVal); storage.enviromentalObjectsList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<RightFacingPipe>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IEnviromental GameObject = new RightFacingPipe(XVal, YVal); storage.enviromentalObjectsList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<StaticCoin>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IItemObjects GameObject = new StaticCoin(XVal, YVal); storage.itemList.Add(GameObject); CoinStats.TotalAvailable++; ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<GoombaEnemySpawner>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IEnviromental GameObject = new EnemySpawner(XVal, YVal, true); storage.enviromentalObjectsList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<KoopaEnemySpawner>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IEnviromental GameObject = new EnemySpawner(XVal, YVal, false); storage.enviromentalObjectsList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<SkyBridge>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IEnviromental GameObject = new SkyWorldBridge(XVal, YVal); storage.enviromentalObjectsList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<IcePipe>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IEnviromental GameObject = new IcePipe(XVal, YVal); storage.enviromentalObjectsList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<IceCloud>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IEnviromental GameObject = new StandingCloud(XVal, YVal); storage.enviromentalObjectsList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<SmileyCloud>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); IEnviromental GameObject = new IceSmileyCloud(XVal, YVal); storage.enviromentalObjectsList.Add(GameObject); ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else if (ObjectType == "<VineCoinBox>") { var xstring = sr.ReadLine(); string[] xstringSeparators = new string[] { " ", "<x>", "</x>", "\n" }; string xtrimmed = xstring.Trim(); var xsplit = xtrimmed.Split(xstringSeparators, StringSplitOptions.None); int XVal = Int32.Parse(xsplit[1]); var ystring = sr.ReadLine(); string[] ystringSeparators = new string[] { " ", "<y>", "</y>", "\n" }; string ytrimmed = ystring.Trim(); var ysplit = ytrimmed.Split(ystringSeparators, StringSplitOptions.None); int YVal = Int32.Parse(ysplit[1]); QuestionCoinBlock GameObject; GameObject = new QuestionCoinBlock(XVal, YVal, BlockType.QuestionCoin); GameObject.setVineBox(true); storage.blocksList.Add(GameObject); CoinStats.TotalAvailable++; ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } else { ObjectType = sr.ReadLine(); ObjectType = ObjectType.Trim(); } } } } return(storage); }
public MarioShootIceball(Mario mario) { this.mario = mario; mario.actions.ShotFired(); sprite = new AnimatedSprite(MarioSpriteFactory.CreateMarioIceStillShootSprite(), UtilityClass.one, UtilityClass.one, mario.Location, UtilityClass.generalTotalFramesAndSpecializedRows); }
public EnemyHitsMarioCollision(Mario mario, IEnemyObject enemy) { this.mario = mario; this.enemy = enemy; }
public void Update(Mario mario, float elapsedtime, Game1 game) { if (vine_box_hit) { if (vinegrowthtime > 1.5) { SoundEffectFactory.OneUp(); IEnviromental GameObject = new SmallVine(355, 230); game.levelStore.enviromentalObjectsList.Add(GameObject); vinegrowthtime = vinegrowthtime - elapsedtime; } else if (vinegrowthtime > 1) { IEnviromental GameObject = new MediumVine(355, 140); game.levelStore.enviromentalObjectsList.Add(GameObject); vinegrowthtime = vinegrowthtime - elapsedtime; } else if (vinegrowthtime > .5) { IEnviromental GameObject = new LargeVine(355, 50); game.levelStore.enviromentalObjectsList.Add(GameObject); vinegrowthtime = vinegrowthtime - elapsedtime; } else if (vinegrowthtime > 0) { IEnviromental GameObject = new FullVine(355, -40); game.levelStore.enviromentalObjectsList.Add(GameObject); vinegrowthtime = vinegrowthtime - elapsedtime; } else { vine_box_hit = false; vine_has_popped = true; } } if (vine_has_popped) { if (IsWithinSendSkyWorldBoundary(((Mario)mario).Location)) { if (((Mario)mario).StateStatus().Equals(MarioState.Jump) || hasbeguntransition == true) { if (hasbeguntransition == false) { SoundEffectFactory.Pipe(); } hasbeguntransition = true; SendToSkyWorld(mario, game); } } } if (IsWithinExitSkyWorldBoundary(((Mario)mario).Location)) { if (((Mario)mario).StateStatus().Equals(MarioState.Duck) || hasbeguntransition == true) { if (hasbeguntransition == false) { SoundEffectFactory.Pipe(); } hasbeguntransition = true; SendFromSkyWorld(mario, elapsedtime, game); } } }