Esempio n. 1
0
        public void FireMarioGreenMushroomTopSideCollisionTest()
        {
            MarioInstance testMario     = new MarioInstance(game);
            MarioInstance expectedMario = new MarioInstance(game);

            testMario.Flower();
            expectedMario.Flower();

            GreenMushroom testGreenMushroom     = new GreenMushroom(game);
            GreenMushroom expectedGreenMushroom = new GreenMushroom(game);

            expectedGreenMushroom.Disappear();

            ICollisionSide            side             = new TopSideCollision();
            CollisionData             collision        = new CollisionData(testMario, testGreenMushroom, side);
            MarioItemCollisionHandler collisionHandler = new MarioItemCollisionHandler(collision);

            collisionHandler.HandleCollision();

            bool    testState        = testMario.MarioState is FireRightIdleState;
            bool    expectedState    = expectedMario.MarioState is FireRightIdleState;
            Vector2 testLocation     = testMario.VectorCoordinates;
            Vector2 expectedLocation = expectedMario.VectorCoordinates;

            Assert.AreEqual(testState, expectedState);
            Assert.AreEqual(testLocation, expectedLocation);
        }
Esempio n. 2
0
        public void MarioMushroomTest()
        {
            //Make Mario, Mushroom, and Movement Command
            IMario mario    = new Mario(new Vector2(250, 500));
            IItem  mushroom = new GreenMushroom(new Vector2(500, 500));

            level       = new Level(game);
            level.Mario = mario;
            ICommand moveRight = new RightCommand(level);

            //Move Mario Right until he has collided with the Mushroom
            Rectangle marioPosition = mario.DrawnRectangle;

            while (marioPosition.X < 510)
            {
                moveRight.Execute();
                level.Update();
                marioPosition = mario.DrawnRectangle;
            }

            //Check test results, Mario should be big
            if (!mario.IsBig())
            {
                writer.WriteLine("Mario Mushroom Test: Unsuccessful\n");
            }

            else
            {
                writer.WriteLine("Mario Mushroom Test: Successful\n");
            }
        }
Esempio n. 3
0
        private IItem InitiateBonus(Bonus caseNumber)
        {
            IItem item;

            switch (caseNumber)
            {
            case Bonus.Gold:
                item = new Gold(new Vector2(Location.X + Util.Instance.Gold_positionFix_x, Location.Y - Util.Instance.Bonus_positionFix_y), false);
                break;

            case Bonus.Star:
                item = new Star(new Vector2(Location.X, Location.Y - Util.Instance.Bonus_positionFix_y));
                break;

            case Bonus.Flower:
                item = new Flower(new Vector2(Location.X, Location.Y - Util.Instance.Bonus_positionFix_y));
                break;

            case Bonus.GreenShroom:
                item = new GreenMushroom(new Vector2(Location.X, Location.Y - Util.Instance.Bonus_positionFix_y));
                break;

            default:
                item = new RedMushroom(new Vector2(Location.X, Location.Y - Util.Instance.Bonus_positionFix_y));
                break;
            }
            return(item);
        }
Esempio n. 4
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            GreenMushroom g = (GreenMushroom)gameObject1;

            g.Location = new Vector2(g.Destination.X, gameObject2.Destination.Y - g.Destination.Height);
            g.Velocity = new Vector2(g.Velocity.X, GameUtilities.StationaryVelocity);
        }
Esempio n. 5
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            GreenMushroom g = (GreenMushroom)gameObject1;

            if (gameObject2.GetType() == typeof(HiddenBlock) && g.Velocity.Y >= GameUtilities.StationaryVelocity)
            {
                return;
            }
        }
Esempio n. 6
0
 public GreenMushroomEntity(Vector2 loc, EventSoundEffects sounds) : base(loc, sounds)
 {
     Sounds          = sounds;
     Sound           = EventSoundEffects.EventSounds.Collect1Up;
     InitialPos      = loc;
     Sprite          = new GreenMushroom(loc);
     EntityCollision = new ItemCollision(this);
     State           = new StandardItemState(this);
     State.NextState = new MovingItemState(this);
 }
