Example #1
0
 public QuestionGameObject(Renderer3D renderer, List <CollidableGameObject> collidableObjects, Question question)
     : base(renderer, collidableObjects)
 {
     this.question           = question;
     this.currentAnswerIndex = 0;
     this.maxFakeSpawnCount  = 1;
     this.minAnswerDistance  = 3;
     this.bonusChance        = 0.75f;
     CreateAnswers();
 }
Example #2
0
        public Answer(Renderer3D renderer, IEnumerable <CollidableGameObject> collidableObjects, string text)
            : base(renderer, collidableObjects)
        {
            this.text = text;
            //"gravidade"
            VariableMovementComponent vmc =
                new VariableMovementComponent(this, 30,
                                              Vector3.Down / 1000 * (float)PublicRandom.NextDouble(0.01f),
                                              Vector3.Down / 100);

            vmc.LowerVelocityThreshold = Vector3.Down / 4;
            addComponent(vmc);
        }
Example #3
0
 /// <summary>
 /// Provides specialized functionality for a visual (3D) Doom Builder editing mode.
 /// </summary>
 public VisualMode()
 {
     // Initialize
     this.renderer        = General.Map.Renderer3D;
     this.renderer3d      = (Renderer3D)General.Map.Renderer3D;
     this.blockmap        = new VisualBlockMap();
     this.allsectors      = new Dictionary <Sector, VisualSector>(General.Map.Map.Sectors.Count);
     this.allthings       = new Dictionary <Thing, VisualThing>(General.Map.Map.Things.Count);
     this.visibleblocks   = new List <VisualBlockEntry>();
     this.visiblesectors  = new Dictionary <Sector, VisualSector>(50);
     this.visiblegeometry = new List <VisualGeometry>(200);
     this.visiblethings   = new List <VisualThing>(100);
     this.processgeometry = true;
     this.processthings   = true;
 }
Example #4
0
        void initGraph()
        {
            uiSplit.Dock = DockStyle.Fill;
            mRenderer3D  = new Renderer3D();
            uiSplit.Panel2.Controls.Add(mRenderer3D);
            mRenderer3D.Dock = DockStyle.Fill;

            //init surface
            initSurface();

            // Create the chart and embed the surface within
            mChart = new Chart(mRenderer3D, Quality.Nicest);
            mChart.Scene.Graph.Add(mSurface);
            mAxeLayout = mChart.AxeLayout;
            mChart.Scene.Views.First().BackgroundColor = Color.BLACK;
            mAxeLayout.MainColor = Color.WHITE;

            DisplayXTicks     = true;
            DisplayXAxisLabel = true;
            DisplayYTicks     = true;
            DisplayYAxisLabel = true;
            DisplayZTicks     = false;
            DisplayZAxisLabel = false;

            DisplayTickLines = true;

            // Create a mouse control
            CameraMouseController mouse = new CameraMouseController();

            mouse.addControllerEventListener(mRenderer3D);
            mChart.addController(mouse);

            // This is just to ensure code is reentrant (used when code is not in Form_Load but another reentrant event)
            disposeBackgroundThread();

            // Create a thread to control the camera based on mouse movements
            mCamera = new CameraThreadController();
            mCamera.addControllerEventListener(mRenderer3D);
            mouse.addSlaveThreadController(mCamera);
            mChart.addController(mCamera);
            //mCamera.Start();

            // Associate the chart with current control
            mRenderer3D.setView(mChart.View);
        }
        public static Answer CreateAnswer(Renderer3D r3D, IEnumerable <CollidableGameObject> collidableObjects, Question q, int answerIndex, bool correct, Answer[] otherAnswers = null)
        {
            Answer a;

            switch (q.Subject)
            {
            case QuestionSubject.MAT:
                a = new Answer(r3D, collidableObjects, CreateMathAnswer(q, answerIndex, otherAnswers, correct));
                break;

            default:
                a = new Answer(r3D, collidableObjects, CreatePTAnswer(q, answerIndex, otherAnswers, correct));

                break;
            }

            return(a);
        }
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            // MVVM made simple : DataContext is current object
            this.DataContext = this;

            // Create the interop host control.
            System.Windows.Forms.Integration.WindowsFormsHost fromHost =
                new System.Windows.Forms.Integration.WindowsFormsHost();

            //// Create the Renderer 3D control.
            Renderer3D renderer = new Renderer3D();

            // Assign the Renderer 3D control as the host control's child.
            fromHost.Child = renderer;
            gridContent.Children.Add(fromHost);

            // Create the chart and embed the surface within
            dataChart = new nzy3D.Chart.Chart(renderer, Quality.Nicest);
            axeLayout = dataChart.AxeLayout;

            // Create a mouse control
            nzy3D.Chart.Controllers.Mouse.Camera.CameraMouseController mouse = new nzy3D.Chart.Controllers.Mouse.Camera.CameraMouseController();
            mouse.addControllerEventListener(renderer);
            dataChart.addController(mouse);

            // This is just to ensure code is reentrant (used when code is not in Form_Load but another reentrant event)
            DisposeBackgroundThread();

            // Create a thread to control the camera based on mouse movements
            threadController = new nzy3D.Chart.Controllers.Thread.Camera.CameraThreadController();
            threadController.addControllerEventListener(renderer);
            mouse.addSlaveThreadController(threadController);
            dataChart.addController(threadController);
            //threadController.Start();

            // Associate the chart with current control
            renderer.setView(dataChart.View);
        }
