示例#1
0
        public static void Window_ClientSizeChanged(object sender, EventArgs e)
        {
            if (Game1.Game1Self.Window.ClientBounds.Size.X >= Game1.Game1Self.Window.ClientBounds.Size.Y * (Globals.WinRenderSize.X / Globals.WinRenderSize.Y))
            {
                Horizontal = true;
            }
            else
            {
                Horizontal = false;
            }

            if (Horizontal)
            {
                Winsize.Y = Game1.Game1Self.Window.ClientBounds.Size.Y;
                Winsize.X = (int)(Winsize.Y * (WinRenderSize.X / WinRenderSize.Y));
            }
            else
            {
                Winsize.X = Game1.Game1Self.Window.ClientBounds.Size.X;
                Winsize.Y = (int)(Winsize.X / (WinRenderSize.X / WinRenderSize.Y));
            }

            if (Horizontal)
            {
                WinOffset.X = Game1.Game1Self.Window.ClientBounds.Width / 2 - Winsize.X / 2;
                WinOffset.Y = 0;
            }
            else
            {
                WinOffset.Y = Game1.Game1Self.Window.ClientBounds.Height / 2 - Winsize.Y / 2;
                WinOffset.X = 0;
            }

            Game1.GraphicsGlobal.PreferredBackBufferWidth  = Winsize.X;
            Game1.GraphicsGlobal.PreferredBackBufferHeight = Winsize.Y;

            ScreenRatio = new Vector2(Winsize.X, Winsize.Y) / new Vector2(WinRenderSize.X, WinRenderSize.Y);

            Camera2DEditor.MoveBy(Vector2.Zero);

            if (Game1.GraphicsGlobal.IsFullScreen == false)
            {
                Game1.STP.WindowSizeWindowed = new Point(Game1.Game1Self.Window.ClientBounds.Size.X, Game1.Game1Self.Window.ClientBounds.Size.Y);
                Game1.STP.Save();
            }
        }
示例#2
0
        public static void Update()
        {
            if (Game1.EditorMenuOpen == true)
            {
                EditorMenu.Update();
            }
            else
            {
                if (MouseInput.MouseStateOld.LeftButton == ButtonState.Pressed)
                {
                    if (UIDrawing.Instance.Tiles.SelectedIndex != null || UIDrawing.Instance.TilesPhysics.SelectedIndex != null)
                    {
                        DrawOnBackground(SelectedEditTile);
                    }
                }
                if (MouseInput.MouseStateNew.MiddleButton == ButtonState.Pressed)
                {
                    Camera2DEditor.MoveBy(MouseInput.MouseStateNew.Position.ToVector2() - MouseInput.MouseStateOld.Position.ToVector2());
                }
                if (MouseInput.MouseStateOld.RightButton == ButtonState.Pressed)
                {
                    DrawOnBackground("_blank_");
                }
                if (MouseInput.MouseClickedLeft() == true)
                {
                    if (UIEntities.Instance.Entities.SelectedIndex != null)
                    {
                        if (UIEntities.Instance.Entities.SelectedIndex == 0)
                        {
                            AddPlayer(new Vector2(MouseInput.MousePositionRealGrid().X, MouseInput.MousePositionRealGrid().Y - (62 * 2)));
                        }
                        if (UIEntities.Instance.Entities.SelectedIndex == 1)
                        {
                            AddEntity(new Vector2(MouseInput.MousePositionRealGrid().X, MouseInput.MousePositionRealGrid().Y - (194)));
                        }
                    }
                }
            }

            if (KeyboardInput.KeyboardStateNew.IsKeyUp(Keys.Tab) && KeyboardInput.KeyboardStateOld.IsKeyDown(Keys.Tab))
            {
                Game1.EditorMenuOpen = !Game1.EditorMenuOpen;
            }
        }
示例#3
0
        public void DrawLights()
        {
            Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp, transformMatrix: Camera2DEditor.GetViewMatrix());

            foreach (IProjectile prjctl in MapProjectiles)
            {
                prjctl.DrawLight();
            }

            foreach (ITriggers trgr in mapTriggers)
            {
                trgr.DrawLight();
            }

            foreach (IEffect lght in mapLightings)
            {
                lght.DrawLight();
            }

            foreach (IDecoration dcr in mapDecorations)
            {
                dcr.DrawLight();
            }

            foreach (IParticle prtcl in mapParticles)
            {
                prtcl.DrawLight();
            }

            foreach (IPickable pck in mapPickables)
            {
                pck.DrawLight();
            }

            Game1.SpriteBatchGlobal.End();
        }
示例#4
0
        public static void DrawForeground()
        {
            Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, transformMatrix: Camera2DEditor.GetViewMatrixLayer2());

            foreach (IDecoration dcr in EditMap.mapDecorationsForeground)
            {
                dcr.Draw();
            }

            Game1.SpriteBatchGlobal.End();
        }
示例#5
0
        public static void DrawEditor()
        {
            Game1.GraphicsGlobal.GraphicsDevice.SetRenderTargets(Game1.EditorBackground);
            Game1.SpriteBatchGlobal.Begin(samplerState: SamplerState.PointWrap, blendState: BlendState.AlphaBlend, sortMode: SpriteSortMode.Immediate, transformMatrix: Camera2DEditor.GetViewMatrix());
            Game1.SpriteBatchGlobal.Draw(Game1.Textures["BackgroundEditor"], Vector2.Zero, sourceRectangle: new Rectangle(0, 0, (int)Editor.EditMap.MapBoundary.Size.X, (int)Editor.EditMap.MapBoundary.Size.Y));

            Editor.EditMap.Draw();

            Editor.DrawEntityCursor();

            Game1.SpriteBatchGlobal.End();

            Game1.SpriteBatchGlobal.Begin();
            foreach (UIInformer info in Game1.InfoList.Reverse <UIInformer>())
            {
                info.Position = new Vector2(8, Game1.InfoList.IndexOf(info) * 32 + 8);
                info.Draw();
            }
            Game1.SpriteBatchGlobal.End();
        }