Exemple #1
0
        /// <summary>
        /// Contructs a new level
        /// </summary>
        /// <param name="serviceProvider">The service provider that will be used to construct a ContentManager.</param>
        public Level(IServiceProvider serviceProvider)
        {
            // Create a new content manager to load content used just by this level.
            content = new ContentManager(serviceProvider, "Content");

            cannon = new Cannon(this);
            farmer = new Farmer(this, new Vector2(200, GAME_HEIGHT - 64));
            observer = new MovingObjectObserver(this);
            deadlyObjectFactory = new DeadlyObjectFactory(this);
            foregroundClouds = new CloudFactory(new Color(Color.White, .90f), 1f, 5, this);
            backgroundClouds = new CloudFactory(new Color(.75f, .75f, 1f, .95f), .50f, 17, this);
            score = 0;
            cannonCountdown = TimeSpan.FromSeconds(5.5);

            ground = new Rectangle(0, GAME_HEIGHT - 64, GAME_WIDTH, 64);

            // Load background layer textures.
            layers = new Texture2D[4];
            for (int i = 0; i < layers.Length; ++i)
            {
                // Choose a random segment for each background layer for level variety.
                int segmentIndex = 0; // random.Next(3);
                layers[i] = Content.Load<Texture2D>("Backgrounds/Layer" + i + "_" + segmentIndex);
            }
            ChangeWind();

            //Play BGM
            levelMusic = Content.Load<Song>("Audio/Music/GameMusic");
            MediaPlayer.Play(levelMusic);
        }
Exemple #2
0
 public Cloud(Vector2 initialPosition, float initialVelocity, Texture2D sprite, Color tint, float scale, CloudFactory myObserver, Level currentLevel)
 {
     level = currentLevel;
     boundingRectangle = new Rectangle((int)initialPosition.X, (int)initialPosition.Y,
                                      (int)((float)sprite.Width * scale), (int)((float)sprite.Height * scale));
     this.scale = scale;
     velocityX = initialVelocity;
     cloudSprite = sprite;
     cloudTint = tint;
     observer = myObserver;
 }