Example #7
0
        // initalize   load    update                                    Draw                                             dispose
        //{‾‾‾‾‾‾‾‾‾‾}{‾‾‾‾‾‾}{‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾}{‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾}{‾‾‾‾‾‾‾‾‾‾}
        //Initalize -> Load -> update -> physics step -> late update -> prerender -> render -> pre uirender -> ui render |-> destroy


        /// <summary>
        /// Constructor of Game
        /// </summary>
        /// <param name="inputParamaters">Packet of startup info </param>
        /// <param name="audio">Audio manager instance</param>
        /// <param name="content">Content manager instance</param>
        /// <param name="ui">Ui manager instance</param>
        /// <param name="level"> Level manager instance</param>
        /// <param name="rend3d">3D Renderer instance</param>
        /// <param name="rend2d">2D (UI Primarilly) Renderer instance </param>
        public Application(GameParams inputParamaters, Manager audio, Manager content, UIManager ui, LevelManager level, Renderer3D rend3d, Renderer2D rend2d)
        {
            GraphicsManager = new GraphicsDeviceManager(this);
            Graphics        = GraphicsManager.GraphicsDevice;

            GraphicsManager.PreferredBackBufferWidth  = inputParamaters.WindowWidth;
            GraphicsManager.PreferredBackBufferHeight = inputParamaters.WindowHeight;
            GraphicsManager.IsFullScreen        = inputParamaters.IsFullScreen;
            GraphicsManager.PreferMultiSampling = inputParamaters.PreferMultisampling;

            if (inputParamaters.Rasterizer != null)
            {
                Graphics.RasterizerState = inputParamaters.Rasterizer;
            }

            Content = content;
            Audio   = audio;
            UI      = ui;
            Level   = level;

            GeneralRenderer = rend3d;
            UiRenderer      = rend2d;
        }
Example #8
0
 public override void Initalize(Renderer pair)
 {
     GenRendLink = (Renderer3D)pair;
 }
        public static QuestionGameObject CreateQuestion(RunnerLevel level, QuestionSubject subject, Renderer3D renderer, List <CollidableGameObject> collidableObjects, List <QuestionGameObject> existingQuestions)
        {
            Question q = null;

            switch (subject)
            {
            case (QuestionSubject.PT):
                q = GenerateQuestion((int)level, existingQuestions, QuestionsDatabase.PT_Questions);
                break;

            default:
                q = GenerateQuestion((int)level, existingQuestions, QuestionsDatabase.MAT_Questions);
                break;
            }
            return(new QuestionGameObject(renderer, collidableObjects, q));
        }
Example #10
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            // MVVM made simple : DataContext is current object
            this.DataContext = this;

            // Create the interop host control.
            System.Windows.Forms.Integration.WindowsFormsHost host =
                new System.Windows.Forms.Integration.WindowsFormsHost();

            // Create the Renderer 3D control.
            Renderer3D renderer = new Renderer3D();

            // Assign the Renderer 3D control as the host control's child.
            host.Child = renderer;

            // Add the interop host control to the Grid
            // control's collection of child controls.
            this.MainGrid.Children.Add(host);

            // Create a range for the graph generation
            Range range = new Range(-150, 150);
            int   steps = 50;

            // Build a nice surface to display with cool alpha colors
            // (alpha 0.8 for surface color and 0.5 for wireframe)
            Shape surface = Builder.buildOrthonomal(new OrthonormalGrid(range, steps, range, steps), new MyMapper());

            surface.ColorMapper        = new ColorMapper(new ColorMapRainbow(), surface.Bounds.zmin, surface.Bounds.zmax, new Color(1, 1, 1, 0.8));
            surface.FaceDisplayed      = true;
            surface.WireframeDisplayed = true;
            surface.WireframeColor     = Color.CYAN;
            surface.WireframeColor.mul(new Color(1, 1, 1, 0.5));

            // Create the chart and embed the surface within
            Chart chart = new Chart(renderer, Quality.Nicest);

            chart.Scene.Graph.Add(surface);
            axeLayout         = chart.AxeLayout;
            DisplayXTicks     = true;
            DisplayXAxisLabel = true;
            DisplayYTicks     = true;
            DisplayYAxisLabel = true;
            DisplayZTicks     = true;
            DisplayZAxisLabel = true;
            DisplayTickLines  = true;

            // Create a mouse control
            nzy3D.Chart.Controllers.Mouse.Camera.CameraMouseController mouse = new nzy3D.Chart.Controllers.Mouse.Camera.CameraMouseController();
            mouse.addControllerEventListener(renderer);
            chart.addController(mouse);

            // This is just to ensure code is reentrant (used when code is not in Form_Load but another reentrant event)
            DisposeBackgroundThread();

            // Create a thread to control the camera based on mouse movements
            t = new nzy3D.Chart.Controllers.Thread.Camera.CameraThreadController();
            t.addControllerEventListener(renderer);
            mouse.addSlaveThreadController(t);
            chart.addController(t);
            t.Start();

            // Associate the chart with current control
            renderer.setView(chart.View);
        }
