예제 #1
0
        private void DXControl_Load(object sender, EventArgs e)
        {
            if (this.DesignMode)
            {
                return;
            }

            editorEngine = new VisualEngine(new StringBuilder("Editor"));

            // Add a relative path where the textures are located
            editorEngine.Textures.AddRelativePath("Textures");

            // The RenderTarget used for rendering

            renderRenderTarget = editorEngine.CreateSwapChainRenderTarget("SwapChain", this.Handle);

            renderView = editorEngine.RenderViews.Create(renderRenderTarget);

            renderView.DepthStencil = editorEngine.DepthStencils.Create(new StringBuilder("MainDepthStencil"), renderView.RenderTarget.Width, renderView.RenderTarget.Height);

            // When a resize of this control happens, i need to recreate this view
            onResizeMethods.Add((w, h) => renderView.Resize(w, h));

            this.ParentForm.FormClosed += ParentForm_FormClosed;

            OnInitializeRender();
        }
예제 #2
0
        void Window1_Loaded(object sender, RoutedEventArgs e)
        {
            /*
             * VERY IMPORTANT NOTE
             * THIS CODE HAS NO SENSE HERE, BUT IF IT'S NOT EXECUTED, THE ENGINE GIVES A ENGINERUNTIMEEXCEPTION WHEN USED IN OTHER PLACES
             */

            RenderableMeshPart meshPart = new RenderableMeshPart(6, 6, 0);

            /*
             * END OF THE STUPID CODE :(
             */

            // Create the engined that will be used for the editor
            editorEngine = new VisualEngine(new StringBuilder("Editor"));

            // Add a relative path where the textures are located
            editorEngine.Textures.AddRelativePath("Textures");

            spriteRenderControl = new SpriteRenderControl(editorEngine, new StringBuilder("SpriteControl"));

            spriteRenderControl.Margin = new Thickness(10, 50, 10, 10);

            Grid.SetColumn(spriteRenderControl, 0);

            ctGrid.Children.Add(spriteRenderControl);

            renderControl = new TestRenderControl(editorEngine, new StringBuilder("Control"));

            Grid.SetColumn(renderControl, 1);

            renderControl.Margin = new Thickness(10, 50, 10, 10);

            ctGrid.Children.Add(renderControl);
        }
예제 #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Font for ASCII graphics
            this.asciiGraphicsFont = this.Content.Load <SpriteFont>("Fonts/BPmono40Bold");
            this.logFont           = this.Content.Load <SpriteFont>("Fonts/Consolas12");

            #region Temporary code

            // Create a map to use for (test) playground.
            this.testMap = new MapContainer(
                MapUtilities.GenerateRandomMap(20, 20, VisualMode.ASCII));
            this.testMap.LoadTileNeighboors();

            // The Actor queue (for the turn system) specific to this map.
            this.queueHelper = new ActorQueueHelper(this.testMap);

            // Initialize VisualEngine for the game
            this.visualEngine = new VisualEngine(
                VisualMode.ASCII,
                32,
                16, 11,
                this.testMap,
                null,
                this.asciiGraphicsFont);
            this.visualEngine.DeltaTileDrawCoordinates = new Point(4, -6);
            this.visualEngine.ASCIIScale = 0.7f;

            // Initialize MessageLog.
            Rectangle logRect = new Rectangle(
                0,
                this.visualEngine.MapDrawboxTileSize.Y * this.visualEngine.TileSize,
                ScreenWidth - 30,
                (ScreenHeight - 30) - (this.visualEngine.MapDrawboxTileSize.Y * this.visualEngine.TileSize));
            this.messageLog = new MessageLog(logRect, this.logFont);

            // Create an actor (unit, character, etc.) for the player.
            this.actor = new Actor(
                "SCiENiDE",
                "@",
                new PropertyBag <int>(),
                this.testMap,
                Flags.IsPlayerControl,
                85,
                Species.Human);

            //// TODO: Improve actor spawn/add to actorQueue.
            // "Spawn" the actor on the map, and add him to the map actor list.
            this.actor.Position = new Point();
            this.queueHelper.AddActor(this.actor);

            #endregion
        }
예제 #4
0
        public SpriteRenderControl(VisualEngine engine, StringBuilder renderName)
        {
            this.editorEngine = engine;

            this.renderName = renderName;

            InitializeComponent();

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            Loaded   += Window1_Loaded;
            Unloaded += RenderControl_Unloaded;
        }
예제 #5
0
        public TestRenderControl(VisualEngine engine, StringBuilder renderName)
        {
            this.editorEngine = engine;

            this.renderName = renderName;

            AIOEngine.MathSpace.Matrix  matrix  = AIOEngine.MathSpace.Matrix.Identity;
            AIOEngine.MathSpace.Vector3 forward = matrix.Forward;
            AIOEngine.MathSpace.Vector3 up      = matrix.Up;
            AIOEngine.MathSpace.Vector3 left    = matrix.Left;

            InitializeComponent();

            if (DesignerProperties.GetIsInDesignMode(this))
            {
                return;
            }

            Loaded   += Window1_Loaded;
            Unloaded += RenderControl_Unloaded;
        }