Ejemplo n.º 1
0
        public static void DrawTile(Camera aCamera, GraphicsDevice aDevice, int xPos, int yPos, int width, int height, Color aColor)
        {
            if (_Effect2D == null)
                Initialize(aCamera, aDevice);

            // TODO: All of this has to be fixed.  This is the most ineffecient drawing code ever.
            Matrix world = Matrix.CreateTranslation(new Vector3(xPos, yPos, 0.0f));

            _Effect2D.World = world;

            VertexPositionColor[] tileVerts = new VertexPositionColor[] {
                new VertexPositionColor(new Vector3(0.0f, 0.0f, 0.0f), aColor),
                new VertexPositionColor(new Vector3(width, 0.0f, 0.0f), aColor),
                new VertexPositionColor(new Vector3(width, height, 0.0f), aColor),
                new VertexPositionColor(new Vector3(0.0f, 0.0f, 0.0f), aColor),
                new VertexPositionColor(new Vector3(width, height, 0.0f), aColor),
                new VertexPositionColor(new Vector3(0.0f, height, 0.0f), aColor)
            };

            _Effect2D.Begin();
            foreach (EffectPass pass in _Effect2D.CurrentTechnique.Passes)
            {
                pass.Begin();
                aDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.TriangleList, tileVerts, 0, 2);
                pass.End();
            }
            _Effect2D.End();
        }
Ejemplo n.º 2
0
        private static void Initialize(Camera aCamera, GraphicsDevice aDevice)
        {
            _Effect2D = new BasicEffect(aDevice, null);
            Matrix proj = Matrix.CreateOrthographicOffCenter(0.0f, aCamera.WindowWidth, aCamera.WindowHeight, 0.0f, -1.0f, 1.0f);

            _Effect2D.Projection = proj;
            _Effect2D.VertexColorEnabled = true;
        }
Ejemplo n.º 3
0
        public override void Render(GameTime aTime, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch)
        {
            if (_verts == null)
            {
                CreateRenderElements(aDevice);
            }

            _effect.View = aCamera.View;
            _effect.Projection = aCamera.Projection;
            _effect.Begin();
            for (int i = 0; i < _effect.CurrentTechnique.Passes.Count; ++i)
            {
                _effect.CurrentTechnique.Passes[i].Begin();
                aDevice.VertexDeclaration = new VertexDeclaration(aDevice, VertexPositionColor.VertexElements);
                aDevice.Vertices[0].SetSource(_verts, 0, VertexPositionColor.SizeInBytes);
                aDevice.DrawPrimitives(PrimitiveType.LineList, 0, _primativeCount);
                _effect.CurrentTechnique.Passes[i].End();
            }
            _effect.End();
        }
Ejemplo n.º 4
0
 public abstract void Render(GameTime aTime, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch);
Ejemplo n.º 5
0
        public override void Render(GameTime aTime, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch)
        {
            // TODO: Rendering needs refactoring... a LOT.
            if (s_defaultTexture == null)
                s_defaultTexture = World.Instance.Game.Content.Load<Texture2D>("white");

            Texture2D myTexture = _spriteTextures[_spriteCurrentFrame];
            if(myTexture == null)
                myTexture = s_defaultTexture;

            Vector2 screenPos = aCamera.WorldToScreen(Position);
            Vector2 screenSize = aCamera.WorldSizeToScreenSize(Size);
            Rectangle destRect = new Rectangle((int)screenPos.X, (int)screenPos.Y, (int)screenSize.X, (int)screenSize.Y);

            aBatch.Begin();
            aBatch.Draw(myTexture, destRect, null, Color, MathHelper.ToRadians(Rotation),
               new Vector2(myTexture.Width / 2, myTexture.Height / 2), SpriteEffects.None, 0.0f);
            aBatch.End();
        }
Ejemplo n.º 6
0
 public override void Render(GameTime aTime, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch)
 {
 }
