示例#1
0
        /// <summary>
        /// Load all required assets for given level (starting with zero).
        /// </summary>
        /// <param name="level">0-based level index</param>
        /// <param name="levelFile">Path to level txt file (With extension) </param>
        public void LoadLevel(int level, string levelFile)
        {
            //Load in the Background
            ParallaxBackground b = new ParallaxBackground("ParallaxBG1", Textures["Background"], new Rectangle(0, 0, TargetWidth, TargetHeight), GameState.Game, 1, null);

            //Generate tiles
            GenerateTiles(levelFile);



            if (level == 0)
            {
                //Enemies
                Catfish c1 = new Catfish("Catfish1", Textures["catfish"], new Rectangle(1997, 1000, 100, 50));
                Catfish c2 = new Catfish("Catfish2", Textures["catfish"], new Rectangle(2500, 1000, 100, 50));


                //Drop in a goal
                Goal goal = new Goal("Goal1", Textures["WhiteBlock"], new Rectangle(5655, -244, 100, 300));

                //Add pickups
                ScorePickup  scorePickup  = new ScorePickup("ScorePickup1", Textures["WhiteBlock"], new Rectangle(1063, 505, 100, 100), 10);
                HealthPickup healthPickup = new HealthPickup("HealthPickup1", Textures["WhiteBlock"], new Rectangle(1391, 55, 100, 100), 1);
                healthPickup.DrawColor = Color.Red;

                //Add a checkpoint
                CheckPoint checkPoint = new CheckPoint("Checkpoint", Textures["WhiteBlock"], new Rectangle(2270, -400, 50, 100));

                //Add in tutorial text
                WorldText tut1 = new WorldText("Tutorial1", "W,A,S,D = Move", font, new Vector2(200, 200));
                WorldText tut2 = new WorldText("Tutorial2", "Space = Jump", font, new Vector2(200, 300));
            }



            //Create the player regardless of level
            Player player = new Player("Current", Textures["CurrentIdle"], Textures["Laser"], new Rectangle(100, 0, 100, 100));

            player.AddAnimation(new Animate(Textures["CurrentIdle"], 1, 1, Animate.ONESIXTIETHSECPERFRAME, player));
            player.AddAnimation(new Animate(Textures["CurrentSwim"], 4, 3, Animate.ONESIXTIETHSECPERFRAME * 5, player));
            player.AddAnimation(new Animate(Textures["CurrentWalk"], 4, 3, Animate.ONESIXTIETHSECPERFRAME, player));

            //Create the Camera
            MainCamera = new Camera("MainCamera", new Rectangle(0, 0, 0, 0), player);

            //Setup parallax bg
            ParallaxBackground p = (ParallaxBackground)(GameManager.Get("ParallaxBG1"));

            p.Target = player;
        }
