示例#1
0
        protected virtual void DrawEntities(GameContext context)
        {
            foreach (IEntity a in context.World.Entities)
            {
                if ((a is ParticleEntity) && (a as ParticleEntity).Definition.RenderMode == ParticleMode.Background)
                {
                    this.HandleRenderOfEntity(context, a);
                }
            }
            foreach (IEntity a in context.World.Entities)
            {
                if (a.Image != null && !(a is ParticleEntity) && (!(a is IDynamicRenderingEntity) || (a as IDynamicRenderingEntity).ShouldRender(context.World)))
                {
                    this.HandleRenderOfEntity(context, a);
                }
            }
            foreach (IEntity a in context.World.Entities)
            {
                if ((a is ParticleEntity) && (a as ParticleEntity).Definition.RenderMode == ParticleMode.Foreground)
                {
                    this.HandleRenderOfEntity(context, a);
                }
            }
            XnaGraphics gr = new XnaGraphics(context);

            foreach (IEntity a in context.World.Entities)
            {
                if (!(a is IDynamicRenderingEntity) || (a as IDynamicRenderingEntity).ShouldRender(context.World))
                {
                    a.Draw(context.World, gr);
                }
            }
        }
示例#2
0
 public override void DrawAbove(GameContext context)
 {
     XnaGraphics xna = new XnaGraphics(context);
     //this.m_FieldOfViewRenderer.Render(context, xna);
     //int i = 0;
     //foreach (IPositionable p in this.m_Uniques)
     //    xna.DrawStringLeft(8, 8 + (i++) * 16, p.ToString());
     xna.DrawStringLeft(8, 8, "FPS: " + context.FPS, "Arial");
 }
示例#3
0
        public void Draw(GameContext context)
        {
            // Clear the screen.
            context.SpriteBatch.Begin();

            // Draw world below.
            context.World.DrawBelow(context);

            // Render all of the tiles.
            /*for (int z = 0; z < Tileset.TILESET_DEPTH; z += 1)
            {
                for (int x = context.Graphics.GraphicsDevice.Viewport.X / Tileset.TILESET_CELL_WIDTH;
                            x < Math.Min(context.Graphics.GraphicsDevice.Viewport.X + context.Graphics.GraphicsDevice.Viewport.Width / Tileset.TILESET_CELL_WIDTH,
                                            Tileset.TILESET_WIDTH);
                            x += 1)
                {
                    for (int y = context.Graphics.GraphicsDevice.Viewport.Y / Tileset.TILESET_CELL_HEIGHT;
                            y < Math.Min(context.Graphics.GraphicsDevice.Viewport.Y + context.Graphics.GraphicsDevice.Viewport.Height / Tileset.TILESET_CELL_HEIGHT,
                                            Tileset.TILESET_HEIGHT);
                            y += 1)
                    {
                        Tile t = context.World.Tileset[x, y, z];
                        if (t == null)
                            continue;
                        if (t.Image == null)
                            continue;
                        context.SpriteBatch.Draw(
                            context.Textures[t.Image],
                            new Rectangle((int)t.X, (int)t.Y, t.Width, t.Height),
                            (t.TX != -1 && t.TY != -1) ? new Rectangle?(new Rectangle(t.TX * t.Width, t.TY * t.Height, t.Width, t.Height)) : null,
                            Color.White
                        );
                    }
                }
            }*/

            // Render all of the actors.
            foreach (IEntity a in context.World.Entities)
                if ((a is ParticleEntity) && (a as ParticleEntity).Definition.RenderMode == ParticleMode.Background)
                    this.HandleRenderOfEntity(context, a);
            foreach (IEntity a in context.World.Entities)
                if (a.Image != null && !(a is ParticleEntity) && (!(a is IDynamicRenderingEntity) || (a as IDynamicRenderingEntity).ShouldRender(context.World)))
                    this.HandleRenderOfEntity(context, a);
            foreach (IEntity a in context.World.Entities)
                if ((a is ParticleEntity) && (a as ParticleEntity).Definition.RenderMode == ParticleMode.Foreground)
                    this.HandleRenderOfEntity(context, a);
            XnaGraphics gr = new XnaGraphics(context);
            foreach (IEntity a in context.World.Entities)
                if (!(a is IDynamicRenderingEntity) || (a as IDynamicRenderingEntity).ShouldRender(context.World))
                    a.Draw(context.World, gr);

            // Draw world above.
            context.World.DrawAbove(context);

            // Finish rendering.
            context.SpriteBatch.End();
        }