Ejemplo n.º 7
0
        public override void Render(GameTime aTime, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch)
        {
            if (_particles == null)
                return;

            if (s_defaultTexture == null)
                s_defaultTexture = World.Instance.Game.Content.Load<Texture2D>("white");

            Texture2D myTexture = _spriteTextures[_spriteCurrentFrame];
            if (myTexture == null)
                myTexture = s_defaultTexture;

            // Render all of our particles.
            aBatch.Begin();
            for (int i = 0; i < _maxParticlesAlive; ++i)
            {
                if (_particles[i]._age < 0.0f)
                    continue;

                Vector2 screenPos = aCamera.WorldToScreen(_particles[i]._pos);
                Vector2 currentSize = Size * _particles[i]._scale;
                Vector2 screenSize = aCamera.WorldSizeToScreenSize(currentSize);
                Rectangle destRect = new Rectangle((int)screenPos.X, (int)screenPos.Y, (int)screenSize.X, (int)screenSize.Y);

                aBatch.Draw(myTexture, destRect, null, _particles[i]._color, _particles[i]._rotation,
                   new Vector2(myTexture.Width / 2, myTexture.Height / 2), SpriteEffects.None, 0.0f);
            }
            aBatch.End();
        }
 public void Render(Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch)
 {
     if (_spatialGraph != null)
         _spatialGraph.Render(aCamera, aDevice, aBatch);
 }
        public override void Render(GameTime aTime, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch)
        {
            Color textColor = new Color(0.5f, 0.5f, 0.5f);
            SpriteFont font = FontCache.Instance["ConsoleSmall"];

            string infoString = "";
            int xOffset = 0;
            if (_current == 0)
            {
                infoString = "[A]: Next ";
                xOffset = 925;
            }
            else if (_current == _screens.Count - 1)
            {
                infoString = "[Back]: Previous";
                xOffset = 870;
            }
            else
            {
                infoString = "[A]: Next [Back]: Previous";
                xOffset = 785;
            }

            aBatch.Begin();
            aBatch.DrawString(font, infoString, new Vector2(xOffset, 745), textColor);
            aBatch.End();
        }
Ejemplo n.º 10
0
        public override void Render(GameTime aTime, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch)
        {
            // TODO: FIX ME!!! Doing this just to test text rendering for now.
            SpriteFont font = FontCache.Instance[Font];

            aBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);
            for (int i = 0; i < _displayStrings.Length; i++)
            {
                Vector2 position = aCamera.WorldToScreen(_displayStrings[i]._position);
                aBatch.DrawString(font, _displayStrings[i]._string, position, this.Color);
            }
            aBatch.End();
        }
Ejemplo n.º 11
0
 public override void Render(GameTime aTime, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch)
 {
     base.Render(aTime, aCamera, aDevice, aBatch);
     _pathFinder.Render();
     _brain.Render();
 }
Ejemplo n.º 12
0
        public void Render(Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch)
        {
            if (HasChildren)
            {
                LHC.Render(aCamera, aDevice, aBatch);
                RHC.Render(aCamera, aDevice, aBatch);
                return;
            }

            if (SpatialGraphManager.Instance.DrawBlocked )
            {
                if (Blocked)
                    BBox.Render(new Color(1.0f, 0.0f, 0.0f, 0.25f), aCamera, aDevice, aBatch);
            }

            if (SpatialGraphManager.Instance.DrawBounds)
            {
                // TODO; Render Outline of a BBox
            }

            Vector2 centroid = BBox.Centroid();

            if( SpatialGraphManager.Instance.DrawNodeIndex )
            {
                Vector2 screenCenter = aCamera.WorldToScreen( centroid );
                aBatch.Begin();
                aBatch.DrawString(FontCache.Instance["ConsoleSmall"], Index.ToString(), screenCenter,  new Color(0, 1, 1, 1));
                aBatch.End();
            }

            if( SpatialGraphManager.Instance.DrawGraph && !Blocked )
            {
                if(s_Effect == null)
                {
                    s_Effect = new BasicEffect(aDevice, null);
                    s_Effect.VertexColorEnabled = true;
                    s_Effect.World = Matrix.Identity;
                }

                List<VertexPositionColor> lineList = new List<VertexPositionColor>();

                for( int i = 0; i < Neighbors.Count; i++ )
                {
                    if( Neighbors[i].Blocked || !NeighborLOS[i] )
                        continue;
                    //Draw lines
                    Vector2 neighbor = Neighbors[i].BBox.Centroid();
                    neighbor = centroid + ((neighbor - centroid) * 0.6f);

                    lineList.Add(new VertexPositionColor(
                        new Vector3(centroid.X, centroid.Y, 0.0f), Color.Red));
                    lineList.Add(new VertexPositionColor(
                        new Vector3(neighbor.X, neighbor.Y, 0.0f), Color.Red));
                }

                VertexPositionColor[] lineArray = lineList.ToArray();

                s_Effect.View = aCamera.View;
                s_Effect.Projection = aCamera.Projection;
                s_Effect.Begin();
                for (int i = 0; i < s_Effect.CurrentTechnique.Passes.Count; ++i)
                {
                    s_Effect.CurrentTechnique.Passes[i].Begin();
                    aDevice.VertexDeclaration = new VertexDeclaration(aDevice, VertexPositionColor.VertexElements);
                    aDevice.DrawUserPrimitives<VertexPositionColor>(PrimitiveType.LineList, lineArray, 0, lineArray.Length / 2);
                    s_Effect.CurrentTechnique.Passes[i].End();
                }
                s_Effect.End();
            }

            if( SpatialGraphManager.Instance.DrawGridPoints )
            {
                if (s_defaultTexture == null)
                    s_defaultTexture = Angel.World.Instance.Game.Content.Load<Texture2D>("white");

                Color pointColor = Color.Red;
                List<Vector2> gridPoints;
                int xPoints, yPoints;
                GetGridPoints(out gridPoints, out xPoints, out yPoints);

                aBatch.Begin();
                for( int i = 0; i < gridPoints.Count; i++ )
                {
                    Vector2 screenLoc = aCamera.WorldToScreen(gridPoints[i]);
                    Rectangle rect = new Rectangle((int)screenLoc.X, (int)screenLoc.Y, 5, 5);
                    aBatch.Draw(s_defaultTexture, rect, pointColor);
                }
                aBatch.End();
            }
        }
