Exemple #1
0
 public MenuFactory(Camera camera, MenuContainer menuContainer, Renderer renderer, Program program, TextureAtlases textureAtlases, FontContainer fontContainer)
 {
     this.menuContainer  = menuContainer;
     this.renderer       = renderer;
     this.program        = program;
     this.fontContainer  = fontContainer;
     this.textureAtlases = textureAtlases;
     this.camera         = camera;
 }
Exemple #2
0
 public Renderer(RenderWindow window, MenuContainer menuContainer, Texture guiElements)
 {
     this.menuContainer = menuContainer;
     GUI           = new RenderTexture(window.Size.X, window.Size.Y);
     guiState      = new RenderStates(guiElements);
     lightingBatch = new SpriteBatch(window, BlendMode.Multiply);
     entityBatch   = new SpriteBatch[(int)Drawable.DrawLayer.IconOverlay];
     for (int i = 0; i < entityBatch.Length; i++)
     {
         entityBatch[i] = new SpriteBatch(window, BlendMode.Alpha);
     }
 }
Exemple #3
0
        public void InitializeResources()
        {
            //Loading text/splashscreen loading
            Image   icon           = new Image("Graphics/GUI/EngineeringCorpsIcon.png");
            Texture loadingTexture = new Texture(icon);
            Sprite  loadingTitle   = new Sprite(loadingTexture);
            Font    loadingFont    = new Font("Fonts/SairaRegular.ttf");
            Text    loadingText    = new Text("", loadingFont);

            loadingText.DisplayedString = "Constructing Texture Atlases...";
            loadingText.Origin          = new Vector2f(loadingText.GetGlobalBounds().Width / 2, loadingText.GetGlobalBounds().Height / 2);
            loadingText.Position        = new Vector2f(window.Size.X / 2, window.Size.Y / 2);
            loadingTitle.Origin         = new Vector2f(loadingTexture.Size.X / 2, loadingTexture.Size.Y / 2);
            loadingTitle.Position       = new Vector2f(window.Size.X / 2, window.Size.Y / 4);

            //Loading textures
            window.Clear(Color.Black);
            window.Draw(loadingTitle);
            window.Draw(loadingText);
            window.Display();
            textureAtlases = new TextureAtlases();
            textureAtlases.LoadTextures(Props.packTogether);

            //Loading fonts
            loadingText.DisplayedString = "Loading Fonts...";
            loadingText.Origin          = new Vector2f(loadingText.GetGlobalBounds().Width / 2, loadingText.GetGlobalBounds().Height / 2);
            window.Clear(Color.Black);
            window.Draw(loadingTitle);
            window.Draw(loadingText);
            window.Display();
            fontContainer = new FontContainer();
            fontContainer.LoadFonts();

            //Initializing Input
            //TODO: Investigate this cyclic couple of the menu system and input.  Input definitely needs access to menufactory.  Menucontainer may not need access to input.
            loadingText.DisplayedString = "Initializing Input...";
            loadingText.Origin          = new Vector2f(loadingText.GetGlobalBounds().Width / 2, loadingText.GetGlobalBounds().Height / 2);
            window.Clear(Color.Black);
            window.Draw(loadingTitle);
            window.Draw(loadingText);
            window.Display();
            input = new InputManager(window);

            //Initializing Rendering systems
            loadingText.DisplayedString = "Initializing Rendering...";
            loadingText.Origin          = new Vector2f(loadingText.GetGlobalBounds().Width / 2, loadingText.GetGlobalBounds().Height / 2);
            window.Clear(Color.Black);
            window.Draw(loadingTitle);
            window.Draw(loadingText);
            window.Display();
            menuContainer = new MenuContainer(input);
            camera        = new Camera();
            camera.SubscribeToInput(input);
            renderer            = new Renderer(window, menuContainer, textureAtlases.GetTexture("guiTilesheet", out _));
            menuFactory         = new MenuFactory(camera, menuContainer, renderer, this, textureAtlases, fontContainer);
            window.Resized     += camera.HandleResize;
            window.Resized     += renderer.HandleResize;
            window.Resized     += menuContainer.RepositionMenus;
            input.menuFactory   = menuFactory;
            input.menuContainer = menuContainer;

            //Loading prototypes
            loadingText.DisplayedString = "Initializing Collections...";
            loadingText.Origin          = new Vector2f(loadingText.GetGlobalBounds().Width / 2, loadingText.GetGlobalBounds().Height / 2);
            window.Clear(Color.Black);
            window.Draw(loadingTitle);
            window.Draw(loadingText);
            window.Display();
            Dictionary <System.Type, UpdateProperties> updateOrder = new Dictionary <Type, UpdateProperties>();

            updateOrder.Add(typeof(Machine), new UpdateProperties(typeof(Machine), 1, false));
            updateOrder.Add(typeof(Tree), new UpdateProperties(typeof(Tree), 600, false));
            updateOrder.Add(typeof(Resource), new UpdateProperties(typeof(Resource), 0, true));
            updateOrder.Add(typeof(Player), new UpdateProperties(typeof(Player), 1, false));
            entityUpdateSystem = new EntityUpdateSystem(updateOrder);
            tileCollection     = new TileCollection(textureAtlases);
            entityCollection   = new EntityCollection(textureAtlases, entityUpdateSystem);
            itemCollection     = new ItemCollection(textureAtlases);
            entityCollection.LoadPrototypes(itemCollection);
            recipeCollection = new RecipeCollection(textureAtlases);
            recipeCollection.LoadRecipes();
            input.entityCollection = entityCollection;
            input.itemCollection   = itemCollection;
            input.recipeCollection = recipeCollection;
        }