Beispiel #1
0
        /// <summary>
        /// Constructs a new level.
        /// </summary>
        /// <param name="serviceProvider">
        /// The service provider that will be used to construct a ContentManager.
        /// </param>
        /// <param name="fileStream">
        /// A stream containing the tile data.
        /// </param>
        public Closet(Game game, Vector2 start, IServiceProvider serviceProvider, Stream fileStream, int levelIndex)
        {
            this.Game = game;

            // Create a new content manager to load content used just by this level.
            content = new ContentManager(serviceProvider, "Content");

            timeRemaining = TimeSpan.FromMinutes(2.0);

            //LoadTiles(fileStream);

            start = RectangleExtensions.GetBottomCenter(GetBounds(0, 0));
            player = new ClayPot(this.Game, start);

            // Load background layer textures. For now, all levels must
            // use the same backgrounds and only use the left-most part of them.
            layers = new Texture2D[3];
            for (int i = 0; i < layers.Length; ++i)
            {
            // Choose a random segment if each background layer for level variety.
            int segmentIndex = levelIndex;
            layers[i] = Content.Load<Texture2D>("Backgrounds/Layer" + i + "_" + segmentIndex);
            }

            // Load sounds.
            exitReachedSound = Content.Load<SoundEffect>("Sounds/ExitReached");
        }
        /// <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.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //Save and load the actual day here.
            this.currentDay = 1;

            //Create a pot.
            //Later on we'll have a pot tool that can be used to add a pot to your grow slot.
            ClayPot myClayPot = new ClayPot(this, new Vector2(0,0));

            //Create a soil tool.  Going to use ph balanced soil here.
            PHBalancedSoilTool mySoil = new PHBalancedSoilTool(this, new Vector2(0,0));

            //Create a white widow seed.
            WaterMelonSeedTool myWhiteWidowSeedTool = new WaterMelonSeedTool(this, new Vector2(0,0));

            //Create an empty soda bottle tool.  It's a low capacity bottle that dispenses a tiny amount of water.
            EmptySodaBottleTool myEmptySodaBottle = new EmptySodaBottleTool(this, new Vector2(0,0)) { RemainingWater = 1.0 };

            //Create a water source, my sink, don't have a purifier yet.
            SinkWaterSource mySink = new SinkWaterSource(this, new Vector2(0,0)) { Quality = 0.5 };

            //Use the soil tool with the pot to add soil to the pot.
            mySoil.Use(myClayPot);

            //Use the seed tool to add the seed to the soil.
            myWhiteWidowSeedTool.Use(myClayPot);

            //Use the empty soda bottle to add water to the soil.
            myEmptySodaBottle.Use(myClayPot);

            //Use the empty soda bottle tool with the sink to refill it with water.
            myEmptySodaBottle.Use(mySink);

            LoadNextLevel();
            // TODO: use this.Content to load your game content here
        }
Beispiel #3
0
        /// <summary>
        /// Instantiates a player, puts him in the level, and remembers where to put him when he is resurrected.
        /// </summary>
        private void LoadStartTile(int x, int y)
        {
            if (Player != null)
            throw new NotSupportedException("A level may only have one starting point.");

            start = RectangleExtensions.GetBottomCenter(GetBounds(x, y));
            player = new ClayPot(this.Game, start);

            //return new Tile(null, TileCollision.Passable);
        }