public Scene createScene()
        {
            bool sceneCreated = false;

            //GUI
            Gui SC_gui = new Gui(window);

            mainPanel.Renderer.BackgroundColor = Color.Black;
            mainPanel.Renderer.BorderColor     = Color.White;
            mainPanel.PositionLayout           = new Layout2d("2.5%", "5%");
            mainPanel.SizeLayout       = new Layout2d("95%", "90%");
            mainPanel.Renderer.Borders = new Outline(5, 5, 5, 5);

            Button createButton = new Button("CREATE");

            createButton.Clicked       += (e, a) => { sceneCreated = true; };
            createButton.PositionLayout = new Layout2d("80%", "90%");

            mainPanel.Add(createButton);
            SC_gui.Add(mainPanel);


            //SIMULATIONS GUI
            Panel simulationsPanel = new Panel();

            simulationsPanel.Renderer.BackgroundColor = Color.Black;
            simulationsPanel.Renderer.BorderColor     = Color.White;
            simulationsPanel.PositionLayout           = new Layout2d("3%", "5%");
            simulationsPanel.SizeLayout       = new Layout2d("25%", "80%");
            simulationsPanel.Renderer.Borders = new Outline(2, 2, 2, 2);

            Panel AddedSimuationsPanel = new Panel(simulationsPanel);

            AddedSimuationsPanel.PositionLayout = new Layout2d("73%", "5%");

            //origin widgets
            originPanel.Renderer.BackgroundColor = Color.Black;
            originPanel.Renderer.BorderColor     = Color.White;
            originPanel.PositionLayout           = new Layout2d("30.5%", "5%");
            originPanel.SizeLayout       = new Layout2d("40%", "80%");
            originPanel.Renderer.Borders = new Outline(2, 2, 2, 2);

            originLabel = new Label();
            originLabel.Renderer.TextColor = Color.White;

            Label SimulationsNote = new Label("Simulations: ");

            SimulationsNote.Renderer       = originLabel.Renderer;
            SimulationsNote.PositionLayout = new Layout2d("3%", "1%");
            Label AddedSimulationsNote = new Label("Added: ");

            AddedSimulationsNote.Renderer       = originLabel.Renderer;
            AddedSimulationsNote.PositionLayout = new Layout2d("73%", "1%");

            mainPanel.Add(SimulationsNote);
            mainPanel.Add(AddedSimulationsNote);
            mainPanel.Add(simulationsPanel);
            mainPanel.Add(AddedSimuationsPanel);


            /////LAYER CREATING/////////
            image = Pixy.drawBorder(image);

            RenderObject picture       = new RenderObject(image);
            RenderObject flame_picture = new RenderObject(flame_field);
            RenderObject fire_picture  = new RenderObject(fire_field);

            Layer main_layer  = new Layer(1, "main");
            Layer Fire_layer  = new Layer(2, "fire_layer");
            Layer flame_layer = new Layer(3, "flame_layer");


            scene = new Scene(window);
            main_layer.setLayerRenderObject(picture);
            Fire_layer.setLayerRenderObject(fire_picture);
            flame_layer.setLayerRenderObject(flame_picture);
            scene.AddLayer(main_layer);
            scene.AddLayer(Fire_layer);
            scene.AddLayer(flame_layer);



            //SIMULATION CREATING PANELS
            SandSimulationPanelInit();
            LiquidSimulationPanelInit();
            FireSimulationPanelInit();
            flameSimulationPanelInit();
            lightningSimulationPanelInit();
            rainSimulationPanelInit();

            AddedSimsList            = new ListBox();
            AddedSimsList.SizeLayout = new Layout2d("100%", "100%");
            AddedSimuationsPanel.Add(AddedSimsList);
            ListBox SimulationsList = new ListBox();

            SimulationsList.AddItem("Sand Simulation", "Sand Simulation");
            SimulationsList.AddItem("Liquid Simulation", "Liquid Simulation");
            SimulationsList.AddItem("Fire Simulation", "Fire Simulation");
            SimulationsList.AddItem("Flame Simulation", "Flame Simulation");
            SimulationsList.AddItem("Lightning Simulation", "Lightning Simulation");
            SimulationsList.AddItem("Rain Simulation", "Rain Simulation");
            SimulationsList.ItemSelected += (e, a) =>
            {
                switch (SimulationsList.GetSelectedItemId())
                {
                case ("Sand Simulation"):
                    currentToolPanel.Visible = false;
                    currentToolPanel         = sandSimulationPanel;
                    currentToolPanel.Visible = true;
                    break;

                case ("Liquid Simulation"):
                    currentToolPanel.Visible = false;
                    currentToolPanel         = liquidSimulationPanel;
                    currentToolPanel.Visible = true;
                    break;

                case ("Fire Simulation"):
                    currentToolPanel.Visible = false;
                    currentToolPanel         = fireSimulationPanel;
                    currentToolPanel.Visible = true;
                    break;

                case ("Flame Simulation"):
                    currentToolPanel.Visible = false;
                    currentToolPanel         = flameSimulationPanel;
                    currentToolPanel.Visible = true;
                    break;

                case ("Lightning Simulation"):
                    currentToolPanel.Visible = false;
                    currentToolPanel         = lightningSimulationPanel;
                    currentToolPanel.Visible = true;
                    break;

                case ("Rain Simulation"):
                    currentToolPanel.Visible = false;
                    currentToolPanel         = rainSimulationPanel;
                    currentToolPanel.Visible = true;
                    break;
                }
            };
            simulationsPanel.Add(SimulationsList);

            while (window.IsOpen && !sceneCreated)
            {
                window.DispatchEvents();
                window.Clear(SFML.Graphics.Color.Black);
                //Draw here
                SC_gui.Draw();
                window.Display();
            }

            //Scene created!
            foreach (var obj in simulations)
            {
                scene.AddObject(obj);
            }
            SC_gui.RemoveAllWidgets();
            return(scene);
        }