Example #11
0
        // Initializes for an existing map
        internal bool InitializeOpenMap(string filepathname, MapOptions options)
        {
            // Apply settings
            this.filename     = Path.GetFileName(filepathname);
            this.filepathname = filepathname;
            this.filepath     = Path.GetDirectoryName(filepathname);
            this.changed      = false;
            this.options      = options;

            General.WriteLogLine("Opening map \"" + this.filename + "\" with configuration \"" + options.ConfigFile + "\"");

            // Initiate graphics
            General.WriteLogLine("Initializing graphics device...");
            graphics = new D3DDevice(General.MainWindow.Display);
            if (!graphics.Initialize())
            {
                return(false);
            }

            // Create renderers
            renderer2d = new Renderer2D(graphics);
            renderer3d = new Renderer3D(graphics);

            // Load game configuration
            General.WriteLogLine("Loading game configuration...");
            configinfo = General.GetConfigurationInfo(options.ConfigFile);
            config     = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile));
            configinfo.ApplyDefaults(config);
            General.Editing.UpdateCurrentEditModes();

            // Create map data
            bool maprestored = false;             //mxd

            map = new MapSet();

            string mapname = Path.GetFileNameWithoutExtension(filepathname);

            if (!string.IsNullOrEmpty(mapname))
            {
                string hash       = MurmurHash2.Hash(mapname + File.GetLastWriteTime(filepathname)).ToString();
                string backuppath = Path.Combine(General.MapRestorePath, mapname + "." + hash + ".restore");

                // Backup exists and it's newer than the map itself?
                if (File.Exists(backuppath) && File.GetLastWriteTime(backuppath) > File.GetLastWriteTime(filepathname))
                {
                    if (General.ShowWarningMessage("Looks like your previous editing session has gone terribly wrong." + Environment.NewLine
                                                   + "Would you like to restore the map from the backup?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");
                        io = MapSetIO.Create(config.FormatInterface, this);
                        General.WriteLogLine("Restoring map from \"" + backuppath + "\"...");

#if DEBUG
                        // Restore map
                        map.Deserialize(new MemoryStream(File.ReadAllBytes(backuppath)));
#else
                        try
                        {
                            // Restore map
                            map.Deserialize(new MemoryStream(File.ReadAllBytes(backuppath)));

                            // Delete the backup
                            File.Delete(backuppath);
                        }
                        catch (Exception e)
                        {
                            General.ErrorLogger.Add(ErrorType.Error, "Unable to restore the map data structures from the backup. " + e.GetType().Name + ": " + e.Message);
                            General.ShowErrorMessage("Unable to restore the map data structures from the backup.", MessageBoxButtons.OK);
                            return(false);
                        }
#endif
                        maprestored = true;
                    }
                }
            }

            // Read the map from file
            if (!maprestored)
            {
                map.BeginAddRemove();

                General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");
                io = MapSetIO.Create(config.FormatInterface, this);
                General.WriteLogLine("Reading map data structures from file...");

#if !DEBUG
                try
                {
#endif
                using (FileStream stream = File.OpenRead(filepathname))
                {
                    io.Read(map, stream);
                }
#if !DEBUG
            }
            catch (Exception e)
            {
                General.ErrorLogger.Add(ErrorType.Error, "Unable to read the map data structures with the specified configuration. " + e.GetType().Name + ": " + e.Message);
                General.ShowErrorMessage("Unable to read the map data structures with the specified configuration.", MessageBoxButtons.OK);
                return(false);
            }
#endif

                map.EndAddRemove();
            }


            // Load data manager
            General.WriteLogLine("Loading data resources...");
            data = new DataManager();
            data.Load(CreateResourcesList());

            // Remove unused sectors
            map.RemoveUnusedSectors(true);

            // Update structures
            options.ApplyGridSettings();
            map.UpdateConfiguration();
            //map.SnapAllToAccuracy();
            map.Update();
            thingsfilter.Update();

            // Bind any methods
            General.Actions.BindMethods(this);

            // Set defaults
            this.visualcamera = new VisualCamera();
            General.Editing.ChangeMode(configinfo.StartMode);
            renderer2d.SetViewMode((ViewMode)General.Settings.DefaultViewMode);

            // Center map in screen
            if (General.Editing.Mode is ClassicMode)
            {
                (General.Editing.Mode as ClassicMode).CenterInScreen();
            }

            // Success
            this.changed = maprestored;             //mxd
            General.WriteLogLine("Map loading done");
            General.MainWindow.UpdateTitle();       //mxd
            return(true);
        }
