Example #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            //Clears the graphics device; updates the invisible renderer and player's strike box.
            GraphicsDevice.Clear(Color.Black);
            Camera2d cam = new Camera2d();

            cam.Pos       = new Vector2(CamX, CamY);
            p.RenderDim.X = (int)p.PlayerX + ((10 - p.RenderDim.Width) / 2);
            p.RenderDim.Y = (int)p.PlayerY + ((40 - p.RenderDim.Height) / 2);
            p.StrikeBox.X = (int)p.PlayerX + ((10 - p.StrikeBox.Width) / 2);
            p.StrikeBox.Y = (int)p.PlayerY + ((40 - p.StrikeBox.Height) / 2);

            //Begins the spriteBatch.
            spriteBatch.Begin(SpriteSortMode.Immediate,
                              BlendState.AlphaBlend,
                              null,
                              null,
                              null,
                              null,
                              cam.get_transformation(GraphicsDevice));

            //Draws map tiles in the TileList.
            foreach (Tile t in TileList)
            {
                if (t.Rect.Intersects(p.RenderDim))
                {
                    spriteBatch.Draw(t.Tex, new Vector2(t.X, t.Y), new Rectangle(0, 0, 25, 25), Color.White);
                }
            }

            //Draws the WorldObjects in the ObjectList.
            foreach (WorldObject w in ObjectList)
            {
                if (w.HitBox.Intersects(p.RenderDim))
                {
                    spriteBatch.Draw(w.Tex, new Vector2(w.X, w.Y), new Rectangle(0, 0, w.Tex.Width, w.Tex.Height), Color.White);
                }
            }

            //Draws each spawn in the SpawnList.
            foreach (Spawn s in SpawnList)
            {
                if (s.HitBox.Intersects(p.RenderDim) && !s.HitBox.Intersects(p.StrikeBox))
                {
                    spriteBatch.Draw(s.Npc.Tex, new Vector2(s.X, s.Y), new Rectangle(0, 0, s.Npc.Tex.Width, s.Npc.Tex.Height), Color.White);
                }
            }

            //Draws each invisible collider boundary in the BoundList.
            foreach (Tile t in BoundList)
            {
                spriteBatch.Draw(t.Tex, new Vector2(t.X, t.Y), t.Rect, Color.Black);
            }
            spriteBatch.Draw(p.PlayerHead, new Vector2(p.PlayerX, p.PlayerY - 10), new Rectangle(0, 0, p.PlayerHead.Width, p.PlayerBody.Height), Color.White);
            spriteBatch.Draw(p.PlayerBody, new Vector2(p.PlayerX, p.PlayerY), new Rectangle(0, 0, p.PlayerHead.Width, p.PlayerBody.Height), Color.White);

            spriteBatch.End();

            base.Draw(gameTime);
        }
        public override void Draw(GameTime gameTime)
        {
            graphicsDevice.Clear(Color.LightCoral);


            //implements a camera
            spriteBatch.Begin(SpriteSortMode.Immediate,
                              BlendState.AlphaBlend, null, null, null, null, cam.get_transformation(graphicsDevice));
            //background here

            platformList.Draw(spriteBatch);
            enemyList.Draw(spriteBatch);
            sliceList.Draw(spriteBatch);
            particleList.Draw(spriteBatch);

            player.Draw(spriteBatch);
            if (showbb)
            {
                //enemyList.drawInfo(spriteBatch, Color.Red, Color.Yellow);
                sliceList.drawInfo(spriteBatch, Color.Red, Color.Yellow);
                player.drawBB(spriteBatch, Color.Red);
                platformList.drawInfo(spriteBatch, Color.Red, Color.Yellow);
                LineBatch.drawLineRectangle(spriteBatch, new Rectangle((int)PlayerSpawnPosition.X, (int)PlayerSpawnPosition.Y, 20, 20), Color.Black);
                LineBatch.drawLineRectangle(spriteBatch, OutOfBounds, Color.Red);
            }



            goal.Draw(spriteBatch);
            spriteBatch.End();


            //DRAW UI STUFF HERE
            spriteBatch.Begin();
            abilityIconDoubleJump.Draw(spriteBatch);
            abilityIconDash.Draw(spriteBatch);
            abilityIconSlice.Draw(spriteBatch);

            TextRenderable score = new TextRenderable("SCORE: " + Game1.TimeScore.ToString(), new Vector2(100, 100), MenuScreen.menuFont, Color.Black);

            score.Draw(spriteBatch);
            //spriteBatch.Draw(texMouseCursor, new Vector2(InputManager.Instance.GetMousePositionX(), InputManager.Instance.GetMousePositionY()), Color.White);
            spriteBatch.Draw(texMouseCursor, null, new Rectangle(InputManager.Instance.GetMousePositionX(), InputManager.Instance.GetMousePositionY(), 30, 30), null, null, 0, null, Color.White, SpriteEffects.FlipHorizontally, 0);
            spriteBatch.End();
        }