示例#4
0
 protected void DrawDebugPathFindingGrid(GameContext context, XnaGraphics graphics)
 {
     for (int x = 0; x < this.m_PathFindingGrid.GetLength(0); x++)
         for (int y = 0; y < this.m_PathFindingGrid.GetLength(1); y++)
             if (this.m_PathFindingGrid[x, y] == (byte)PathFinderHelper.BLOCKED_TILE)
                 graphics.DrawRectangle(new Rectangle(x * 16, y * 16, 16, 16), new Color(255, 0, 0, 128));
             else if (this.m_PathFindingGrid[x, y] == (byte)PathFinderHelper.EMPTY_TILE)
                 graphics.DrawRectangle(new Rectangle(x * 16, y * 16, 16, 16), new Color(0, 255, 0, 128));
             else
                 graphics.DrawRectangle(new Rectangle(x * 16, y * 16, 16, 16), new Color(0, 0, 255, 128));
 }
示例#5
0
        public override void DrawAbove(GameContext context)
        {
            XnaGraphics xna = new XnaGraphics(context);
            xna.DrawStringCentered(context.Camera.Width / 2, 50, "τυχαία", "TitleFont");
            xna.DrawStringCentered(context.Camera.Width / 2, 200, "(tychaía)", "SubtitleFont");

            MouseState state = Mouse.GetState();
            foreach (Button b in this.m_Buttons)
                b.Process(xna, state);

            xna.DrawStringCentered(context.Camera.Width / 2, 750, "Using static seed: " + m_StaticSeed.ToString(), "Arial");
        }
        public void Generate(Block[,,] blocks, ChunkInfo info)
        {
            while (RuntimeGame.DeviceForStateValidationOutput == null)
                continue;

            lock (RuntimeGame.LockForStateValidationOutput)
            {
                Console.Write("Locked graphics.  Rendering graph to file...");
                RainfallInformation rainfall = info.Objects.First(val => val is RainfallInformation) as RainfallInformation;
                TemperatureInformation temperature = info.Objects.First(val => val is TemperatureInformation) as TemperatureInformation;
                PresentationParameters pp = RuntimeGame.DeviceForStateValidationOutput.PresentationParameters;
                RenderTarget2D renderTarget = new RenderTarget2D(RuntimeGame.DeviceForStateValidationOutput, 200, 200, true, RuntimeGame.DeviceForStateValidationOutput.DisplayMode.Format, DepthFormat.Depth24);
                RuntimeGame.DeviceForStateValidationOutput.SetRenderTarget(renderTarget);
                RuntimeGame.ContextForStateValidationOutput.SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone);//, SaveStateMode.None, Matrix.Identity);
                //graphics.GraphicsDevice.SamplerStates[0].MagFilter = TextureFilter.Point;
                //graphics.GraphicsDevice.SamplerStates[0].MinFilter = TextureFilter.Point;
                //graphics.GraphicsDevice.SamplerStates[0].MipFilter = TextureFilter.Point;

                XnaGraphics graphics = new XnaGraphics(RuntimeGame.ContextForStateValidationOutput);
                if (File.Exists("state.png"))
                {
                    using (StreamReader reader = new StreamReader("state.png"))
                    {
                        Texture2D tex = Texture2D.FromStream(RuntimeGame.DeviceForStateValidationOutput, reader.BaseStream);
                        RuntimeGame.ContextForStateValidationOutput.SpriteBatch.Draw(tex, new Rectangle(0, 0, 200, 200), Color.White);
                    }
                }
                else
                {
                    graphics.FillRectangle(0, 0, 200, 200, Color.Red);
                    graphics.FillRectangle(0, 0, 100, 100, Color.White);
                }

                for (int x = 0; x < info.Bounds.Width; x++)
                    for (int y = 0; y < info.Bounds.Height; y++)
                    {
                        int r = 100 - (int)(rainfall.Rainfall[x, y] * 100);
                        int t = 100 - (int)(temperature.Temperature[x, y] * 100);

                        graphics.DrawLine(r, t, r + 1, t + 1, 1, new Color(0f, 0f, 0f, 0.1f).ToPremultiplied());
                    }

                RuntimeGame.ContextForStateValidationOutput.SpriteBatch.End();
                RuntimeGame.DeviceForStateValidationOutput.SetRenderTarget(null);
                using (StreamWriter writer = new StreamWriter("state.png"))
                {
                    renderTarget.SaveAsPng(writer.BaseStream, 200, 200);
                }
                Console.WriteLine(" done.");
            }
        }
示例#7
0
        public override void Draw(World world, XnaGraphics graphics)
        {
            this.m_World = world as RedMeansGoWorld;
            base.Draw(world, graphics);

            graphics.DrawSprite((int)this.X, (int)this.Y, this.Width - 8, this.Height - 8, "player.powerup", this.PowerupColor, false, this.Rotation,
                                new Vector2(54 / 2, 54 / 2));

            string msg;
            if (this.Health <= 0)
                msg = "You win.  They died.";
            else
                msg = "Distance to Heart: " + (this.Health * 150).ToString("F2") + "cm";
            graphics.DrawStringCentered((int)this.X, (int)this.Y + 40, msg);
            RedMeansGoGame.SetWindowTitle(msg);
        }
