コード例 #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            IsMouseVisible           = true;
            Window.AllowUserResizing = true;
            if (!graphics.IsFullScreen)
            {
                graphics.PreferredBackBufferWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
                graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;
                //graphics.ToggleFullScreen();
            }

            Window.ClientSizeChanged += new EventHandler <EventArgs>(OnResize);


            // SGBasicEffect.Initialize(GraphicsDevice);
            StaticGlobal.BasicEffect.Initialize(GraphicsDevice);
            StaticGlobal.Screen.Initialize(Window.ClientBounds);
            Render.Initialize();
            Camera.Initialize();

            UIElementHandler.Initialize();

            debugRectangle = new GraphicRectangle(Color.White, 0, 0, 490, 148);

            shadowRectangle = new GraphicRectangle(
                new Color(0, 0, 0, 0.85f),
                0, 0,
                Window.ClientBounds.Width,
                Window.ClientBounds.Height
                );

            base.Initialize();
        }
コード例 #2
0
        public static void Initialize()
        {
            #region Buttons
            body   = new GraphicRectangle(Color.White, 0, 0, 0, 0);
            bottom = new GraphicRectangle(Color.White, 0, 0, 0, 0);

            buttons = new Button[]
            {
                // NULL BUTTON
                new Button
                {
                    Bounds = new Rectangle(-100, -100, 0, 0)
                },

                // Hello
                new Button
                {
                    Bounds = new Rectangle
                    {
                        Width  = 150,
                        Height = 50,
                        X      = 20,
                        Y      = 20
                    },
                    Action = () => Console.WriteLine("Hello")
                },

                // Exit button
                new Button
                {
                    Bounds = new Rectangle
                    {
                        Width  = 100,
                        Height = 100,
                        X      = 200,
                        Y      = 200
                    },
                    Action = () =>
                    {
                        StaticGlobal.SaveModeON = true;
                        StaticGlobal.Shutdown();
                    }
                },

                // Just cause
                new Button
                {
                    Bounds = new Rectangle
                    {
                        Width  = 50,
                        Height = 50,
                        X      = StaticGlobal.Screen.Area.Width - 100,
                        Y      = 100
                    },
                    Action = () =>
                    {
                        Camera.FreeCam  = false;
                        Camera.Position = new Vector2(int.MaxValue, int.MinValue);
                    }
                }
            };
            #endregion Buttons

            #region Select Outline
            vertices            = new VertexPositionColor[10];
            selectedButtonIndex = 0;

            for (int i = 0; i < vertices.Length; i++)
            {
                vertices[i].Color = Color.DodgerBlue;
            }
            #endregion Select Outline
        }