Example #3
0
 public void Draw(SpriteBatch spriteBatch, GraphicsDevice graphicsDevice)
 {
     spriteBatch.Begin();
     spriteBatch.Draw(Bg, Vector2.Zero, Color.White);
     spriteBatch.End();
     DayNightCycle.Draw(spriteBatch);
     //Camera 2D
     spriteBatch.Begin(SpriteSortMode.Deferred,
                       null, null, null, null, null,
                       cam.get_transformation(graphicsDevice));
     Tiles.DrawTiles(spriteBatch, Map.Chunks);
     Player1.Draw(spriteBatch);
     spriteBatch.End();
     //EndCamera
     EastAndWest.DrawEaW(spriteBatch);
     if (MapShown == true)
     {
         MapScreen.Draw(spriteBatch);
     }
 }
Example #4
0
        public void ShowContextMenu(TileObject tile)
        {
            if (Desktop.ContextMenu != null)
            {
                // Dont show if it's already shown
                return;
            }

            var container = new VerticalStackPanel
            {
                Spacing = 4
            };

            var titleContainer = new Panel
            {
                Background = DefaultAssets.UITextureRegionAtlas["button"],
            };

            var titleLabel = new Label
            {
                Text = "Choose Option",
                HorizontalAlignment = HorizontalAlignment.Center
            };

            titleContainer.Widgets.Add(titleLabel);
            container.Widgets.Add(titleContainer);

            var menuItem1 = new MenuItem();

            menuItem1.Text      = "Change levelDepth";
            menuItem1.Selected += (s, a) =>
            {
                // "Start New Game" selected
                //  mapMenuComponent.ShowGridResizingMenu();
            };

            var rotateAction = new MenuItem();

            rotateAction.Text      = "Rotate";
            rotateAction.Selected += (s, a) =>
            {
                // "Start New Game" selected
                //  mapMenuComponent.ShowGridResizingMenu();
                tile.isRotated = true;
                if (tile.rotationAngle == MathHelper.Pi * 2)
                {
                    tile.rotationAngle = 0;
                }
                else
                {
                    tile.rotationAngle += MathHelper.PiOver2;
                }
            };


            var menuItem2 = new MenuItem();

            menuItem2.Text      = "Options";
            menuItem2.Selected += (s, a) =>
            {
                tilePropertiesWindow = new TilePropertiesWindow(tile);
                tilePropertiesWindow.CenterOnDesktop();
                tilePropertiesWindow.Show();
                // "Start New Game" selected
            };



            var menuItem3 = new MenuItem();

            menuItem3.Text = "Quit";

            var verticalMenu = new VerticalMenu();

            if (game.isTileClicked(Desktop.TouchPosition.X, Desktop.TouchPosition.Y))
            {
                verticalMenu.Items.Add(menuItem1);
                verticalMenu.Items.Add(menuItem2);
                verticalMenu.Items.Add(menuItem3);
                verticalMenu.Items.Add(rotateAction);
            }
            else
            {
                verticalMenu.Items.Add(menuItem3);
            }
            container.Widgets.Add(verticalMenu);

            var mouseState    = Mouse.GetState();
            var mousePosition = new Point(mouseState.X, mouseState.Y);

            //Vector2 worldPosition = Vector2.Transform(new Vector2(mouseState.X,mouseState.Y), Matrix.Invert(camera._transform));
            Microsoft.Xna.Framework.Vector2 worldPosition = Microsoft.Xna.Framework.Vector2.Transform(new Microsoft.Xna.Framework.Vector2(mouseState.X, mouseState.Y), Matrix.Invert(camera.get_transformation(graphicsDevice)));
            Desktop.ShowContextMenu(container, Desktop.TouchPosition);
        }
