public Map(int width, int height, Texture2D createFrom) { NextText = 0; CurrentTextFrame = -1; PlayText = false; Spawn = Vector.Zero; WidthInTiles = width; HeightInTiles = height; Tiles = new Tile[width, height]; Entities = new List<Entity>(); LitAreas = new List<LitArea>(); Staircases = new List<Staircase>(); Particles = new List<Particle>(); Random = new Random((int)DateTime.Now.Ticks); Entities.Add(PlayerEntity = new Player(this)); InitMap(createFrom); AddMapObjects(); for (int x = 0; x < WidthInTiles; x++) for (int y = 0; y < HeightInTiles; y++) { if (Tiles[x, y].Background == Tile.BlockType.Node) Pentagram = new Vector(x + 1, y + 1); } }
protected override void Initialize() { base.Initialize(); CurrentLevel = 0; //using (var file = System.IO.File.OpenRead("level1.png")) LoadLevel(CurrentLevel); CurrentCamera = Vector.Zero; }
public void CheckDeath(Vector point) { if (PentagramAnimation == 0 && (point - Pentagram).LengthSquared < 5 * 5) PentagramAnimation = 1; }
public void Draw(SpriteBatch sb, Vector camera) { for (int y = HeightInTiles - 1; y >= 0; y--) for (int x = WidthInTiles - 1; x >= 0; x--) Tiles[x, y].DrawBackground(sb, x, y); for (int i = 0; i < Staircases.Count; i++) Staircases[i].Draw(sb); for (int y = HeightInTiles - 1; y >= 0; y--) for (int x = WidthInTiles - 1; x >= 0; x--) Tiles[x, y].DrawBackgroundLayer(sb, x, y); sb.Draw(Resources.Graphics.Nodes[Math.Min(PentagramAnimation / 6, 5)], new Rectangle((int)((Pentagram.X - 1.2) * ViewScale), (int)((Pentagram.Y - 1.2) * ViewScale), (int)(ViewScale * 2.2), (int)(ViewScale * 2.2)), Color.White); for (int i = 0; i < Entities.Count; i++) Entities[i].Draw(sb); for (int i = 0; i < Particles.Count; i++) Particles[i].Draw(sb); for (int y = HeightInTiles - 1; y >= 0; y--) for (int x = WidthInTiles - 1; x >= 0; x--) Tiles[x, y].DrawForegroundLayer(sb, x, y); }
public void AddPairOfStairaces(Vector pos1, Vector pos2) { Staircase first = new Staircase(pos1, null); Staircase second = new Staircase(pos2, first); first.Other = second; Staircases.Add(first); Staircases.Add(second); }
public double Dot(Vector other) => X * other.X + Y * other.Y;
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(new Color(56, 40, 41)); if (gameMap != null) { double centerX = (gameMap.PlayerEntity.Position.X + gameMap.PlayerEntity.Width / 2) * Map.ViewScale; double centerY = (gameMap.PlayerEntity.Position.Y + gameMap.PlayerEntity.Height / 2) * Map.ViewScale; if (gameMap.PlayerEntity.Facing == Entities.Entity.Direction.Left) centerX -= 4 * Map.ViewScale; else centerX += 4 * Map.ViewScale; CurrentCamera = new Vector(centerX, centerY) * 0.1 + CurrentCamera * 0.9; Matrix m = Matrix.CreateTranslation(new Vector3( -(float)CurrentCamera.X + graphics.PreferredBackBufferWidth / 2, -(float)CurrentCamera.Y + graphics.PreferredBackBufferHeight / 2, 0)); spriteBatch.Begin(transformMatrix: m); gameMap.Draw(spriteBatch, CurrentCamera); spriteBatch.End(); spriteBatch.Begin(blendState: BlendState.Additive, transformMatrix: m); gameMap.DrawBlend(spriteBatch); spriteBatch.End(); if (gameMap.NextText < 4 && gameMap.CurrentTextFrame > -1 && Resources.Graphics.Monologue[gameMap.NextText][gameMap.CurrentTextFrame] != null) { int w = Resources.Graphics.Monologue[gameMap.NextText][gameMap.CurrentTextFrame].Width / 2; int h = Resources.Graphics.Monologue[gameMap.NextText][gameMap.CurrentTextFrame].Height / 2; spriteBatch.Begin(); spriteBatch.Draw(Resources.Graphics.Monologue[gameMap.NextText][gameMap.CurrentTextFrame], new Rectangle(ScreenWidth / 2 - w / 2, ScreenHeight / 2 - h / 2, w, h), Color.White); spriteBatch.End(); } } base.Draw(gameTime); }
public Staircase(Vector location, Staircase other) { Location = location; Other = other; }