private void DrawTextures() { var grass = SpriteLoader.Instance.AddSprite("content/title_grass"); Menu.PreDraw(this); SetRenderTarget(GrassNoise); GraphicsDevice.Clear(Color.Black); var proj = Matrix.CreateOrthographicOffCenter(0, GrassNoise.Width, GrassNoise.Height, 0, 0, -1); PushSpriteBatch(samplerState: SamplerState.PointWrap, blendState: NonPremultiplied, shader: Shader, projection: proj, shaderSetup: (transform, projection) => { SetupColorMatrix(ColorMatrix.Identity, transform, projection); }); for (int x = 0; x < GrassWidth; x++) { for (int y = 0; y < GrassHeight; y++) { DrawSprite(grass, Noise.GetValue(x, y), new Vector2(x, y) * 16, SpriteEffects.None, 0); } } PopSpriteBatch(); SetRenderTarget(GrassMap); GraphicsDevice.Clear(Color.Black); PushSpriteBatch(samplerState: SamplerState.PointWrap, blendState: NonPremultiplied, transform: Matrix.Identity, projection: Projection, shader: Shader, shaderSetup: (transform, projection) => { SetupColorMatrix(ColorMatrix.Identity, Matrix.Identity, Projection); }); var shadow = SpriteLoader.Instance.AddSprite("content/title_morpho_shadow"); var shadowSword = SpriteLoader.Instance.AddSprite("content/title_morpho_shadow_sword"); shadowSword.ShouldLoad = true; PushSpriteBatch(shader: Shader, shaderSetup: (transform, projection) => { SetupUVScroll(GroundOffset * -1 / new Vector2(GrassNoise.Width, GrassNoise.Height), transform, projection); }); SpriteBatch.Draw(GrassNoise, Viewport.Bounds, Viewport.Bounds, Color.White); PopSpriteBatch(); if (TitleSM.CurrentState >= TitleState.TextSlash) { DrawSpriteExt(shadowSword, Frame / 10, MorphoPosition - shadowSword.Middle, shadowSword.Middle, Util.VectorToAngle(MorphoFacing) + MathHelper.Pi, new Vector2(0.5f), SpriteEffects.None, new Color(255, 255, 255, 64), 0); } else { DrawSpriteExt(shadow, Frame / 10, MorphoPosition - shadow.Middle, shadow.Middle, Util.VectorToAngle(MorphoFacing) + MathHelper.Pi, new Vector2(0.5f), SpriteEffects.None, new Color(255, 255, 255, 64), 0); } foreach (var particle in GroundParticles) { particle.Draw(this); } PopSpriteBatch(); }
public void Print(Map map) { SimpleNoise spikeNoise = new SimpleNoise(Random.Next()); if (map.Width != Width || map.Height != Height) { throw new Exception(); } var tiles = Rooms.SelectMany(x => x.GetCoveredTiles().Select(y => new Tuple <Room, Point>(x, y))).GroupBy(pair => pair.Item2, pair => pair.Item1); foreach (var rooms in tiles) { var pos = rooms.Key; var tile = map.GetTile(pos.X, pos.Y); var count = rooms.Count(); var singleRoom = count == 1 ? rooms.Single() : null; RoomType[] normalRooms = new[] { RoomType.None, RoomType.Start, RoomType.End, RoomType.Corridor }; RoomType[] startEnd = new[] { RoomType.Start, RoomType.End }; Template[] floors = new[] { null, Template.Corridor }; Template template = null; if (singleRoom != null && singleRoom.Type == RoomType.Filled) { template = Template.Wall; } if (singleRoom != null && singleRoom.Type == RoomType.Chasm) { template = Template.Chasm; } if (count > 1) { template = Template.Wall; } if (rooms.Any(x => x.Type == RoomType.Chasm)) { template = Template.Corridor; } if (rooms.All(x => x.Type == RoomType.Chasm)) { template = Template.Chasm; } if (rooms.All(x => x.Type == RoomType.Corridor)) { template = Template.Corridor; } if (singleRoom?.Type == RoomType.Start || singleRoom?.Type == RoomType.End) { template = Template.Floor; } if (count == 2 && IsConnected(rooms.First(), rooms.Last()) && !floors.Contains(template)) { template = null; } if (IsEdgeTile(pos) && floors.Contains(template) && !rooms.All(x => startEnd.Contains(x.Type))) { template = Template.Wall; } int spikeValue = spikeNoise.GetValue(pos.X / 3, pos.Y / 3); if (template == Template.Wall && (spikeValue % 10 == 0 || spikeNoise.GetValue(pos.X, pos.Y) % 30 == 0)) { template = Template.SpikeWall; } if (template == Template.Wall && Random.NextDouble() < 0.1) { template = Template.WraithWall; } if (template == null) { template = Template.Floor; } if (template != null) { tile.ApplyTemplate(template); } if (rooms.Any(x => x.Type == RoomType.Chasm) && template != Template.Chasm) { Behavior.Apply(new BehaviorChasmSeam(tile, template == Template.Corridor ? new Color(155, 99, 74) : new Color(124, 88, 114))); } if (singleRoom?.Type == RoomType.Start) { Behavior.Apply(new BehaviorLevelStart(tile, singleRoom.GetEdgeDirection())); } if (singleRoom?.Type == RoomType.End) { Behavior.Apply(new BehaviorLevelEnd(tile, singleRoom.GetEdgeDirection())); if (singleRoom.Interior.Center == pos) { var pointer = new Curio(Template.Pointer); pointer.MoveTo(tile); Behavior.Apply(new BehaviorEscapeTarget(pointer, singleRoom.Interior)); } } } }