示例#8
0
        public void Draw(RTSWorld world, GameContext context, XnaGraphics graphics)
        {
            this.Update(world, context);

            graphics.DrawStringLeft(0, 0, world.ActiveLevel.GetType().Name);
            graphics.DrawStringLeft(0, 32, this.m_Tick.ToString());

            if (this.m_LastMousePoint.HasValue && this.m_CurrentMousePoint.HasValue)
                graphics.DrawRectangle(this.m_LastMousePoint.Value, this.m_CurrentMousePoint.Value, Color.LimeGreen);

            foreach (Unit u in this.Selected)
            {
                Rectangle bb = new Rectangle((int)u.X, (int)u.Y - 1, u.Width + 1, u.Height + 1);
                if (u.Team != null)
                    graphics.DrawRectangle(bb, u.Team.Color);
                else
                    graphics.DrawRectangle(bb, Color.LimeGreen);
            }

            // Draw chat.
            int a = 16;
            for (int i = this.m_ChatMessages.Count - 1; i >= Math.Max(this.m_ChatMessages.Count - 11, 0); i--)
            {
                if (i < this.m_ChatMessages.Count)
                    graphics.DrawStringLeft(0, context.Graphics.GraphicsDevice.Viewport.Height - a, this.m_ChatMessages[i]);
                a += 16;
            }

            // Draw graph.
            if (this.m_GraphFrames.Count > 1)
            {
                for (int i = 1; i < this.m_GraphFrames.Count; i++)
                    graphics.DrawLine(i - 1, (float)this.m_GraphFrames[i - 1], i, (float)this.m_GraphFrames[i], 1, Color.Lime);
            }

            // Add frame information.
            if (this.m_GraphFrames.Count > 200)
                this.m_GraphFrames.RemoveAt(0);
            this.m_GraphFrames.Add(context.GameTime.ElapsedGameTime.TotalMilliseconds);

            this.m_Tick++;
        }
示例#9
0
        public void Draw(GameContext context)
        {
            // Clear the screen.
            context.SpriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, context.Camera.GetTransformationMatrix());

            // Draw world below.
            context.World.DrawBelow(context);

            // Render tiles below.
            if (context.World.Tileset != null)
                this.DrawTilesBelow(context);

            // Render all of the actors.
            foreach (IEntity a in context.World.Entities)
                if ((a is ParticleEntity) && (a as ParticleEntity).Definition.RenderMode == ParticleMode.Background)
                    this.HandleRenderOfEntity(context, a);
            foreach (IEntity a in context.World.Entities)
                if (a.Image != null && !(a is ParticleEntity) && (!(a is IDynamicRenderingEntity) || (a as IDynamicRenderingEntity).ShouldRender(context.World)))
                    this.HandleRenderOfEntity(context, a);
            foreach (IEntity a in context.World.Entities)
                if ((a is ParticleEntity) && (a as ParticleEntity).Definition.RenderMode == ParticleMode.Foreground)
                    this.HandleRenderOfEntity(context, a);
            XnaGraphics gr = new XnaGraphics(context);
            foreach (IEntity a in context.World.Entities)
                if (!(a is IDynamicRenderingEntity) || (a as IDynamicRenderingEntity).ShouldRender(context.World))
                    a.Draw(context.World, gr);

            // Render tiles above.
            if (context.World.Tileset != null)
                this.DrawTilesAbove(context);

            // Draw world above.
            context.World.DrawAbove(context);

            // Finish rendering.
            context.SpriteBatch.End();
        }