Example #5
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            cam.Pos  = new Vector2(MathHelper.Lerp(cam.Pos.X, p.x, 0.08f), MathHelper.Lerp(cam.Pos.Y, p.y, 0.08f));
            cam.Zoom = 1;

            MouseState m = Mouse.GetState();


            spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, cam.get_transformation(GraphicsDevice));
            for (int y = 0; y < this.map.points.GetLength(1); y++)
            {
                for (int x = 0; x < this.map.points.GetLength(0); x++)
                {
                    for (int z = 0; z < this.map.points.GetLength(2); z++)
                    {
                        if (this.map.points[x, y, z] != null)
                        {
                            ITile tile  = this.map.points[x, y, z];
                            int   baseX = this.map.points.GetLength(0) * 8;
                            int   baseY = this.map.points.GetLength(1) / 2;
                            spriteBatch.Draw(this.textures[tile.tileTexture], new Rectangle(baseX + ((x - z) * (32 / 2)), baseY + (((x + z) * (32 / 4)) - ((32 / 2) * (y))), tile.width, tile.height), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, y / ((float)this.map.points.GetLength(1)));
                        }
                    }
                }
            }
            spriteBatch.Draw(this.textures["G2M"], new Vector2(this.p.x, this.p.y), null, Color.White);

            Texture2D rect = new Texture2D(graphics.GraphicsDevice, 1, 1);

            rect.SetData(new[] { Color.Red });

            spriteBatch.Draw(rect, new Rectangle(10, 10, 10, 10), Color.White);

            spriteBatch.End();

            base.Draw(gameTime);
        }
Example #6
0
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, null, null, null, null, camera.get_transformation(screenManager.GraphicsDevice));

            //spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend);

            //SpriteFont spriteFont = content.Load<SpriteFont>(@"Menu\menufont");
            //spriteBatch.DrawString(spriteFont, "TESTTESTTEST", new Vector2(100, 100), Color.White);
            //spriteBatch.Draw(texture, new Rectangle(100,100,1000,1000), Color.White);

            //spriteBatch.Draw(texture, new Rectangle(0, 0, (int)GameMap.TileShift.X, (int)GameMap.TileShift.Y), new Rectangle(152, 379, (int)GameMap.TileShift.X, (int)GameMap.TileShift.Y), Color.White, 0, new Vector2(), SpriteEffects.None, 0);

            GameMap.Draw(gameTime, spriteBatch);
            foreach (Fighter f in Fighters)
            {
                if ((!f.IsAlive && f.isDying) || f.IsAlive)
                {
                    f.Draw(gameTime, spriteBatch);
                }
            }
            foreach (Enemy e in Enemies)
            {
                e.Draw(gameTime, spriteBatch);
            }
            foreach (Missile m in Missiles)
            {
                m.Draw(gameTime, spriteBatch);
            }

            spriteBatch.End();

            SpriteFont font = screenManager.Font;

            // Inicjuje nowego spriteBatcha, żeby interfejs nie przesuwal sie z kamerą
            spriteBatch.Begin();

            GameInterface.Draw(spriteBatch);
            //Vector2 posClick = new Vector2(MouseCord.X - GameInterface.Width - (screenManager.Settings.Resolution.X - GameInterface.Width) / 2 + GameInterface.Width - Fighters[0].position.X, MouseCord.Y - screenManager.Settings.Resolution.Y / 2 - Fighters[0].position.Y);
            Vector2 posClick = new Vector2(MouseCord.X - GameInterface.Width - (screenManager.Settings.Resolution.X - GameInterface.Width) / 2, MouseCord.Y - screenManager.Settings.Resolution.Y / 2);

            posClick += camera.Pos;

            spriteBatch.DrawString(font, (MouseCord.X - GameInterface.Width).ToString() + "," + MouseCord.Y.ToString(), new Vector2(10, 0), Color.Red);
            spriteBatch.DrawString(font, ((int)posClick.X).ToString() + "," + ((int)posClick.Y).ToString(), new Vector2(10, 50), Color.Red);
            spriteBatch.DrawString(font, ((int)Fighters[0].position.X).ToString() + "," + ((int)Fighters[0].position.Y).ToString(), new Vector2(10, 100), Color.Red);

            spriteBatch.DrawString(font, "{" + camera.Pos.GetMapPosition(GameMap).X + "," + camera.Pos.GetMapPosition(GameMap).Y + "}", new Vector2(10, 150), Color.Purple);

            spriteBatch.DrawString(font, "{" + posClick.GetMapPosition(GameMap).X + "," + posClick.GetMapPosition(GameMap).Y + "}", new Vector2(10, 200), Color.Plum);

            spriteBatch.DrawString(font, "{" + Math.Floor(posClick.X * 2 / GameMap.TileShift.X) + "," + Math.Floor(posClick.Y * 2 / GameMap.TileShift.Y) + "}", new Vector2(10, 250), Color.Maroon);

            Vector2 test = new Vector2(47, 3);

            test.GetMapPosition(GameMap);

            spriteBatch.End();
        }