Example #1
0
 void NextLevel()
 {
     if(_currentLevel.GetType() == typeof(Level1))
         _currentLevel = new Level2(_voxelRenderer);
     else if (_currentLevel.GetType() == typeof(Level2))
         _currentLevel = new Level3(_voxelRenderer);
     else if (_currentLevel.GetType() == typeof(Level3))
         _currentLevel = new Level4(_voxelRenderer);
     else if (_currentLevel.GetType() == typeof(Level4))
         _currentLevel = new Level5(_voxelRenderer);
     else
         _currentLevel = new Level1(_voxelRenderer);
 }
Example #2
0
        protected override void LoadContent()
        {
            _voxelRenderer = new VoxelRenderer(GraphicsDevice, Content);
            _currentLevel = new Level1(_voxelRenderer);

            _seedbar = new Seedbar(Window.NativeWindow as System.Windows.Forms.Control);
            _seedbar.LoadContent(GraphicsDevice, Content);

            _background = new Background(GraphicsDevice);

            _spriteBatch = new SpriteBatch(GraphicsDevice);
            _largeFont = Content.Load<SpriteFont>("largefont.tkfnt");
            _pixTexture = Content.Load<Texture2D>("pixel.png");

            base.LoadContent();
        }
Example #3
0
        protected override void Update(GameTime gameTime)
        {
            if (System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.Escape))
                Exit();

            // move camera
            _camera.Update(gameTime);

            if (!_gamePaused)
            {

                // Simulate level if 0.25f seconds passed.
                _cumulatedFrameTime += gameTime.ElapsedGameTime.TotalSeconds;
                if (_cumulatedFrameTime > 0.25)
                {
                    _cumulatedFrameTime -= 0.25;
                    _currentLevel.Tick();
                }

                _seedbar.Update();

                // the permanent picking
                var ray = _camera.GetPickingRay(GraphicsDevice.BackBuffer.Width, GraphicsDevice.BackBuffer.Height);
                _pickPosAvailable = this._currentLevel.GetMap().PickPosition(ray, out _pickedPos);

                // stop game?
                if (_currentLevel.IsVictory() || _currentLevel.IsLost())
                {
                    _gamePaused = true;
                    // TODO: Display message
                }

                // next/prev level cheat
                if (System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.OemPlus) && !wasCheatPlusPressed)
                {
                    NextLevel();
                    wasCheatPlusPressed = true;
                }
                wasCheatPlusPressed = !System.Windows.Input.Keyboard.IsKeyUp(System.Windows.Input.Key.OemPlus);
            }
            else
            {
                if (System.Windows.Input.Keyboard.IsKeyDown(System.Windows.Input.Key.Enter))
                {
                    if (_currentLevel.IsVictory())
                        NextLevel();
                    else if (_currentLevel.IsLost())
                        _currentLevel = (Level)_currentLevel.GetType().GetConstructor(new[] { typeof(VoxelRenderer) }).Invoke(new object[] { (object)_voxelRenderer} );
                    _gamePaused = false;
                }
            }

            // Handle base.Update
            base.Update(gameTime);
        }
