コード例 #1
0
        public void TestCollisionResponse_Megaman_Block_FromLeft(Megaman megaMan, Block block)
        {
            megaMan = new Megaman(new Vector2(50, 240), megamanGame.Content);
            block = new Block(new Vector2(100, 240), BlockState.Question, megaMan, megamanGame.Content);

            megaMan.RightCommand();
            megaMan.ActionState.UpdatePosition(new Vector2(105, 240), gameTime);
        }
コード例 #2
0
        public void TestMethod1()
        {
            Megaman mm = new Megaman(mmGame.Content);
            Block block = new Block(new Vector2(0, 0), BlockState.Pyramid, mm, mmGame.Content);

            block.Collide(mm);

            BlockState state = BlockState.Colliding;
            Assert.AreEqual(state, block.CurrentState);
        }
コード例 #3
0
        public HiddenItem(Rectangle AABB, Block block, Rectangle frame, int millisecondsPerFrame, Texture2D texture, SoundEffect sound)
            : base(AABB, frame, millisecondsPerFrame, Vector2.Zero, texture)
        {
            this.block = block;
            this.sound = sound;

            active = false;

            maxVelocity = new Vector2(100, 150);
            minVelocity = new Vector2(-100, -150);
        }
コード例 #4
0
        public HiddenItem GetHiddenItem(String itemType, Block block)
        {
            if (itemType == "etank")
            {
                return new HiddenETank(content, block);

            } else if (itemType == "falconpowerup")
            {
                return new HiddenFalconPowerup(content, block);

            } else if (itemType == "lifetank")
            {
                return new HiddenLifeTank(content, block);

            } else if (itemType == "megamanhelmet")
            {
                return new HiddenMegamanHelmet(content, block);

            } else // itemType == "zerohelmet"
            {
                return new HiddenZeroHelmet(content, block);
            }
        }
コード例 #5
0
 public HiddenETank(ContentManager content, Block block)
     : base(new Rectangle(0, 0, 32, 32), block, new Rectangle(0, 0, 32, 32), 150,
     content.Load<Texture2D>("Items/MM_etank"), content.Load<SoundEffect>("Sounds/mm1/MM1-GetPoints"))
 {
 }
コード例 #6
0
 public HiddenMegamanHelmet(ContentManager content, Block block)
     : base(new Rectangle(0, 0, 32, 32), block, new Rectangle(0, 0, 32, 32), 400,
     content.Load<Texture2D>("Items/megaman_helmet"), content.Load<SoundEffect>("Sounds/mm7/GetLife"))
 {
 }
コード例 #7
0
        Stage getStageFromNode(XmlNode stageNode)
        {
            Vector2 boundary = parseAndScaleOrderedPairToVector2(stageNode.Attributes["boundary"].InnerText);
            Stage stage = new Stage(game, boundary,
                stageNode.Attributes["background"].InnerText,
                stageNode.Attributes["music"].InnerText,
                stageNode.Attributes["id"].InnerText);
            ControllerFactory controllerFactory = new ControllerFactory(stage, game, megaman);

            addBoundary(stage, boundary);

            foreach (XmlNode configItemNode in stageNode.ChildNodes)
            {
                if (configItemNode.Name == "block")
                {
                    Block block = getBlockFromNode(configItemNode, stage); // there's got to be a better way then passing the stage...
                    stage.AddSprite(block);
                    stage.AddCollidable(block);

                } else if (configItemNode.Name == "platform")
                {
                    Point platformDimensions = parseAndScaleOrderedPairToPoint(configItemNode.Attributes["size"].InnerText);
                    Vector2 platformLocation = parseAndScaleOrderedPairToVector2(configItemNode.Attributes["location"].InnerText);
                    BlockState platformType = BlockStateHelper.GetState(configItemNode.Attributes["blockType"].InnerText);

                    platformDimensions.X += (int)platformLocation.X;
                    platformDimensions.Y += (int)platformLocation.Y;

                    for (int i = (int)platformLocation.X; i < platformDimensions.X; i += 32)
                    {
                        for (int j = (int)platformLocation.Y; j < platformDimensions.Y; j += 32)
                        {
                            Block block = new Block(new Vector2(i, j), platformType, megaman, content);
                            stage.AddSprite(block);
                            stage.AddCollidable(block);
                        }
                    }

                } else if (configItemNode.Name == "item")
                {
                    Sprite item = getItemFromNode(configItemNode);
                    stage.AddSprite(item);
                    stage.AddCollidable(item);

                } else if (configItemNode.Name == "enemy")
                {
                    Sprite enemy = getEnemyFromNode(configItemNode);
                    stage.AddSprite(enemy);
                    stage.AddCollidable(enemy);

                } else if(configItemNode.Name == "megaman")
                {
                    stage.MegamanInitialPosition = parseAndScaleOrderedPairToVector2(configItemNode.Attributes["location"].InnerText);

                } else if (configItemNode.Name == "parallax")
                {
                    stage.AddSprite(getParallaxSpriteFromNode(configItemNode, stage));
                }
            }

            stage.Checkpoint = parseAndScaleOrderedPairToVector2(stageNode.Attributes["checkpoint"].InnerText);

            stage.AddSprite(new HUD(game.Content, game.Megaman, stage));
            stage.AddController(controllerFactory.GetGamePadController());
            stage.AddController(controllerFactory.GetKeyboardController());

            return stage;
        }
