3 using Microsoft.Xna.Framework;
4 using Microsoft.Xna.Framework.Graphics;
6 using System.Collections.Generic;
12 private LevelRenderer renderer;
22 renderer.ReloadTextures();
24 HashSet<Texture2D> uniqueTextures =
new HashSet<Texture2D>();
25 HashSet<Sprite> uniqueSprites =
new HashSet<Sprite>();
27 foreach (var levelObj
in allLevelObjects)
29 foreach (
Sprite sprite
in levelObj.Prefab.Sprites)
31 if (!uniqueTextures.Contains(sprite.
Texture))
33 uniqueTextures.Add(sprite.
Texture);
34 uniqueSprites.Add(sprite);
39 foreach (
Sprite sprite
in uniqueSprites)
47 if (renderer ==
null) {
return; }
48 renderer.DrawDebugOverlay(spriteBatch, cam);
54 Color color = Color.Yellow;
57 color = Color.DarkOrange;
61 color = Color.LightGray;
68 GUI.DrawRectangle(spriteBatch,
new Vector2(pos.
Position.X - 15.0f, -pos.
Position.Y - 15.0f),
new Vector2(30.0f, 30.0f), color,
true);
71 foreach (RuinGeneration.Ruin ruin in
Ruins)
74 ruinArea.Y = -ruinArea.Y - ruinArea.Height;
76 GUI.DrawRectangle(spriteBatch, ruinArea, Color.DarkSlateBlue,
false, 0, 5);
79 foreach (var positions
in wreckPositions.Values)
81 for (
int i = 0; i < positions.Count; i++)
83 float t = (i + 1) / (
float)positions.Count;
84 float multiplier = MathHelper.Lerp(0, 1, t);
85 Color color = Color.Red * multiplier;
86 var pos = positions[i];
88 var size =
new Vector2(100);
89 GUI.DrawRectangle(spriteBatch, pos - size / 2, size, color, thickness: 10);
90 if (i < positions.Count - 1)
92 var nextPos = positions[i + 1];
93 nextPos.Y = -nextPos.Y;
94 GUI.DrawLine(spriteBatch, pos, nextPos, color, width: 10);
99 foreach (var rects
in blockedRects.Values)
101 foreach (var rect
in rects)
104 newRect.Y = -newRect.Y;
105 GUI.DrawRectangle(spriteBatch, newRect, Color.Red, thickness: 5);
111 public void DrawBack(GraphicsDevice graphics, SpriteBatch spriteBatch,
Camera cam)
113 float brightness = MathHelper.Clamp(1.1f + (cam.
Position.Y -
Size.Y) / 100000.0f, 0.1f, 1.0f);
115 lightColorHLS.Y *= brightness;
121 if (renderer !=
null)
124 renderer?.DrawBackground(spriteBatch, cam,
LevelObjectManager, backgroundCreatureManager);
142 if (levelWall.
Body.BodyType == BodyType.Static) {
continue; }
144 Vector2 bodyPos =
new Vector2(
148 if (Vector2.DistanceSquared(bodyPos, levelWall.
Body.Position) > 0.5f
151 levelWall.
Body.SetTransformIgnoreContacts(ref bodyPos, levelWall.
Body.Rotation);
162 destructibleWall.SetDamage(destructibleWall.MaxHealth * damageByte / 255.0f);
167 throw new Exception($
"Malformed incoming level event: {eventType} is not a supported event type");
static Lights.LightManager LightManager
LevelGenerationParams GenerationParams
void DrawBack(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam)
BackgroundCreatureManager BackgroundCreatureManager
void DrawDebugOverlay(SpriteBatch spriteBatch, Camera cam)
void ClientEventRead(IReadMessage msg, float sendingTime)
List< LevelWall > ExtraWalls
void DrawFront(SpriteBatch spriteBatch, Camera cam)
List< InterestingPosition > PositionsOfInterest
IEnumerable< LevelObject > GetAllObjects()
Single ReadRangedSingle(Single min, Single max, int bitCount)
readonly PositionType PositionType