Example #12
0
        // Initializes for a new map
        internal bool InitializeNewMap(MapOptions options)
        {
            // Apply settings
            this.filename     = "unnamed.map";
            this.filepathname = string.Empty;
            this.filepath     = string.Empty;
            this.changed      = false;
            this.options      = options;

            General.WriteLogLine("Creating new map with configuration \"" + options.ConfigFile + "\"");

            // Initiate graphics
            General.WriteLogLine("Initializing graphics device...");
            graphics = new D3DDevice(General.MainWindow.Display);
            if (!graphics.Initialize())
            {
                return(false);
            }

            // Create renderers
            renderer2d = new Renderer2D(graphics);
            renderer3d = new Renderer3D(graphics);

            // Load game configuration
            General.WriteLogLine("Loading game configuration...");
            configinfo = General.GetConfigurationInfo(options.ConfigFile);
            config     = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile));
            configinfo.ApplyDefaults(config);
            General.Editing.UpdateCurrentEditModes();

            // Create map data
            map = new MapSet();

            // Initialize map format interface
            General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "...");
            io = MapSetIO.Create(config.FormatInterface, this);

            // Load data manager
            General.WriteLogLine("Loading data resources...");
            data = new DataManager();
            data.Load(CreateResourcesList());

            // Update structures
            options.ApplyGridSettings();
            map.UpdateConfiguration();
            map.Update();
            thingsfilter.Update();

            // Bind any methods
            General.Actions.BindMethods(this);

            // Set defaults
            this.visualcamera = new VisualCamera();
            General.Editing.ChangeMode(configinfo.StartMode);
            ClassicMode cmode = (General.Editing.Mode as ClassicMode);

            if (cmode != null)
            {
                cmode.SetZoom(Rendering.Renderer2D.DEFAULT_ZOOM);
            }
            renderer2d.SetViewMode((ViewMode)General.Settings.DefaultViewMode);

            // Success
            this.changed = false;
            General.WriteLogLine("Map creation done");
            General.MainWindow.UpdateTitle();             //mxd
            return(true);
        }
Example #13
0
        // Disposer
        public void Dispose()
        {
            // Not already disposed?
            if (!isdisposed)
            {
                // Let the plugins know
                General.Plugins.OnMapCloseBegin();

                // Stop processing
                General.MainWindow.StopProcessing();

                // Change to no mode
                General.Editing.ChangeMode((EditMode)null);

                // Unbind any methods
                General.Actions.UnbindMethods(this);

                // Dispose
                if (grid != null)
                {
                    grid.Dispose();
                }
                if (launcher != null)
                {
                    launcher.Dispose();
                }
                if (copypaste != null)
                {
                    copypaste.Dispose();
                }
                if (undoredo != null)
                {
                    undoredo.Dispose();
                }
                General.WriteLogLine("Unloading data resources...");
                if (data != null)
                {
                    data.Dispose();
                }
                General.WriteLogLine("Unloading map data...");
                if (map != null)
                {
                    map.Dispose();
                }
                General.WriteLogLine("Stopping graphics device...");
                if (renderer2d != null)
                {
                    renderer2d.Dispose();
                }
                if (renderer3d != null)
                {
                    renderer3d.Dispose();
                }
                if (graphics != null)
                {
                    graphics.Dispose();
                }
                visualcamera = null;
                grid         = null;
                launcher     = null;
                copypaste    = null;
                undoredo     = null;
                data         = null;
                //tempwad = null;
                map        = null;
                renderer2d = null;
                renderer3d = null;
                graphics   = null;

                // We may spend some time to clean things up here
                GC.Collect();

                // Let the plugins know
                General.Plugins.OnMapCloseEnd();

                // Done
                isdisposed = true;
            }
        }