Esempio n. 7
0
        public void Trigger()
        {
            if (Used)
            {
                return;
            }
            GreenMushroom newObject = new GreenMushroom(new Vector2(Location.X, Location.Y - 2));

            GameUtilities.GameObjectManager.AddItem(newObject);
            SoundManager.Instance.PlayPowerUpAppearsSound();
            stateMachine.BeTriggered();
        }
Esempio n. 8
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            GreenMushroom greenMushroom     = (GreenMushroom)gameObject1;
            int           greenMushroomPreY = (int)(greenMushroom.Destination.Y - (greenMushroom.Velocity.Y - GameUtilities.SinglePixel));

            if (greenMushroomPreY + greenMushroom.Destination.Height <= gameObject2.Destination.Y)
            {
                return;
            }

            else if (greenMushroomPreY > gameObject2.Destination.Y + gameObject2.Destination.Height)
            {
                return;
            }
            greenMushroom.ChangeDirection();
        }
Esempio n. 9
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            if (gameObject2.GetType() == typeof(HiddenBlock))
            {
                HiddenBlock hiddenBlock = (HiddenBlock)gameObject2;
                if (!hiddenBlock.Used)
                {
                    return;
                }
            }

            GreenMushroom greenMushroom = (GreenMushroom)gameObject1;

            if (greenMushroom.IsPreparing)
            {
                return;
            }
            greenMushroom.Location = new Vector2(greenMushroom.Location.X, gameObject2.Location.Y - greenMushroom.Destination.Height);
            greenMushroom.Velocity = new Vector2(greenMushroom.Velocity.X, GameUtilities.StationaryVelocity);
        }
 private static void HandleGreenMushroomCollision(IPlayer player, GreenMushroom greenMushroom)
 {
     player.UseGreenMushroom();
     greenMushroom.BeCollected();
 }
        public static void InfiniteLevelLoad(Game myGame)
        {
            enemyList = new List <IEnemy>();
            itemList  = new List <IItem>();
            blockList = new List <IBlock>();
            bgList    = new List <IBg>();

            String[] levelFile = new String[two] {
                "InfiniteLevel-1.txt", "InfiniteLevel-2.txt"
            };
            int file = 0;

            StreamReader File = new StreamReader(Path.Combine(Directory.GetCurrentDirectory(),
                                                              "Content", "Levels", levelFile[file]));

            String inComingLine;
            int    posRow = zero;

            while (!File.EndOfStream)
            {
                inComingLine = File.ReadLine();
                String[] target = inComingLine.Split(',');
                int      posCol = zero;
                while (posCol < target.Length)
                {
                    if (target[posCol].Equals("brick"))
                    {
                        IBlock block = new Brick(myGame, posCol, posRow);
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("crack"))
                    {
                        IBlock block = new Crack(myGame, posCol, posRow);
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("diamond"))
                    {
                        IBlock block = new Diamond(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize);
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("question"))
                    {
                        IBlock block = new Question(myGame, posCol, posRow);
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("questionRedM"))
                    {
                        Question block = new Question(myGame, posCol, posRow);
                        block.contain = Utility.items.redM;
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("questionFireF"))
                    {
                        Question block = new Question(myGame, posCol, posRow);
                        block.contain = Utility.items.flower;
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("questionCoin"))
                    {
                        Question block = new Question(myGame, posCol, posRow);
                        block.contain = Utility.items.coin;
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("questionGreenM"))
                    {
                        Question block = new Question(myGame, posCol, posRow);
                        block.contain = Utility.items.greenM;
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("questionBat"))
                    {
                        Question block = new Question(myGame, posCol, posRow);
                        block.contain = Utility.items.bat;
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("used"))
                    {
                        IBlock block = new Used(myGame, posCol, posRow);
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("invisible"))
                    {
                        IBlock block = new Invisible(myGame, posCol, posRow);
                        blockList.Add(block);
                    }
                    else if (target[posCol].Equals("standardPipe"))
                    {
                        Pipe block = new Pipe(myGame, posCol, posRow);
                        blockList.Add(block);

                        IEnemy enemy = new PiranhaPlant(myGame, block.drawLoc.X, block.drawLoc.Y);
                        enemyList.Add(enemy);
                    }

                    else if (target[posCol].Equals("pipeNeck"))
                    {
                        IBlock block = new PipeNeck(myGame, posCol, posRow);
                        blockList.Add(block);
                    }

                    else if (target[posCol].Equals("coin"))
                    {
                        IItem item = new Coin(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize);
                        itemList.Add(item);
                    }
                    else if (target[posCol].Equals("star"))
                    {
                        IItem item = new Star(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize);
                        itemList.Add(item);
                    }
                    else if (target[posCol].Equals("flower"))
                    {
                        IItem item = new FireFlower(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize);
                        itemList.Add(item);
                    }
                    else if (target[posCol].Equals("redMushroom"))
                    {
                        IItem item = new RedMushroom(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize);
                        itemList.Add(item);
                    }
                    else if (target[posCol].Equals("greenMushroom"))
                    {
                        IItem item = new GreenMushroom(myGame, posCol * stdSpriteSize, posRow * stdSpriteSize);
                        itemList.Add(item);
                    }


                    else if (target[posCol].Equals("goomba"))
                    {
                        IEnemy enemy = new Goomba(myGame, posCol, posRow);
                        enemyList.Add(enemy);
                    }
                    else if (target[posCol].Equals("koopa"))
                    {
                        IEnemy enemy = new Koopa(myGame, posCol, posRow);
                        enemyList.Add(enemy);
                    }


                    else if (target[posCol].Equals("oneCloud"))
                    {
                        IBg bg = new Bg(myGame, myGame.oneCloudBgElement, posCol, posRow);
                        bgList.Add(bg);
                    }
                    else if (target[posCol].Equals("threeClouds"))
                    {
                        IBg bg = new Bg(myGame, myGame.threeCloudsBgElement, posCol, posRow);
                        bgList.Add(bg);
                    }
                    else if (target[posCol].Equals("oneBush"))
                    {
                        IBg bg = new Bg(myGame, myGame.oneBushBgElement, posCol, posRow);
                        bgList.Add(bg);
                    }
                    else if (target[posCol].Equals("threeBushes"))
                    {
                        IBg bg = new Bg(myGame, myGame.threeBushesBgElement, posCol, posRow);
                        bgList.Add(bg);
                    }
                    else if (target[posCol].Equals("smallMountain"))
                    {
                        IBg bg = new Bg(myGame, myGame.smallMountainBgElement, posCol, posRow);
                        bgList.Add(bg);
                    }
                    else if (target[posCol].Equals("bigMountain"))
                    {
                        IBg bg = new Bg(myGame, myGame.bigMountainBgElement, posCol, posRow);
                        bgList.Add(bg);
                    }
                    posCol++;
                }
                posRow++;
            }
            File.Close();
            if (file < two)
            {
                File = new StreamReader(Path.Combine(Directory.GetCurrentDirectory(),
                                                     "Content", "Levels", levelFile[file]));
                file++;
            }
            else
            {
                file = zero;
            }

            IComparer <IBlock> blockComp = new BlockComparer <IBlock>();
            IComparer <IItem>  itemComp  = new ItemComparer <IItem>();
            IComparer <IEnemy> enemyComp = new EnemyComparer <IEnemy>();

            blockList.Sort(blockComp);
            itemList.Sort(itemComp);
            enemyList.Sort(enemyComp);
        }