Ejemplo n.º 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

            base.Initialize();

            this.IsMouseVisible = true;

            // Create the map.
            map = new Tile[MapX, MapY];

            // Create the camera.
            Camera = new Camera();

            // Initialize the camera viewport
            Camera.ViewportWidth = graphics.GraphicsDevice.Viewport.Width;
            Camera.ViewportHeight = graphics.GraphicsDevice.Viewport.Height;

            _RenderTarget = new RenderTarget2D(
                GraphicsDevice,
                MapX * TileSize,
                MapY * TileSize,
                false,
                GraphicsDevice.PresentationParameters.BackBufferFormat,
                DepthFormat.Depth24);

            Camera.CenterOn(new Vector2(100, 100));

            for (int x = 0; x < MapX; x++)
            {
                for (int y = 0; y < MapY; y++)
                {
                    if (y == 1 && x != 0 && x != MapX-1)
                    {
                        map[x, y] = new Tile(x, y, true, 2);
                    }
                    else if (y == 0 || x == 0 || y == MapY-1 || x == MapX-1)
                    {
                        map[x, y] = new Tile(x, y, true, 1);
                    }
                    else
                    {
                        map[x, y] = new Tile(x, y, false, 0);
                    }
                }

                testUnit = new Unit();
                testUnit.Initialize(2, 2);
                testUnit.Move(4, 4);
            }
        }
Ejemplo n.º 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);
        }