예제 #1
0
        protected override void Initialize()
        {
            //this.IsMouseVisible = true;

            this.graphics.PreferredBackBufferWidth  = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width;
            this.graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height;

            //graphics.ToggleFullScreen();

            whiteSquare = Content.Load <Texture2D>("WhiteSquare");
            font        = Content.Load <SpriteFont>("text");

            inputHandler = InputHandler.Instance;
            mouseTexture = whiteSquare;
            inputHandler.mouseTexture = mouseTexture;

            hoverPlanetErrorText   = whiteSquare;
            hoverPlanetSuccessText = whiteSquare;
            human = new Player(hoverPlanetErrorText, hoverPlanetSuccessText);

            Globals.screenHeight = GraphicsDevice.Viewport.Height;
            Globals.screenWidth  = GraphicsDevice.Viewport.Width;
            Globals.camera       = new Camera(GraphicsDevice.Viewport);
            Globals.camera.CenterOn(new Vector2(Globals.screenWidth / 2, Globals.screenHeight / 2));

            for (int i = 0; i < planetNum; i++)
            {
                Color  randColor = new Color(random.Next(256), random.Next(256), random.Next(256));
                Planet planet    = new Planet(whiteSquare,
                                              random.Next(-Globals.screenWidth / 2, Globals.screenWidth * 3 / 2 - planetSize),
                                              //+30 for height of HeaderBar
                                              random.Next(-Globals.screenHeight / 2 + 30, Globals.screenHeight * 3 / 2 - planetSize),
                                              planetSize, planetSize, randColor, i.ToString());
                planets.Add(planet);
            }

            if (shouldShowFourCornerPlanets)
            {
                Planet topLeft = new Planet(whiteSquare,
                                            -Globals.screenWidth / 2,
                                            //+30 for height of HeaderBar
                                            -Globals.screenHeight / 2 + 30,
                                            planetSize, planetSize, Color.Black, "Top Left");
                Planet topRight = new Planet(whiteSquare,
                                             Globals.screenWidth * 3 / 2 - planetSize,
                                             //+30 for height of HeaderBar
                                             -Globals.screenHeight / 2 + 30,
                                             planetSize, planetSize, Color.Black, "Top Right");
                Planet bottomLeft = new Planet(whiteSquare,
                                               -Globals.screenWidth / 2,
                                               Globals.screenHeight * 3 / 2 - planetSize,
                                               planetSize, planetSize, Color.Black, "Bottom Left");
                Planet bottomRight = new Planet(whiteSquare,
                                                Globals.screenWidth * 3 / 2 - planetSize,
                                                Globals.screenHeight * 3 / 2 - planetSize,
                                                planetSize, planetSize, Color.Black, "Bottom Right");

                planets.Add(topLeft);
                planets.Add(topRight);
                planets.Add(bottomLeft);
                planets.Add(bottomRight);
            }

            ModalUtil.init();
            PlanetUtil.init(ref planets);
            DrawUtil.init(whiteSquare);

            HeaderBar.init(human, whiteSquare, font);
            headerBar = HeaderBar.Instance;

            BaseInfo.init(whiteSquare, font);

            base.Initialize();
        }