示例#2
0
        /// <summary>
        /// Load all required assets for given level (starting with zero).
        /// </summary>
        /// <param name="level">0-based level index</param>
        /// <param name="levelFile">Path to level txt file (With extension) </param>
        public void LoadLevel(int level, string levelFile)
        {
            //Load in the Background
            ParallaxBackground b = new ParallaxBackground("ParallaxBG1", Textures["Background"], new Rectangle(0, 0, TargetWidth, TargetHeight), GameState.Game, 1, null);

            //Generate tiles
            GenerateTiles(levelFile);


            Player player = null;

            if (level == 0)
            {
                //Enemies
                Catfish c1 = new Catfish("Catfish1", Textures["Catfish"], new Rectangle(1997, 1000, 100, 50));
                Catfish c2 = new Catfish("Catfish2", Textures["Catfish"], new Rectangle(2500, 1000, 100, 50));
                Catfish c3 = new Catfish("Catfish3", Textures["Catfish"], new Rectangle(8039, 1400, 100, 50));
                Catfish c4 = new Catfish("Catfish4", Textures["Catfish"], new Rectangle(8039, 1000, 100, 50));



                //Drop in a goal
                Goal goal = new Goal("Goal1", Textures["Crossbone"], new Rectangle(7024, -994, 200, 100));

                //Add pickups
                ScorePickup  scorePickup  = new ScorePickup("ScorePickup1", Textures["ScorePickup"], new Rectangle(1301, 504, 100, 100), 10);
                ScorePickup  scorePickup1 = new ScorePickup("ScorePickup2", Textures["ScorePickup"], new Rectangle(6895, -120, 100, 100), 100);
                HealthPickup healthPickup = new HealthPickup("HealthPickup1", Textures["HealthPickup"], new Rectangle(1326, 10, 100, 100), 1);
                healthPickup.DrawColor = Color.Red;

                //Add a checkpoint
                CheckPoint checkPoint = new CheckPoint("Checkpoint", Textures["Checkpoint"], new Rectangle(2270, -400, 50, 100));

                //Add in tutorial text
                WorldText tut1 = new WorldText("Tutorial1", "W,A,S,D = Move", font, new Vector2(200, 200));
                WorldText tut2 = new WorldText("Tutorial2", "Space = Jump", font, new Vector2(200, 300));

                player = new Player("Current", Textures["CurrentIdle"], Textures["Laser"], new Rectangle(209, 505, 100, 100));
            }
            else if (level == 1)
            {
                player = new Player("Current", Textures["CurrentIdle"], Textures["Laser"], new Rectangle(368, 355, 100, 100));
                ScorePickup scorePickup = new ScorePickup("ScorePickup", Textures["ScorePickup"], new Rectangle(4688, -1144, 100, 100), 10);


                WorldText   laserInstr = new WorldText("LaserInstruction", "Shift=Laser", font, new Vector2(550, 200));
                LaserPickup laser      = new LaserPickup("LaserPickup", Textures["LaserPickup"], new Rectangle(550, 300, 100, 100), 0);

                LandCat landCat  = new LandCat("Landcat", Textures["Landcat"], new Rectangle(3337, 55, 200, 125));
                LandCat landCat4 = new LandCat("Landcat4", Textures["Landcat"], new Rectangle(7866, -844, 200, 125));
                LandCat landCat5 = new LandCat("Landcat5", Textures["Landcat"], new Rectangle(8966, -1444, 200, 125));
                Goal    goal     = new Goal("Goal", Textures["Crossbone"], new Rectangle(14378, -2794, 200, 100));
            }
            else if (level == 2)
            {
                player = new Player("Current", Textures["CurrentIdle"], Textures["Laser"], new Rectangle(200, 205, 100, 100));

                //Add pickups
                ScorePickup scorePickup  = new ScorePickup("ScorePickup1", Textures["ScorePickup"], new Rectangle(2500, 50, 100, 100), 10);
                ScorePickup scorePickup2 = new ScorePickup("ScorePickup2", Textures["ScorePickup"], new Rectangle(7500, -2100, 100, 100), 10);

                Goal goal = new Goal("Goal1", Textures["Crossbone"], new Rectangle(7607, -1594, 200, 100));
            }
            else if (level == 3)
            {
                //score blocks
                ScorePickup scorePickup = new ScorePickup("ScorePickup1", Textures["ScorePickup"], new Rectangle(4300, -2077, 100, 100), 10);

                //enemy
                LandCat kitty = new LandCat("Cat1", Textures["Landcat"], new Rectangle(3744, -94, 200, 125));
                player = new Player("Current", Textures["CurrentIdle"], Textures["Laser"], new Rectangle(238, 205, 100, 100));

                Goal goal = new Goal("Goal1", Textures["Crossbone"], new Rectangle(9555, -2944, 200, 100));
            }

            //Create the Camera
            MainCamera = new Camera("MainCamera", new Rectangle(0, 0, 0, 0), player);

            //Setup parallax bg
            ParallaxBackground p = (ParallaxBackground)(GameManager.Get("ParallaxBG1"));

            p.Target = player;
        }