Esempio n. 1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            if (Game1.World != null && Game1.World.Map != null && Game1.World.GroundRender == null)
            {
                Game1.World.GroundRender = new RenderTarget2D(GraphicsDevice, Game1.World.Map.Width * 16, Game1.World.Map.Height * 16);
                GraphicsDevice.SetRenderTarget(Game1.World.GroundRender);
                spriteBatch.Begin();
                Game1.World.DrawGround(spriteBatch);
                spriteBatch.End();
            }

            GraphicsDevice.SetRenderTarget(gameRender);
            GraphicsDevice.Clear(Color.Black);
            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise);
            if (Game1.World != null && Game1.World.GroundRender != null)
            {
                spriteBatch.Draw(Game1.World.GroundRender, Vector2.Zero.DrawPos(), null, Color.White, 0, Vector2.Zero, Game1.PixelZoom, SpriteEffects.None, 1);
                Game1.World.Draw(spriteBatch);
            }
            Texture2D blank = new Texture2D(GraphicsDevice, 1, 1);

            blank.SetData(new Color[] { Color.White });
            spriteBatch.Draw(blank, new Rectangle(0, 0, Game1.GameWidth, Game1.GameHeight), Color.Black * Fade);
            Thyme.Draw(spriteBatch);
            spriteBatch.End();

            GraphicsDevice.SetRenderTarget(null);
            spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, RasterizerState.CullCounterClockwise);
            spriteBatch.Draw(gameRender, Vector2.Zero, null, Thyme.light, 0, Vector2.Zero, 1, SpriteEffects.None, 1);
            if (Game1.CurrentMenu != null)
            {
                Game1.CurrentMenu.Draw(spriteBatch);
            }
            Buffs.Draw(spriteBatch);
            spriteBatch.Draw(ContentLibrary.Sprites["ui:cursorPict"], new Vector2(Mouse.GetState().X, Mouse.GetState().Y), null, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, Layer.Mouse);
            spriteBatch.End();

            base.Draw(gameTime);
        }
Esempio n. 2
0
        protected override void Update(GameTime gameTime)
        {
            Buffs.Update(gameTime);
            KeyboardUtil.Update();
            MouseUtil.Update();

            if (!Game1.IsPaused())
            {
                Thyme.Update(gameTime);
            }
            if (KeyboardUtil.KeyPressed(Keys.B))
            {
                World.AddEntity(new Sodamachine(Utility.GetTilePos(MouseUtil.WorldPos.X, MouseUtil.WorldPos.Y)));
            }
            if (KeyboardUtil.KeyPressed(Keys.K))
            {
                timeman++;
            }
            if (KeyboardUtil.KeyPressed(Keys.J))
            {
                timeman--;
            }

            if (MouseUtil.ButtonPressed(MouseButton.RightButton))
            {
                Game1.World.AddEntity(new Treeeeeeee(Utility.GetTilePos(MouseUtil.WorldPos.X, MouseUtil.WorldPos.Y)));
            }
            if (MouseUtil.ButtonPressed(MouseButton.MiddleButton))
            {
                Game1.World.AddEntity(new Giantdog(Utility.GetTilePos(MouseUtil.WorldPos.X, MouseUtil.WorldPos.Y)));
            }
            if (KeyboardUtil.KeyPressed(Keys.J))
            {
                Game1.World.AddEntity(new Plant(Utility.GetTilePos(Player.X, Player.Y)));
            }

            if (KeyboardUtil.KeyPressed(Keys.T))
            {
                Thyme.active = !Thyme.active;
            }

            if (!playedMusic)
            {
                Music.Play("music");
                Music.Volume(0.2f);
                playedMusic = true;
            }

            if (KeyboardUtil.KeyPressed(Keys.M))
            {
                if (KeyboardUtil.IsKeyDown(Keys.LeftControl))
                {
                    Music.Dispose();
                    Music.Play("monoman");
                    Music.Volume(0.3f);
                }
                else
                {
                    if (!Music.IsMuted)
                    {
                        Music.Mute();
                    }
                    else
                    {
                        Music.UnMute();
                    }
                }
            }

            Game1.Random = new Random();

            if (Game1.CurrentMenu != null)
            {
                Game1.CurrentMenu.Update(gameTime);
                KeyboardUtil.Update();
            }

            if (Game1.World != null)
            {
                Game1.World.Update(gameTime);
            }
            if (KeyboardUtil.KeyPressed(Keys.X))
            {
                World.AddEntity(new Chest(Utility.GetTilePos(MouseUtil.WorldPos.X, MouseUtil.WorldPos.Y)));
            }

            if (KeyboardUtil.KeyPressed(Keys.Escape) && Game1.CurrentMenu == null)
            {
                Game1.OpenMenu(new Menu());
            }
            if (KeyboardUtil.KeyPressed(Keys.E) && Game1.CurrentMenu == null)
            {
                Game1.OpenMenu(new JagInventory());
            }
            if (KeyboardUtil.KeyPressed(Keys.V))
            {
                World.AddEntity(new Chest((Utility.GetTilePos(MouseUtil.WorldPos.X, MouseUtil.WorldPos.Y))));
            }
            if (KeyboardUtil.KeyPressed(Keys.OemPlus))
            {
                if (Game1.PixelZoom < 1)
                {
                    Game1.PixelZoom *= 2;
                }
                else
                {
                    Game1.PixelZoom++;
                }
            }
            if (KeyboardUtil.KeyPressed(Keys.OemMinus))
            {
                if (Game1.PixelZoom <= 1)
                {
                    Game1.PixelZoom /= 2;
                }
                else
                {
                    Game1.PixelZoom--;
                }
            }

            base.Update(gameTime);
        }