示例#1
0
        protected override void Update(GameTime gameTime)
        {
            if (!exiting)
            {
                if (!paused && !loading)
                {
                    centre = overviewScreen.centre;
                    if (currentscreen != titlescreen)
                    {
                        zoom = overviewScreen.zoom;
                    }

                    if (currentscreen == menuscreen)
                    {
                        menuscreen.Update(gameTime, Window, GraphicsDevice);
                        DGUI.UpdateMouse();
                    }

                    if (currentscreen == overviewScreen)
                    {
                        zoom = (float)DGUI.zoom;
                        centre = DGUI.centre;
                        overviewScreen.mousePosition = Vector2.Transform(DGUI.mousePosition, camera.transformMouse);
                        overviewScreen.Update(gameTime, centre, zoom, DGUI.mouseOverHUD);
                    }
                    else
                    {
                        currentscreen.Update(gameTime);
                    }
                    camera.Update(gameTime, centre, zoom, account.SaveData.MapSize);
                }

                if (currentscreen == overviewScreen)
                {
                    centre = overviewScreen.centre;
                    zoom = overviewScreen.zoom;
                    DGUI.UpdateMouse();
                    DGUI.Update(gameTime, account.SaveData, this,
                        overviewScreen.HumanPlayer.resources, overviewScreen,
                        overviewScreen.elapsedHours, overviewScreen.elapsedDays);
                }
              
                #region if loading 

                if (loading)
                {
                    loadingScreen.Update(gameTime);
                    if (loadingScreen.fadedIn)
                    {
                        if (!loadingScreen.loaded)
                        {
                            if (!loadingScreen.startedLoading)
                            {
                                LoadingScreenLoadontent();
                            }
                        }
                        else
                        {
                            switch (ToChange)
                            {
                                case 1:
                                    currentscreen = menuscreen;
                                    break;
                                case 2:                                   
                                    currentscreen = overviewScreen;
                                    break;
                            }
                            loading = false;
                        }
                    }

                    if (needEndLoading)
                    {
                        if (currentscreen == overviewScreen)
                        {
                            overviewScreen.LoadMainThreadContent();
                        }
                        loadingScreen.End();
                        needEndLoading = false;
                    }
                }
                #endregion


                Window.ClientSizeChanged += Window_ClientSizeChanged;
                if (exiting)
                {
                    Exiting();
                }

            }

            FramesCounter.Update(gameTime);

            //extraGame.Update(gameTime.ElapsedGameTime);

            base.Update(gameTime);
        }
示例#2
0
        protected override void LoadContent()
        {
            rectangledraw = Content.Load<Texture2D>("white");

            account = new Account();
            spriteBatch = new SpriteBatch(GraphicsDevice);
            spriteBatch2 = new SpriteBatch(GraphicsDevice);
            sf = Content.Load<SpriteFont>("Segoe_UI_9_Regular");
            glowEffect = Content.Load<Effect>("effect1");
            //glowEffect.CurrentTechnique.Passes[0].Apply();


            titlescreen = new Title(this.Content, new System.EventHandler(TitleScreenEvent));

            menuscreen = new Menu(this, graphics, this.Content,
                new System.EventHandler(MenuScreenEvent), account, GraphicsDevice,
                new System.EventHandler(ExitGamePressed));

            overviewScreen = new Overview(this.graphics, this.Content,
                new System.EventHandler(OverviewEscapeToMenu), new System.EventHandler(gamePaused),
                account, new Vector2(0, 0), new EventHandler(SystemSelected), new EventHandler(DayPassed),
                new EventHandler(SystemHovered), new EventHandler(RemoveSystemHovered),
                new EventHandler(UpdateBuildQueue), new EventHandler(UpdatePlanetResources),
                GraphicsDevice, spriteBatch);

            loadingScreen = new Loading(Content, graphics);
            camera = new Camera(GraphicsDevice.Viewport);

            DGUI = new GUIManager(graphics, Content, new EventHandler(ExitGamePressed),
                new EventHandler(OverviewEscapeToMenu), new EventHandler(SaveGamePressed),
                new EventHandler(LoadGamePressed), new EventHandler(overviewScreen.Button1Pressed),
                new EventHandler(ZoomIn), new EventHandler(overviewScreen.ZoomOut),
                new EventHandler(gamePaused), new EventHandler(planetHighlighted),
                new EventHandler(PlanetslistToggled), new EventHandler(SectorChanged),
                new EventHandler(PlanetInfoPressed), account.SaveData,
                new EventHandler(MapSystemSelected), new EventHandler(JumpToSystem),
                new EventHandler(JumpToPlanet), new EventHandler(TaxRateChanged),
                new EventHandler(GameSpeedChanged), new EventHandler(BuildingUpgraded),
                new EventHandler(BuildingDismantled), new EventHandler(AddBuildQueueItem),
                new EventHandler(RemoveBuildQueueItem), GraphicsDevice);

            //account.SaveData.Score = 6;
            //account.SaveData.MapSize = new Vector2(2000, 2000);
            currentscreen = titlescreen; // <= SETTING FIRST SCREEN TO BE SHOWN
                                         //overviewScreen.LoadContent(account, gameDetails);
                                         //DGUI.Init(this, new Point(0,0));
                                         //DGUI.StartKeyBindings();
                                         // REMOVE WHEN REVERTING BACK TO TITLE SCREEN FIRST ^^

            centre.X = 0;
            centre.Y = 0;
            zoom = 1.0f;

            FramesCounter = new FPSCounter(this, spriteBatch, sf);
        }