示例#10
0
        public void Render(GameContext context, XnaGraphics xna)
        {
            Point center = this.m_FieldOfView.World.GetCenter();

            for (int x = 0; x < this.m_FieldOfView.BroadphaseGrid.GetLength(0); x++)
                for (int y = 0; y < this.m_FieldOfView.BroadphaseGrid.GetLength(1); y++)
                {
                    if (!this.m_FieldOfView.BroadphaseGrid[x, y])
                        xna.FillRectangle(new Rectangle(x * Seperation, y * Seperation, Seperation, Seperation), new Color(0f, 0f, 0f, 0.4f).ToPremultiplied());
                    if (x == center.X && y == center.Y)
                        xna.FillRectangle(new Rectangle(x * Seperation, y * Seperation, Seperation, Seperation), new Color(1f, 0f, 0f, 1).ToPremultiplied());
                    //xna.DrawStringLeft(x * Seperation, y * Seperation, this.m_FieldOfView.m_BroadphaseHeightGrid[x, y].ToString());
                    int deg = (int)MathHelper.ToDegrees(this.m_FieldOfView.m_BroadphaseAngleGrid[x, y]);
                    xna.DrawStringLeft(x * Seperation, y * Seperation, deg.ToString(), "SmallArial");
                    /*if (deg < -100)
                        xna.DrawStringLeft(x * Seperation, y * Seperation, Math.Abs(deg + 100).ToString());
                    else if (deg < 0)
                        xna.DrawStringLeft(x * Seperation, y * Seperation, Math.Abs(deg).ToString());
                    else if (deg < 100)
                        xna.DrawStringLeft(x * Seperation, y * Seperation, (deg).ToString());
                    else if (deg < 200)
                        xna.DrawStringLeft(x * Seperation, y * Seperation, (deg - 100).ToString());*/
                }
        }
示例#11
0
 public void Process(XnaGraphics xna, MouseState mouse)
 {
     if (this.m_PulseValue >= 1)
         this.m_PulseModeUp = false;
     else if (this.m_PulseValue <= 0)
         this.m_PulseModeUp = true;
     this.m_PulseValue += this.m_PulseModeUp ? 0.01 : -0.01;
     if (this.m_Area.Contains(mouse.X, mouse.Y) && mouse.LeftButton == ButtonState.Pressed)
         this.m_OnClick();
     if (this.m_Area.Contains(mouse.X, mouse.Y))
         xna.FillRectangle(this.m_Area, new Color(1f, 1f, 1f, 0.25f + (float)(this.m_PulseValue / 2.0)).ToPremultiplied());
     else
         xna.FillRectangle(this.m_Area, new Color(1f, 1f, 1f, 0.1f + (float)(this.m_PulseValue / 32.0)).ToPremultiplied());
     xna.DrawStringCentered(this.m_Area.X + this.m_Area.Width / 2, this.m_Area.Y + 4, this.m_Text, "ButtonFont");
 }
示例#12
0
 public virtual void Draw(World world, XnaGraphics graphics)
 {
 }
示例#13
0
        public override void DrawAbove(GameContext context)
        {
            // Are we waiting for players?
            #if MULTIPLAYER
            if (this.m_GlobalSession.Waiting || (this.m_GlobalSession.LoadingInitialData && !LocalNode.Singleton.IsServer))
            #else
            if (this.m_GlobalSession.Waiting)
            #endif
            {
                XnaGraphics graphics = new XnaGraphics(context);
                graphics.FillRectangle(new Rectangle(0, 0, context.Graphics.GraphicsDevice.Viewport.Width, context.Graphics.GraphicsDevice.Viewport.Height), Color.Black);
                int dialogX = context.Graphics.GraphicsDevice.Viewport.X + context.Graphics.GraphicsDevice.Viewport.Width / 2 - 300;
                int dialogY = context.Graphics.GraphicsDevice.Viewport.Y + context.Graphics.GraphicsDevice.Viewport.Height / 2 - 200;
                graphics.FillRectangle(new Rectangle(dialogX, dialogY, 600, 400), Color.DarkSlateGray);
                graphics.DrawStringCentered(dialogX + 300, dialogY + 8, this.m_GlobalSession.LobbyMessage, "BigArial");
                graphics.DrawStringCentered(dialogX + 300, dialogY + 32, "Press enter to toggle ready status.");
                int a = 0;
                for (int i = 0; i < this.m_GlobalSession.Players.Count; i++)
                {
                    Player p = this.m_GlobalSession.Players[i];
                    if (p.Ready)
                        graphics.DrawStringLeft(dialogX + 8, dialogY + 48 + a * 16, "Player " + a + " (" + p.PlayerID + ") ready.");
                    else
                        graphics.DrawStringLeft(dialogX + 8, dialogY + 48 + a * 16, "Player " + a + " (" + p.PlayerID + ") not ready.");
                    a++;
                }
                return;
            }

            // Handle game normally.
            if (this.m_ActiveLevel != null)
                this.m_ActiveLevel.DrawAbove(context);
            this.m_UiManager.Draw(this, context, new XnaGraphics(context));
        }
示例#14
0
        public override void Draw(World world, XnaGraphics graphics)
        {
            base.Draw(world, graphics);

            if (this.Width == 16 && this.CurrentHealth > 0 && this.MaxHealth > 0)
                graphics.DrawSprite((int)this.X, (int)this.Y, this.Width, this.Height, "meters.health.i" + ((int)(16 - (this.CurrentHealth / this.MaxHealth * 15))).ToString(), Color.White, false);

            // You can override to show more meters in subclasses.
        }