예제 #2
0
        public void loadScene1()
        {
            //COLORS

            Color sand1      = new Color(252, 235, 145);
            Color emptyP     = new Color(0, 0, 0);
            Color waterP     = new Color(101, 175, 182, 150);
            Color lightning  = new Color(108, 233, 236);
            Color fire       = new Color(191, 106, 2);
            byte  fireoffset = 42;
            Color fireActive = new Color(191, 148, 2);
            Color wood       = new Color(53, 33, 21);
            byte  woodoffset = 29;

            //MAIN__FIELD
            //Image image = new Image("C:/Users/Пользователь/Desktop/SandySharp/SandySharp/FirstScene.png");
            Image image       = new Image(160, 120, Color.Transparent);
            Image flame_field = new Image(160, 120, Color.Transparent);
            Image fire_field  = new Image(160, 120, Color.Transparent);

            image = Pixy.drawBorder(image);

            RenderObject picture       = new RenderObject(image);
            RenderObject flame_picture = new RenderObject(flame_field);
            RenderObject fire_picture  = new RenderObject(fire_field);

            //starts



            //SCENES AND LAYERS
            Scene scene       = new Scene(window);
            Layer main_layer  = new Layer(1, "main");
            Layer Fire_layer  = new Layer(2, "fire_layer");
            Layer flame_layer = new Layer(3, "flame_layer");



            //SIMULATIONS
            SandSimulation      sandSim      = new SandSimulation(sand1, image, "sand_sim");
            LiquidSimulation    liqSim       = new LiquidSimulation(waterP, image, "liquid_sim");
            FireSimulation      fireSim      = new FireSimulation(fire, fireoffset, wood, woodoffset, fire_field, image, waterP, "fire_sim");
            FlameSimulation     flameSim     = new FlameSimulation(fire, fireSim.getActiveFire(), fire_field, flame_field, "flame_sim");
            LightningSimulation lightningSim = new LightningSimulation(lightning, fireSim.getActiveFire(), fire_field, image, "lightning_sim");
            RainSimulation      rainSim      = new RainSimulation(waterP, lightning, image, fire_field, 0.1f, 0.08f, "rain_sim");


            scene.AddLayer(main_layer);
            scene.AddLayer(Fire_layer);
            scene.AddLayer(flame_layer);


            scene.AddObject(fireSim);
            scene.AddObject(flameSim);
            scene.AddObject(liqSim);
            scene.AddObject(sandSim);
            //scene.AddObject(lightningSim);
            //scene.AddObject(rainSim);

            main_layer.setLayerRenderObject(picture);
            Fire_layer.setLayerRenderObject(fire_picture);
            flame_layer.setLayerRenderObject(flame_picture);
            scene.initialisation();



            //SYSTEMS INICIALIZATION
            SceneManager.instance().setCurrentScene(scene);
            TimeManager.instance().start();
            ViewSystem.instance().start(picture.sprite);


            BrushManager.instance().start(image);
            BrushManager.instance().AddColor(waterP, "water");
            BrushManager.instance().AddColor(fireSim.getActiveFire(), "fire");
            BrushManager.instance().AddColor(sand1, "sand");
            BrushManager.instance().AddColor(wood, "wood");

            UI_SYSTEM.instance().start();

            //testPHYSICS
        }