Example #1
0
        // This method is called whenever a condition requires the current level to be reset. For instance player death or too many children died.
        private void Restart()
        {
            //Reset player to starting position.
            Player.Position          = new Vector2(Player.BoundingBox.Width, Player.BoundingBox.Height);
            Player.Ammo              = 0;
            Player.DistanceTravelled = 0;
            ChildrenFed              = 0;
            ChildrenDied             = 0;

            switch (State)
            {
            case GameState.Level0A:
                Text            = new Text("LEVEL A:\nFeed the hungry child \nbefore the soldier reaches her...", 4000 + Time);
                Level           = LevelConstructor.Level0A();
                ChildrenTotal   = 1;
                ChildrenFedGoal = 1;
                Player.Ammo     = 10;
                break;

            case GameState.Level0B:
                Text            = new Text("LEVEL B:\nDon't get killed by the helicopter...", 4000 + Time);
                Level           = LevelConstructor.Level0B();
                ChildrenTotal   = 0;
                ChildrenFedGoal = 0;
                Player.Ammo     = 6;
                break;

            case GameState.Level1:
                Text            = new Text("LEVEL 1:\nFeed 2 hungry children...", 3000 + Time);
                Level           = LevelConstructor.Level1();
                ChildrenTotal   = 3;
                ChildrenFedGoal = 2;
                Player.Ammo     = 20;
                break;

            case GameState.Level2:
                Text            = new Text("LEVEL 2:\nCows can be burgers...", 3000 + Time);
                Level           = LevelConstructor.Level2();
                ChildrenTotal   = 6;
                ChildrenFedGoal = 5;
                Player.Ammo     = 5;
                break;

            case GameState.Level3:
                Text            = new Text("LEVEL 3:\nJust chill...", 3000 + Time);
                Level           = LevelConstructor.Level3();
                ChildrenTotal   = 0;
                ChildrenFedGoal = 0;
                Player.Ammo     = 0;
                break;

            case GameState.Level4:
                Text            = new Text("Game Over, You won!\nNow contemplate\nthe meaning of life\nwithout any challenge...", 30000 + Time);
                Level           = LevelConstructor.Level4();
                ChildrenTotal   = 0;
                ChildrenFedGoal = 0;
                Player.Ammo     = 0;
                break;
            }
            CollisionHandler = new CollissionHandler(Level.LevelSprites);
        }