Example #4
0
        public void Draw(Level currentlevel, GameTime gameTime)
        {
            float progress = (float)currentlevel.CurrentBiomass / (float)currentlevel.TargetBiomass;
            float evilProgress = (float)currentlevel.CurrentParasiteMass / (float)currentlevel.FinalParasiteBiomass;

            progressCount = (float)gameTime.TotalGameTime.TotalSeconds / 2;

            alpha = progressCount - (float)Math.Floor(progressCount);

            spriteBatch.Begin(SpriteSortMode.Deferred, spriteBatch.GraphicsDevice.BlendStates.NonPremultiplied);

            //draw Progress good/evil
            spriteBatch.Draw(progressBar, new DrawingRectangle(windowWidth, windowHeigth, progressBarPictureWidth, (int)((windowHeigth - 68) * progress)),
                new DrawingRectangle(progressBarPictureWidth * ((int)progressCount % progressBarPictureCount), 0, progressBarPictureWidth, (int)(progressBarPictureHeight * progress)),
                new Color(1f,1f,1f, 1f - alpha), (float)Math.PI, new Vector2(0, 0), SpriteEffects.None, 0);
            spriteBatch.Draw(progressBar, new DrawingRectangle(windowWidth, windowHeigth, progressBarPictureWidth, (int)((windowHeigth - 68) * progress)),
                new DrawingRectangle(progressBarPictureWidth * (((int)progressCount + 1) % progressBarPictureCount), 0, progressBarPictureWidth, (int)(progressBarPictureHeight * progress)),
                new Color(1f, 1f, 1f, alpha), (float)Math.PI, new Vector2(0, 0), SpriteEffects.None, 0);

            spriteBatch.Draw(evilProgressBar, new DrawingRectangle(windowWidth - progressBarPictureWidth, windowHeigth, progressBarPictureWidth, (int)((windowHeigth - 68) * evilProgress)),
                new DrawingRectangle(progressBarPictureWidth * ((int)progressCount % progressBarPictureCount), 0, progressBarPictureWidth, (int)(progressBarPictureHeight * evilProgress)),
                new Color(1f,1f,1f, 1f - alpha), (float)Math.PI, new Vector2(0, 0), SpriteEffects.None, 0);
            spriteBatch.Draw(evilProgressBar, new DrawingRectangle(windowWidth - progressBarPictureWidth, windowHeigth, progressBarPictureWidth, (int)((windowHeigth - 68) * evilProgress)),
                new DrawingRectangle(progressBarPictureWidth * (((int)progressCount + 1) % progressBarPictureCount), 0, progressBarPictureWidth, (int)(progressBarPictureHeight * evilProgress)),
                new Color(1f, 1f, 1f, alpha), (float)Math.PI, new Vector2(0, 0), SpriteEffects.None, 0);

            spriteBatch.End();
            spriteBatch.Begin();

            for (int i = 0; i < barLength; i++)
            {
                if (i == 0 || i == 1 || i == 2 || i == 3 || i == 4)
                {
                //draw frame
                spriteBatch.Draw(pixel, new DrawingRectangle((int)seeds[i]._position.X, (int)seeds[i]._position.Y , 84, 32), Color.Black);
                spriteBatch.Draw(frame, new DrawingRectangle((int)seeds[i]._position.X - 5, (int)seeds[i]._position.Y - 5, 94, 42), Color.Gray);
                //draw price
                spriteBatch.Draw(helix, new DrawingRectangle((int)seeds[i]._position.X + 35, (int)seeds[i]._position.Y + 5, 10, 20), Color.White);
                spriteBatch.DrawString(font, TypeInformation.GetPrice(seeds[i]._type).ToString(), new Vector2(seeds[i]._position.X + 43, seeds[i]._position.Y+5), Color.White);
                //draw Icons
                spriteBatch.Draw(textures[i], new DrawingRectangle((int)seeds[i]._position.X, (int)seeds[i]._position.Y, 32, 32), Color.White);
                }
            }

            //draw Resources
            spriteBatch.Draw(pixel, new DrawingRectangle(9 * windowWidth / 10 + 7, 5, progressBarPictureWidth * 2-10, 54), Color.Black);
            spriteBatch.Draw(frame, new DrawingRectangle(9 * windowWidth / 10 + 2, 0, progressBarPictureWidth * 2, 64), Color.Gray);
            spriteBatch.Draw(helix, new DrawingRectangle(9 * windowWidth / 10 + 15, 9, 23, 46), Color.White);
            spriteBatch.DrawString(largeFont, currentlevel.Resources.ToString(), new Vector2(9 * windowWidth / 10 + 36, -6), Color.White);

            if (_selected > -1)
            {
                spriteBatch.Draw(frame, new DrawingRectangle((int)seeds[_selected]._position.X - 5, (int)seeds[_selected]._position.Y - 5, 94, 42), Color.Yellow);
            }

            //draw Tooltip
            for (int i = 0; i < barLength; i++)
            {
                if (i == 0 || i == 1 || i == 2 || i == 3 || i == 4)
                {
                if (MouseOver(seeds[i]._position, 83, 32))
                {
                    tooltipCounter[i] += gameTime.ElapsedGameTime.Milliseconds;

                    if (tooltipCounter[i] >= 300)
                    {
                        int corrector = 0;
                        if (mousePosition.X + 310 > windowWidth) corrector = mousePosition.X + 310 - windowWidth;

                        spriteBatch.Draw(pixel, new DrawingRectangle(mousePosition.X + 10 - corrector, mousePosition.Y + 10, 280, 130), new Color(0.5f, 0.5f, 0.5f, 0.5f));
                        spriteBatch.DrawString(font, TypeInformation.GetName(seeds[i]._type), new Vector2(mousePosition.X + 35 - corrector, mousePosition.Y + 15), Color.Black);
                        spriteBatch.DrawString(font, "+" + TypeInformation.GetStrength(seeds[i]._type)[0] + "\n+" + TypeInformation.GetStrength(seeds[i]._type)[1], new Vector2(mousePosition.X + 15 - corrector, mousePosition.Y + 40), Color.Green);
                        spriteBatch.DrawString(font, "-" + TypeInformation.GetWeakness(seeds[i]._type)[0] + "\n-" + TypeInformation.GetWeakness(seeds[i]._type)[1], new Vector2(mousePosition.X + 15 - corrector, mousePosition.Y + 90), Color.Crimson);
                    }
                }
                else tooltipCounter[i] = 0;
                }
            }
            spriteBatch.End();
        }