示例#1
0
        public PalmTree MakeNewTree(float scale, int offset)
        {
            Random ran  = new Random();
            Game1  game = Game1.Instance;

            PalmTree tree = new PalmTree(SpriteTexture, new Vector2(x: offset, y: Game1.GroundLevel - SpriteTexture.Height * scale));

            tree.Scale = scale;
            return(tree);
        }
示例#2
0
        public LevelConstructor(Child childProto, Soldier soldierProto, Hut hutProto, Jet jetProto, Helicopter helicopterProto, Cow cowProto, Cloud cloudProto, Mountain mountainProto,
                                PalmTree palm, Ground ground, Bullet bullet)
        {
            game   = Game1.Instance;
            level  = new Level();
            ran    = new Random();
            width  = game.ScreenSize.X;
            height = game.ScreenSize.Y;

            ChildProto      = childProto;
            SoldierProto    = soldierProto;
            HutProto        = hutProto;
            JetProto        = jetProto;
            HelicopterProto = helicopterProto;
            CowProto        = cowProto;
            CloudProto      = cloudProto;
            MountainProto   = mountainProto;
            PalmProto       = palm;
            GroundProto     = ground;
            BulletProto     = bullet;
        }
示例#3
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();
        }