Ejemplo n.º 13
0
        public void Render(Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch)
        {
            bool bDrawAny = SpatialGraphManager.Instance.DrawBounds || SpatialGraphManager.Instance.DrawGridPoints
                || SpatialGraphManager.Instance.DrawGraph || SpatialGraphManager.Instance.DrawBlocked;

            if (bDrawAny && _root != null)
            {
                _root.Render(aCamera, aDevice, aBatch);
            }
        }
Ejemplo n.º 14
0
        public bool Initialize(Game game, int windowWidth, int windowHeight, string windowName)
        {
            if (_initialized)
                return false;

            _game = game;

            _camera = new Camera(windowWidth, windowHeight, new Vector3(0, 0, 10), new Vector3(0, 0, -10));

            if (File.Exists(string.Format("Config\\{0}.cfg", "autoexec")))
            {
                DeveloperConsole.Instance.ExecConfigFile("autoexec");
            }

            ConsoleVariable var = DeveloperConsole.Instance.ItemManager.GetCVar("theWorld");
            var.Value = this;
            //CONSOLE_DECLARECMDSTATIC(UnloadAll, UnloadAllStatic);
            //CONSOLE_DECLARECMDSTATIC(ReloadLevel, ReloadLevel);

            #if WINDOWS
            DeveloperConsole.Instance.ItemManager.AddCommand("BeginEditing", x => { BeginEditing(); return null; });
            DeveloperConsole.Instance.ItemManager.AddCommand("EndEditing", x => { EndEditing(); return null; });

            Switchboard.Instance["BeginEditing"] = new MessageHandler(x => BeginEditing());
            #endif
            _initialized = true;
            return true;
        }
Ejemplo n.º 15
0
        public void Render(Color aColor, Camera aCamera, GraphicsDevice aDevice, SpriteBatch aBatch)
        {
            if (s_defaultTexture == null)
                s_defaultTexture = World.Instance.Game.Content.Load<Texture2D>("white");

            Vector2 screenPos = aCamera.WorldToScreen(Centroid());
            Vector2 screenSize = aCamera.WorldSizeToScreenSize(Max - Min);
            Rectangle destRect = new Rectangle((int)screenPos.X, (int)screenPos.Y, (int)screenSize.X, (int)screenSize.Y);

            aBatch.Begin();
            aBatch.Draw(s_defaultTexture, destRect, null, aColor, 0.0f,
               new Vector2(s_defaultTexture.Width / 2, s_defaultTexture.Height / 2),
               SpriteEffects.None, 0.0f);
            aBatch.End();
        }