コード例 #8
0
        Block getBlockFromNode(XmlNode blockNode, Stage stage)
        {
            Vector2 location = parseAndScaleOrderedPairToVector2(blockNode.Attributes["location"].InnerText);
            Block block = new Block(location, BlockStateHelper.GetState(blockNode.Attributes["blockType"].InnerText), megaman, content);

            foreach (XmlNode itemNode in blockNode.ChildNodes)
            {
                try
                {
                    HiddenItem item = itemSpriteFactory.GetHiddenItem(itemNode.Attributes["itemType"].InnerText, block);
                    stage.AddSprite(item);
                    stage.AddCollidable(item);
                    block.AddItem(item);
                } catch (Exception)
                {
                    //Comment?
                }
            }

            return block;
        }
コード例 #9
0
        void addBoundary(Stage stage, Vector2 boundary)
        {
            for (int i = 0; i < boundary.X; i += 32)
            {
                Block topBlock = new Block(new Vector2(i, -31), BlockState.Pyramid, megaman, content);
                Block bottomBlock = new Block(new Vector2(i, boundary.Y), BlockState.Pyramid, megaman, content);

                stage.AddCollidable(topBlock);
                stage.AddCollidable(bottomBlock);
                stage.AddSprite(topBlock);
                stage.AddSprite(bottomBlock);
            }

            for (int i = 0; i < boundary.Y; i += 32)
            {
                Block leftBlock = new Block(new Vector2(-31, i), BlockState.Pyramid, megaman, content);
                Block rightBlock = new Block(new Vector2(boundary.X, i), BlockState.Pyramid, megaman, content);

                stage.AddCollidable(leftBlock);
                stage.AddCollidable(rightBlock);
                stage.AddSprite(leftBlock);
                stage.AddSprite(rightBlock);
            }
        }
コード例 #10
0
 public HiddenLifeTank(ContentManager content, Block block)
     : base(new Rectangle(0, 0, 32, 32), block, new Rectangle(0, 0, 32, 32), 100,
     content.Load<Texture2D>("Items/life_tank"), content.Load<SoundEffect>("Sounds/mm7/GetEnergy"))
 {
 }
コード例 #11
0
 public HiddenFalconPowerup(ContentManager content, Block block)
     : base(new Rectangle(0, 0, 32, 32), block, new Rectangle(0, 0, 32, 32), 175,
     content.Load<Texture2D>("Items/falcon_powerup"), content.Load<SoundEffect>("Sounds/mm3/ProtoWhistle"))
 {
 }
コード例 #12
0
 public HiddenZeroHelmet(ContentManager content, Block block)
     : base(new Rectangle(0, 0, 32, 32), block, new Rectangle(0, 0, 32, 32), 210,
     content.Load<Texture2D>("Items/Zero_Helmet"), content.Load<SoundEffect>("Sounds/mm7/GetSpecial"))
 {
 }
コード例 #13
0
 public void TestInitialize(Megaman megaMan, Block block)
 {
     this.megaMan = megaMan;
     this.block = block;
 }