Ejemplo n.º 1
0
        public override void Load()
        {
            Title          = new StaticText(Content, "gameover");
            Title.Position = new Vector2(150f, 75f);

            Scene.AudioHandler.PlayBGM("Audio/game_over", false);

            menu          = new Menu(Font);
            menu.Position = new Vector2(175f, 150f);
            menu.AddOption(new ResetCommand(scene), "Restart");
            menu.AddOption(new QuitCommand(scene), "Quit");

            Controllers = ControllerSetup.LoadMenuControllers(menu, scene);
        }
Ejemplo n.º 2
0
        public override void Load()
        {
            Title          = new StaticText(Content, "SMW_title");
            Title.Position = new Vector2(112.5f, 10f);

            Scene.AudioHandler.PlayBGM("Audio/title_bgm", true);

            menu          = new Menu(Font);
            menu.Position = new Vector2(200f, 150f);
            menu.AddOption(new StartSingleCommand(scene), "1 Player");
            menu.AddOption(new StartMultiCommand(scene), "2 Player");

            Controllers = ControllerSetup.LoadMenuControllers(menu, scene);
        }
Ejemplo n.º 3
0
        public override void Load()
        {
            Scene.AudioHandler.PlayBGM("Audio/bgm", true);

            Vector2 startPos = new Vector2();

            Entities = MapSetup.LoadEntities(level, ref startPos, Content, scene);

            if (Scene.Checkpoint.X > startPos.X)
            {
                startPos = Scene.Checkpoint;
            }
            Scene.mario = new MarioEntity(new MarioFactory(Content), startPos);
            Scene.luigi = new LuigiEntity(new LuigiFactory(Content), new Vector2(startPos.X - 20, startPos.Y));

            if (scene.Single)
            {
                Controllers = ControllerSetup.LoadLevelControllers1P(Scene.mario, scene);
            }
            else
            {
                Controllers = ControllerSetup.LoadLevelControllers2P(Scene.mario, Scene.luigi, scene);
            }

            Entities.Add(Scene.mario);
            if (!scene.Single)
            {
                Entities.Add(Scene.luigi);
            }

            // Create a camera instance and limit its moving range
            Scene.camera = new Camera(scene.graphics.GraphicsDevice.Viewport)
            {
                Limits = Scene.Bound.Rectangle
            };

            // Create 9 layers with parallax ranging from 0% to 100% (only horizontal)
            Layers = new List <Layer>
            {
                new Layer(Scene.camera)
                {
                    Parallax = new Vector2(0.0f, 0.0f)
                },                                                              //background layers
                new Layer(Scene.camera)
                {
                    Parallax = new Vector2(0.1f, 0.1f)
                },
                new Layer(Scene.camera)
                {
                    Parallax = new Vector2(0.2f, 0.2f)
                },
                new Layer(Scene.camera)
                {
                    Parallax = new Vector2(0.5f, 0.4f)
                },
                new Layer(Scene.camera)
                {
                    Parallax = new Vector2(0.8f, 0.8f)
                },
                new Layer(Scene.camera)
                {
                    Parallax = new Vector2(1.0f, 1.0f)
                },
                new Layer(Scene.camera)
                {
                    Parallax = new Vector2(1.0f, 1.0f)
                },
                new Layer(Scene.camera)
                {
                    Parallax = new Vector2(1.0f, 1.0f)
                },
                new Layer(Scene.camera)
                {
                    Parallax = new Vector2(1.0f, 1.0f)
                },                                                              // item
                new Layer(Scene.camera)
                {
                    Parallax = new Vector2(1.0f, 1.0f)
                },                                                              // blocks/char
                new Layer(Scene.camera)
                {
                    Parallax = new Vector2(0.0f, 0.0f)
                }                                                               // HUD
            };

            Rectangle limits = new Rectangle(0, 0, (int)Scene.camera.Limits.Value.Width, (int)Scene.camera.Limits.Value.Height);

            // Add one sprite to each background layer
            for (int i = 0; i < 6; i++)
            {
                Layers[i].Sprites.Add(new Sprite {
                    Texture = Content.Load <Texture2D>("Layer" + (i + 1)), Entity = null, rect = limits
                });
            }
            Sprite dimLayer = new Sprite {
                Texture = Scene.Pixel, Entity = null, rect = limits
            };

            dimLayer.Dim = 1f;
            Layers[8].Sprites.Add(dimLayer);

            // Add a few duplicates in different positions
            //Layers[7].Sprites.Add(new Sprite { Texture = Content.Load<Texture2D>("Layer8"), Position = new Vector2(900, 0), Entity = null, rect = limits });
            //Layers[8].Sprites.Add(new Sprite { Texture = Content.Load<Texture2D>("Layer9"), Position = new Vector2(1600, 0), Entity = null, rect = limits });

            // add items to layer 9, everything else in layer 10
            foreach (Entity entity in Entities)
            {
                if (entity is ItemEntity)
                {
                    Layers[6].Sprites.Add(entity.Sprite);
                }
                else if (entity is PlayerChar)
                {
                    Layers[9].Sprites.Add(entity.Sprite);
                }
                else
                {
                    Layers[7].Sprites.Add(entity.Sprite);
                }
            }

            // add HUD elements to Layer 11
            Layers[10].Sprites.Add(hud.MarioLivesDisp);
            Layers[10].Sprites.Add(hud.MarioCharDisp);
            Layers[10].Sprites.Add(hud.TimeDisp);
            Layers[10].Sprites.Add(hud.PointsDisp);
            if (!scene.Single)
            {
                Layers[10].Sprites.Add(hud.LuigiCharDisp);
                Layers[10].Sprites.Add(hud.LuigiLivesDisp);
                foreach (Sprite sprite in hud.LuigiLivesNum)
                {
                    Layers[10].Sprites.Add(sprite);
                }
            }
            foreach (Sprite sprite in hud.MarioLivesNum)
            {
                Layers[10].Sprites.Add(sprite);
            }
            foreach (Sprite sprite in hud.TimeNum)
            {
                Layers[10].Sprites.Add(sprite);
            }
            foreach (Sprite sprite in hud.PointsNum)
            {
                Layers[10].Sprites.Add(sprite);
            }
            foreach (Sprite sprite in hud.CoinsNum)
            {
                Layers[10].Sprites.Add(sprite);
            }
        }