Example #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            GroundLevel  = ScreenSize.Y * 0.8f;
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            Level        = new Level();

            //SOUNDS
            ShotSound                = Content.Load <SoundEffect>("./sounds/shot");
            ChildFedSound            = Content.Load <SoundEffect>("./sounds/BurgerPickUp");
            MooSound                 = Content.Load <SoundEffect>("./sounds/moo");
            ChildDeathSound          = Content.Load <SoundEffect>("./sounds/ChildDead");
            SoldierDeathSound        = Content.Load <SoundEffect>("./sounds/SoldierDeath");
            HelicopterExplosionSound = Content.Load <SoundEffect>("./sounds/Explosion");
            bgMusic = Content.Load <SoundEffect>("./sounds/newJazz");

            List <Texture2D> textures = new List <Texture2D>();

            textures.Add(Content.Load <Texture2D>("star"));
            textures.Add(Content.Load <Texture2D>("star"));
            textures.Add(Content.Load <Texture2D>("star"));
            FireworksEmitter fireworks = new FireworksEmitter(textures, new Vector2(400, 240));

            List <Texture2D> textures2 = new List <Texture2D>();

            textures2.Add(Content.Load <Texture2D>("helidebris"));

            HelicopterDebris helicopterDebrisEmitter = new HelicopterDebris(textures2, new Vector2());

            Texture2D titleTexture = Content.Load <Texture2D>("title");
            Sprite    intro        = new Sprite(titleTexture, new Vector2(ScreenSize.X * 0.4f, ScreenSize.X * 0.1f));

            //This is the balloon used on the intro screen
            Texture2D introBalloonTexture2D = Content.Load <Texture2D>("introBalloon");

            _introBalloon = new IntroBalloon(introBalloonTexture2D, new Vector2(50, ScreenSize.Y));

            // This is the player balloon object. It will be the only one created so lets keep track of it so we don't loose it.
            Texture2D ballonTexture = Content.Load <Texture2D>("./balloon/balloon");

            Player = new Balloon(ballonTexture, new Vector2(0, 0));

            // THESE ARE THE NEW PROTOTYPES THAT WILL BE USED IN LEVELCONSTRUCTOR!//////////////////////////////////////
            Vector2    vectorZero      = new Vector2(0, 0);
            Child      ChildProto      = new Child(Content.Load <Texture2D>("child"), vectorZero);
            Soldier    SoldierProto    = new Soldier(Content.Load <Texture2D>("animated_soldier"), vectorZero);
            Hut        HutProto        = new Hut(Content.Load <Texture2D>("hut"), vectorZero);
            Jet        JetProto        = new Jet(Content.Load <Texture2D>("./attackplane/attackplane"), vectorZero);
            Helicopter HelicopterProto = new Helicopter(Content.Load <Texture2D>("Helicopter"), vectorZero);
            Cow        CowProto        = new Cow(Content.Load <Texture2D>("cow"), vectorZero);
            Cloud      CloudProto      = new Cloud(Content.Load <Texture2D>("./cloud/cloud"), vectorZero);
            Mountain   MountainProto   = new Mountain(Content.Load <Texture2D>("mountain"), vectorZero);
            PalmTree   PalmTreeProto   = new PalmTree(Content.Load <Texture2D>("palm"), vectorZero);
            Ground     GroundProto     = new Ground(Content.Load <Texture2D>("ground"), vectorZero);

            ChildDeathTexture    = Content.Load <Texture2D>("diechild");
            SoldierDeathTexture  = Content.Load <Texture2D>("diesoldier");
            SoldierEatingTexture = Content.Load <Texture2D>("eatingsoldier");

            ExplosionTexture = Content.Load <Texture2D>("explosionflash");

            BalloonDeathTexture = Content.Load <Texture2D>("./balloon/balloonburning");

            //These classes are spawned during the game and are needed by the classes that spawn
            Bullet BulletProto = new Bullet(Content.Load <Texture2D>("bullet"), vectorZero, null);

            BurgerTexture   = Content.Load <Texture2D>("burger");
            HeadTexture     = Content.Load <Texture2D>("childhead");
            HeadOKTexture   = Content.Load <Texture2D>("childheadOK");
            HeadDEADTexture = Content.Load <Texture2D>("childheadDEAD");
            BulletTracer    = Content.Load <Texture2D>("bulletTracer");

            //Here we initialise our level contructor. It will hold all of our object prototypes.
            LevelConstructor = new LevelConstructor(ChildProto, SoldierProto, HutProto, JetProto, HelicopterProto, CowProto, CloudProto, MountainProto, PalmTreeProto, GroundProto, BulletProto);
            LevelConstructor.HelicopterDebris = helicopterDebrisEmitter;
            LevelConstructor.Fireworks        = fireworks;

            //This is a 1 pixel wide color gradient image that we draw a lot to fill the screen. Wonder if a big picture would be better?
            _backgroundTexture = Content.Load <Texture2D>("background");
            _background        = new Sprite(_backgroundTexture, vectorZero);

            _blackbottom = Content.Load <Texture2D>("blackbottom");

            //The game starts with us showing the Intro screen. Therefore we set the gamestate to Intro. Who would have thought...
            State = GameState.Intro;

            // We use the levelconstructor to set the level to the intro screen.
            Level = LevelConstructor.IntroScreen();
            Level.LevelSprites.Add(_introBalloon);
            Level.LevelSprites.Add(intro);

            // The CollisionHandler is created with the level list of sprites that we want to check collisions for
            CollisionHandler = new CollissionHandler(Level.LevelSprites);

            Font = Content.Load <SpriteFont>("superfont");
            Text = new Text("", 0);

            SoundEffectInstance bgm = bgMusic.CreateInstance();

            bgm.Volume   = 0.5f;
            bgm.IsLooped = true;
            bgm.Play();
        }