public Door(Vector3 pos, int dir, VoxelSprite sheet) { Position = pos; Dir = dir; if(Dir==0||Dir==2) CollisionBox = new BoundingBox(pos - new Vector3(4f, 1f, 4f), pos + new Vector3(4f, 1f, 4f)); else CollisionBox = new BoundingBox(pos - new Vector3(1f, 4f, 4f), pos + new Vector3(1f, 4f, 4f)); switch (Dir) { case 0: ParticlePosition = Position + new Vector3(0f, -15f, 0f); ParticleDir = new Vector3(0f, 1f, 0f); break; case 1: ParticlePosition = Position + new Vector3(15f, 0f, 0f); ParticleDir = new Vector3(-1f, 0f, 0f); break; case 2: ParticlePosition = Position + new Vector3(0f, 15f, 0f); ParticleDir = new Vector3(0f, -1f, 0f); break; case 3: ParticlePosition = Position + new Vector3(-15f, 0f, 0f); ParticleDir = new Vector3(1f, 0f, 0f); break; } spriteSheet = sheet; }
public Enemy(Vector3 pos, Room room, VoxelSprite sprite) { Position = pos; Room = room; spriteSheet = sprite; }
public Enemy(Vector3 pos, Room room, VoxelSprite sprite) { Position = pos; Room = room; spriteSheet = sprite; }
public Manhack(Vector3 pos, Room room, VoxelSprite sprite) : base(pos, room, sprite) { Type = EnemyType.Manhack; Position.Z -= 2f; animTargetTime = 30f; Health = 50f; }
public void LoadContent(ContentManager content, GraphicsDevice gd) { spriteSheet = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "dude.vxs"), ref spriteSheet); drawEffect = new BasicEffect(gd) { VertexColorEnabled = true }; }
public Manhack(Vector3 pos, Room room, VoxelSprite sprite) : base(pos, room, sprite) { Type = EnemyType.Manhack; Position.Z -= 2f; animTargetTime = 30f; Health = 50f; }
public Sentinel(Vector3 pos, Room room, VoxelSprite sprite) : base(pos, room, sprite) { animTargetTime = 100; numFrames = 5; offsetFrame = 1; Target = Position; Rotation = (float)(Helper.Random.NextDouble() * MathHelper.TwoPi); numAttackFrames = 6; }
public Ooze(Vector3 pos, Room room, VoxelSprite sprite) : base(pos, room, sprite) { Type = EnemyType.Ooze; animTargetTime = 500; numFrames = 3; offsetFrame = 1; Target = Position; Health = 50; Rotation = (float)(Helper.Random.NextDouble() * MathHelper.TwoPi); }
public Ooze(Vector3 pos, Room room, VoxelSprite sprite) : base(pos, room, sprite) { Type = EnemyType.Ooze; animTargetTime = 500; numFrames = 3; offsetFrame = 1; Target = Position; Health = 50; Rotation = (float)(Helper.Random.NextDouble() * MathHelper.TwoPi); }
public Sentinel(Vector3 pos, Room room, VoxelSprite sprite) : base(pos, room, sprite) { Type = EnemyType.Sentinel; animTargetTime = 100; numFrames = 5; offsetFrame = 1; Target = Position; Rotation = (float)(Helper.Random.NextDouble() * MathHelper.TwoPi); numAttackFrames = 6; }
public BombController(GraphicsDevice gd, VoxelSprite sprite) { Instance = this; graphicsDevice = gd; spriteSheet = sprite; drawEffect = new BasicEffect(gd) { VertexColorEnabled = true }; }
public Room(VoxelSprite tileSheet, VoxelSprite objects, bool isGap) { IsGap = isGap; if (!isGap) { World = new VoxelWorld(15, 9, 1, true); CreateMap(tileSheet); } objectSheet = objects; }
public BombController(GraphicsDevice gd, VoxelSprite sprite) { Instance = this; graphicsDevice = gd; spriteSheet = sprite; drawEffect = new BasicEffect(gd) { VertexColorEnabled = true }; }
public Head(Vector3 pos, Room room, VoxelSprite sprite) : base(pos, room, sprite) { Type = EnemyType.Head; Position.Z -= 5f; numFrames = 1; offsetFrame = 0; numAttackFrames = 7; Health = 500f; }
public Head(Vector3 pos, Room room, VoxelSprite sprite) : base(pos, room, sprite) { Type = EnemyType.Head; Position.Z -= 5f; numFrames = 1; offsetFrame = 0; numAttackFrames = 7; Health = 500f; }
public Door(Vector3 pos, int dir, VoxelSprite sheet) { Position = pos; Dir = dir; if (Dir == 0 || Dir == 2) { CollisionBox = new BoundingBox(pos - new Vector3(4f, 1f, 4f), pos + new Vector3(4f, 1f, 4f)); } else { CollisionBox = new BoundingBox(pos - new Vector3(1f, 4f, 4f), pos + new Vector3(1f, 4f, 4f)); } spriteSheet = sheet; }
public Room(VoxelSprite tileSheet, VoxelSprite objects, bool isGap) { IsGap = isGap; if (!isGap) { World = new VoxelWorld(15, 9, 1, true); CreateMap(tileSheet); } else IsComplete = true; //IsComplete = true; objectSheet = objects; }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); AudioController.LoadContent(Content); tileSheet = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(Content.RootDirectory, "tiles.vxs"), ref tileSheet); doorSheet = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(Content.RootDirectory, "door.vxs"), ref doorSheet); objectSheet = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(Content.RootDirectory, "dynamic.vxs"), ref objectSheet); gameCamera = new Camera(GraphicsDevice, GraphicsDevice.Viewport); particleController = new ParticleController(GraphicsDevice); projectileController = new ProjectileController(GraphicsDevice); bombController = new BombController(GraphicsDevice, objectSheet); enemyController = new EnemyController(GraphicsDevice); projectileController.LoadContent(Content); enemyController.LoadContent(Content); drawEffect = new BasicEffect(GraphicsDevice) { World = gameCamera.worldMatrix, View = gameCamera.viewMatrix, Projection = gameCamera.projectionMatrix, VertexColorEnabled = true, }; gameHero = new Hero(0, 0, Vector3.Zero); gameHero.LoadContent(Content, GraphicsDevice); ThreadPool.QueueUserWorkItem(delegate { CreateRoomsAsync(); }); Doors.Add(new Door(VoxelWorld.ToScreenSpace((7 * 16) + 7, 7, 21) + new Vector3(Voxel.HALF_SIZE, Voxel.HALF_SIZE, Voxel.HALF_SIZE), 0, doorSheet)); Doors.Add(new Door(VoxelWorld.ToScreenSpace((14 * 16) + 7, (4 * 16) + 7, 21) + new Vector3(Voxel.HALF_SIZE, Voxel.HALF_SIZE, Voxel.HALF_SIZE), 1, doorSheet)); Doors.Add(new Door(VoxelWorld.ToScreenSpace((7 * 16) + 7, (8 * 16) + 7, 21) + new Vector3(Voxel.HALF_SIZE, Voxel.HALF_SIZE, Voxel.HALF_SIZE), 2, doorSheet)); Doors.Add(new Door(VoxelWorld.ToScreenSpace(7, (4 * 16) + 7, 21) + new Vector3(Voxel.HALF_SIZE, Voxel.HALF_SIZE, Voxel.HALF_SIZE), 3, doorSheet)); roomIcon = Content.Load <Texture2D>("roomicon"); font = Content.Load <SpriteFont>("font"); }
public Door(Vector3 pos, int dir, VoxelSprite sheet) { Position = pos; Dir = dir; if (Dir == 0 || Dir == 2) { CollisionBox = new BoundingBox(pos - new Vector3(4f, 1f, 4f), pos + new Vector3(4f, 1f, 4f)); } else { CollisionBox = new BoundingBox(pos - new Vector3(1f, 4f, 4f), pos + new Vector3(1f, 4f, 4f)); } switch (Dir) { case 0: ParticlePosition = Position + new Vector3(0f, -15f, 0f); ParticleDir = new Vector3(0f, 1f, 0f); break; case 1: ParticlePosition = Position + new Vector3(15f, 0f, 0f); ParticleDir = new Vector3(-1f, 0f, 0f); break; case 2: ParticlePosition = Position + new Vector3(0f, 15f, 0f); ParticleDir = new Vector3(0f, -1f, 0f); break; case 3: ParticlePosition = Position + new Vector3(-15f, 0f, 0f); ParticleDir = new Vector3(1f, 0f, 0f); break; } spriteSheet = sheet; }
public void LoadContent(ContentManager content) { VoxelSprite manhack = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "enemies", "manhack.vxs"), ref manhack); spriteSheets.Add("Manhack", manhack); VoxelSprite sentinel = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "enemies", "sentinel.vxs"), ref sentinel); spriteSheets.Add("Sentinel", sentinel); VoxelSprite head = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "enemies", "head.vxs"), ref head); spriteSheets.Add("Head", head); VoxelSprite ooze = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "enemies", "ooze.vxs"), ref ooze); spriteSheets.Add("Ooze", ooze); }
void CreateMap(VoxelSprite tileSheet) { for (int x = 0; x < 15; x++) { for (int y = 0; y < 9; y++) { wallRots[x, y] = MathHelper.PiOver2 * (float)Helper.Random.Next(4); if (x == 0 || x == 14 || y == 0 || y == 8) { if (x != 7 && y != 4) { World.CopySprite(x * Chunk.X_SIZE, y * Chunk.X_SIZE, 14, tileSheet.AnimChunks[0], Helper.Random.Next(4), 0); } else { World.CopySprite(x * Chunk.X_SIZE, y * Chunk.X_SIZE, 14, tileSheet.AnimChunks[(x == 7 ? 2 : 1)], 0, 0); } } } } for (int i = 0; i < 3; i++) { int rx = 1 + Helper.Random.Next(6); int ry = 1 + Helper.Random.Next(3); int t = 6 + Helper.Random.Next(1); World.CopySprite(rx * Chunk.X_SIZE, ry * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); World.CopySprite((14 - rx) * Chunk.X_SIZE, ry * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); World.CopySprite(rx * Chunk.X_SIZE, (8 - ry) * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); World.CopySprite((14 - rx) * Chunk.X_SIZE, (8 - ry) * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); } for (int i = 0; i < 1; i++) { int rx = 2 + Helper.Random.Next(5); int t = 4 + Helper.Random.Next(3); World.CopySprite(rx * Chunk.X_SIZE, 4 * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); World.CopySprite((14 - rx) * Chunk.X_SIZE, 4 * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); } for (int i = 0; i < 1; i++) { int ry = 2 + Helper.Random.Next(2); int t = 4 + Helper.Random.Next(3); World.CopySprite(7 * Chunk.X_SIZE, ry * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); World.CopySprite(7 * Chunk.X_SIZE, (8 - ry) * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); } //if (!((rx == 1 || rx == 14) && ry == 4) && !((ry == 1 || ry == 8) && rx == 7)) //{ // World.CopySprite(rx * Chunk.X_SIZE, ry * Chunk.X_SIZE, 14, tileSheet.AnimChunks[3], 0); //} int enemiesSpawned = 0; for (int x = 1; x < 14; x++) { for (int y = 1; y < 8; y++) { if (!World.GetVoxel((x * Chunk.X_SIZE) + (Chunk.X_SIZE / 2), (y * Chunk.Y_SIZE) + (Chunk.Y_SIZE / 2), 21).Active) { // Create an enemy? if (enemiesSpawned < 4 && Helper.Random.Next(50) == 1) { enemiesSpawned++; EnemyType type = (EnemyType)Helper.Random.Next(Enum.GetValues(typeof(EnemyType)).Length); EnemyController.Instance.Spawn(type, VoxelWorld.ToScreenSpace((x * Chunk.X_SIZE) + (Chunk.X_SIZE / 2), (y * Chunk.Y_SIZE) + (Chunk.Y_SIZE / 2), 21), this); } } } } World.UpdateWorldMeshes(); }
void CreateMap(VoxelSprite tileSheet) { for (int x = 0; x < 15; x++) for (int y = 0; y < 9; y++) { wallRots[x, y] = MathHelper.PiOver2 * (float)Helper.Random.Next(4); if (x == 0 || x == 14 || y == 0 || y == 8) if (x != 7 && y != 4) World.CopySprite(x * Chunk.X_SIZE, y * Chunk.X_SIZE, 14, tileSheet.AnimChunks[0], Helper.Random.Next(4), 0); else World.CopySprite(x * Chunk.X_SIZE, y * Chunk.X_SIZE, 14, tileSheet.AnimChunks[(x == 7 ? 2 : 1)], 0, 0); } for (int i = 0; i < 3; i++) { int rx = 1 + Helper.Random.Next(6); int ry = 1 + Helper.Random.Next(3); int t = 6 + Helper.Random.Next(1); World.CopySprite(rx * Chunk.X_SIZE, ry * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); World.CopySprite((14 - rx) * Chunk.X_SIZE, ry * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); World.CopySprite(rx * Chunk.X_SIZE, (8 - ry) * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); World.CopySprite((14 - rx) * Chunk.X_SIZE, (8 - ry) * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); if(Helper.Random.Next(5)==1) PickupController.Instance.Spawn(PickupType.Health, this, VoxelWorld.ToScreenSpace((rx * Chunk.X_SIZE) + (Chunk.X_SIZE / 2), (ry * Chunk.Y_SIZE) + (Chunk.Y_SIZE / 2), 21)); if (Helper.Random.Next(5) == 1) PickupController.Instance.Spawn(PickupType.Health, this, VoxelWorld.ToScreenSpace(((14 - rx) * Chunk.X_SIZE) + (Chunk.X_SIZE / 2), (ry * Chunk.Y_SIZE) + (Chunk.Y_SIZE / 2), 21)); if (Helper.Random.Next(5) == 1) PickupController.Instance.Spawn(PickupType.Health, this, VoxelWorld.ToScreenSpace((rx * Chunk.X_SIZE) + (Chunk.X_SIZE / 2), ((8 - ry) * Chunk.Y_SIZE) + (Chunk.Y_SIZE / 2), 21)); if (Helper.Random.Next(5) == 1) PickupController.Instance.Spawn(PickupType.Health, this, VoxelWorld.ToScreenSpace(((14 - rx) * Chunk.X_SIZE) + (Chunk.X_SIZE / 2), ((8 - ry) * Chunk.Y_SIZE) + (Chunk.Y_SIZE / 2), 21)); } for (int i = 0; i < 1; i++) { int rx = 2 + Helper.Random.Next(5); int t = 4 + Helper.Random.Next(3); World.CopySprite(rx * Chunk.X_SIZE, 4 * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); World.CopySprite((14 - rx) * Chunk.X_SIZE, 4 * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); } for (int i = 0; i < 1; i++) { int ry = 2 + Helper.Random.Next(2); int t = 4 + Helper.Random.Next(3); World.CopySprite(7 * Chunk.X_SIZE, ry * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); World.CopySprite(7 * Chunk.X_SIZE, (8 - ry) * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); } //if (!((rx == 1 || rx == 14) && ry == 4) && !((ry == 1 || ry == 8) && rx == 7)) //{ // World.CopySprite(rx * Chunk.X_SIZE, ry * Chunk.X_SIZE, 14, tileSheet.AnimChunks[3], 0); //} int enemiesSpawned = 0; bool headSpawned = false; bool oozeSpawned = false; int numEnemies = 0 + Helper.Random.Next(6); while (enemiesSpawned < numEnemies) { for (int x = 1; x < 14; x++) for (int y = 1; y < 8; y++) { if (!World.GetVoxel((x * Chunk.X_SIZE) + (Chunk.X_SIZE / 2), (y * Chunk.Y_SIZE) + (Chunk.Y_SIZE / 2), 23).Active) { // Create an enemy? if (!(x == 7 && y == 4)) { if (enemiesSpawned < numEnemies && Helper.Random.Next(50) == 1) { EnemyType type = (EnemyType)Helper.Random.Next(Enum.GetValues(typeof(EnemyType)).Length); if (type != EnemyType.Head) { if (type == EnemyType.Ooze && oozeSpawned) continue; if(type== EnemyType.Ooze) oozeSpawned = true; EnemyController.Instance.Spawn(type, VoxelWorld.ToScreenSpace((x * Chunk.X_SIZE) + (Chunk.X_SIZE / 2), (y * Chunk.Y_SIZE) + (Chunk.Y_SIZE / 2), 21), this); enemiesSpawned++; } } } if (x == 7 && y == 4) { if (enemiesSpawned < numEnemies && !headSpawned && Helper.Random.Next(5) == 1) { enemiesSpawned++; EnemyController.Instance.Spawn(EnemyType.Head, VoxelWorld.ToScreenSpace((x * Chunk.X_SIZE) + (Chunk.X_SIZE / 2), (y * Chunk.Y_SIZE) + (Chunk.Y_SIZE / 2), 21), this); headSpawned = true; } } } } } World.UpdateWorldMeshes(); }
public Manhack(Vector3 pos, Room room, VoxelSprite sprite) : base(pos, room, sprite) { Position.Z -= 2f; animTargetTime = 30f; }
public void LoadContent(ContentManager content) { pickupStrip = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "dynamic.vxs"), ref pickupStrip); }
public static void LoadSprite(string fn, ref VoxelSprite sprite) { byte[] buffer; using (FileStream gstr = new FileStream(fn, FileMode.Open)) { byte[] lb = new byte[4]; gstr.Position = gstr.Length - 4; gstr.Read(lb, 0, 4); int msgLength = BitConverter.ToInt32(lb, 0); buffer = new byte[msgLength]; gstr.Position = 0; using (GZipStream str = new GZipStream(gstr, CompressionMode.Decompress)) { str.Read(buffer, 0, msgLength); } } int pos = 0; int xs = buffer[0]; int ys = buffer[1]; int zs = buffer[2]; int frames = buffer[3]; sprite = new VoxelSprite(xs, ys, zs); sprite.AnimChunks.Clear(); sprite.ChunkRTs.Clear(); pos = 4; for (int i = 0; i < 10; i++) { // don't need swatches in game! pos += 3; } for (int frame = 0; frame < frames; frame++) { sprite.AddFrame(false); AnimChunk c = sprite.AnimChunks[frame]; while (pos < buffer.Length) { if (Convert.ToChar(buffer[pos]) != 'c') { //str.Seek(-1, SeekOrigin.Current); //str.Read(ba, 0, 10); int vx = buffer[pos]; int vy = buffer[pos + 1]; int vz = buffer[pos + 2]; Color top = new Color(buffer[pos + 3], buffer[pos + 4], buffer[pos + 5]); c.SetVoxel(vx, vy, vz, true, top); pos += 6; } else { pos++; break; } } c.UpdateMesh(); } GC.Collect(); }
public void LoadContent(ContentManager content) { projectileStrip = new VoxelSprite(5, 5, 5); LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "projectiles.vxs"), ref projectileStrip); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { generatedPercent = 0; // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); if (firstRun) { AudioController.LoadContent(Content); tileSheet = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(Content.RootDirectory, "tiles.vxs"), ref tileSheet); doorSheet = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(Content.RootDirectory, "door.vxs"), ref doorSheet); objectSheet = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(Content.RootDirectory, "dynamic.vxs"), ref objectSheet); } else if (AudioController.instances["roomscrape"].State == SoundState.Playing) { AudioController.instances["roomscrape"].Pause(); } gameCamera = new Camera(GraphicsDevice, GraphicsDevice.Viewport); particleController = new ParticleController(GraphicsDevice); projectileController = new ProjectileController(GraphicsDevice); pickupController = new PickupController(GraphicsDevice); bombController = new BombController(GraphicsDevice, objectSheet); enemyController = new EnemyController(GraphicsDevice); projectileController.LoadContent(Content); pickupController.LoadContent(Content); enemyController.LoadContent(Content); drawEffect = new BasicEffect(GraphicsDevice) { World = gameCamera.worldMatrix, View = gameCamera.viewMatrix, Projection = gameCamera.projectionMatrix, VertexColorEnabled = true, }; gameHero = new Hero(0, 0, Vector3.Zero, Vector3.Zero); gameHero.LoadContent(Content, GraphicsDevice); ThreadPool.QueueUserWorkItem(delegate { CreateRoomsAsync(); }); doorCountdown = 10000; roomMovesLeft = 0; roomShift = null; roomState = RoomState.DoorsOpen; deadTime = 0; allRoomsComplete = false; shownComplete = false; showCompleteTime = 0; showCompleteAlpha = 0f; Doors.Clear(); Doors.Add(new Door(VoxelWorld.ToScreenSpace((7 * 16) + 7, 7, 21) + new Vector3(Voxel.HALF_SIZE, Voxel.HALF_SIZE, Voxel.HALF_SIZE), 0, doorSheet)); Doors.Add(new Door(VoxelWorld.ToScreenSpace((14 * 16) + 7, (4 * 16) + 7, 21) + new Vector3(Voxel.HALF_SIZE, Voxel.HALF_SIZE, Voxel.HALF_SIZE), 1, doorSheet)); Doors.Add(new Door(VoxelWorld.ToScreenSpace((7 * 16) + 7, (8 * 16) + 7, 21) + new Vector3(Voxel.HALF_SIZE, Voxel.HALF_SIZE, Voxel.HALF_SIZE), 2, doorSheet)); Doors.Add(new Door(VoxelWorld.ToScreenSpace(7, (4 * 16) + 7, 21) + new Vector3(Voxel.HALF_SIZE, Voxel.HALF_SIZE, Voxel.HALF_SIZE), 3, doorSheet)); if (firstRun) { roomIcon = Content.Load <Texture2D>("roomicon"); texHud = Content.Load <Texture2D>("hud"); texTitle = Content.Load <Texture2D>("titlesheet"); texTitleBG = Content.Load <Texture2D>("title-bg"); texStingers = Content.Load <Texture2D>("stingers"); font = Content.Load <SpriteFont>("font"); timerFontLarge = Content.Load <SpriteFont>("timerfont-large"); timerFontSmall = Content.Load <SpriteFont>("timerfont-small"); } firstRun = false; }
void CreateMap(VoxelSprite tileSheet) { for (int x = 0; x < 15; x++) { for (int y = 0; y < 9; y++) { wallRots[x, y] = MathHelper.PiOver2 * (float)Helper.Random.Next(4); if (x == 0 || x == 14 || y == 0 || y == 8) { if (x != 7 && y != 4) { World.CopySprite(x * Chunk.X_SIZE, y * Chunk.X_SIZE, 14, tileSheet.AnimChunks[0], Helper.Random.Next(4), 0); } else { World.CopySprite(x * Chunk.X_SIZE, y * Chunk.X_SIZE, 14, tileSheet.AnimChunks[(x == 7 ? 2 : 1)], 0, 0); } } } } for (int i = 0; i < 3; i++) { int rx = 1 + Helper.Random.Next(6); int ry = 1 + Helper.Random.Next(3); int t = 6 + Helper.Random.Next(1); World.CopySprite(rx * Chunk.X_SIZE, ry * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); World.CopySprite((14 - rx) * Chunk.X_SIZE, ry * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); World.CopySprite(rx * Chunk.X_SIZE, (8 - ry) * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); World.CopySprite((14 - rx) * Chunk.X_SIZE, (8 - ry) * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); if (Helper.Random.Next(5) == 1) { PickupController.Instance.Spawn(PickupType.Health, this, VoxelWorld.ToScreenSpace((rx * Chunk.X_SIZE) + (Chunk.X_SIZE / 2), (ry * Chunk.Y_SIZE) + (Chunk.Y_SIZE / 2), 21)); } if (Helper.Random.Next(5) == 1) { PickupController.Instance.Spawn(PickupType.Health, this, VoxelWorld.ToScreenSpace(((14 - rx) * Chunk.X_SIZE) + (Chunk.X_SIZE / 2), (ry * Chunk.Y_SIZE) + (Chunk.Y_SIZE / 2), 21)); } if (Helper.Random.Next(5) == 1) { PickupController.Instance.Spawn(PickupType.Health, this, VoxelWorld.ToScreenSpace((rx * Chunk.X_SIZE) + (Chunk.X_SIZE / 2), ((8 - ry) * Chunk.Y_SIZE) + (Chunk.Y_SIZE / 2), 21)); } if (Helper.Random.Next(5) == 1) { PickupController.Instance.Spawn(PickupType.Health, this, VoxelWorld.ToScreenSpace(((14 - rx) * Chunk.X_SIZE) + (Chunk.X_SIZE / 2), ((8 - ry) * Chunk.Y_SIZE) + (Chunk.Y_SIZE / 2), 21)); } } for (int i = 0; i < 1; i++) { int rx = 2 + Helper.Random.Next(5); int t = 4 + Helper.Random.Next(3); World.CopySprite(rx * Chunk.X_SIZE, 4 * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); World.CopySprite((14 - rx) * Chunk.X_SIZE, 4 * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); } for (int i = 0; i < 1; i++) { int ry = 2 + Helper.Random.Next(2); int t = 4 + Helper.Random.Next(3); World.CopySprite(7 * Chunk.X_SIZE, ry * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); World.CopySprite(7 * Chunk.X_SIZE, (8 - ry) * Chunk.X_SIZE, 14, tileSheet.AnimChunks[t], 0, 1); } //if (!((rx == 1 || rx == 14) && ry == 4) && !((ry == 1 || ry == 8) && rx == 7)) //{ // World.CopySprite(rx * Chunk.X_SIZE, ry * Chunk.X_SIZE, 14, tileSheet.AnimChunks[3], 0); //} int enemiesSpawned = 0; bool headSpawned = false; bool oozeSpawned = false; int numEnemies = 0 + Helper.Random.Next(6); while (enemiesSpawned < numEnemies) { for (int x = 1; x < 14; x++) { for (int y = 1; y < 8; y++) { if (!World.GetVoxel((x * Chunk.X_SIZE) + (Chunk.X_SIZE / 2), (y * Chunk.Y_SIZE) + (Chunk.Y_SIZE / 2), 23).Active) { // Create an enemy? if (!(x == 7 && y == 4)) { if (enemiesSpawned < numEnemies && Helper.Random.Next(50) == 1) { EnemyType type = (EnemyType)Helper.Random.Next(Enum.GetValues(typeof(EnemyType)).Length); if (type != EnemyType.Head) { if (type == EnemyType.Ooze && oozeSpawned) { continue; } if (type == EnemyType.Ooze) { oozeSpawned = true; } EnemyController.Instance.Spawn(type, VoxelWorld.ToScreenSpace((x * Chunk.X_SIZE) + (Chunk.X_SIZE / 2), (y * Chunk.Y_SIZE) + (Chunk.Y_SIZE / 2), 21), this); enemiesSpawned++; } } } if (x == 7 && y == 4) { if (enemiesSpawned < numEnemies && !headSpawned && Helper.Random.Next(5) == 1) { enemiesSpawned++; EnemyController.Instance.Spawn(EnemyType.Head, VoxelWorld.ToScreenSpace((x * Chunk.X_SIZE) + (Chunk.X_SIZE / 2), (y * Chunk.Y_SIZE) + (Chunk.Y_SIZE / 2), 21), this); headSpawned = true; } } } } } } World.UpdateWorldMeshes(); }
public static void LoadSprite(string fn, ref VoxelSprite sprite) { byte[] buffer; using (FileStream gstr = new FileStream(fn, FileMode.Open)) { byte[] lb = new byte[4]; gstr.Position = gstr.Length - 4; gstr.Read(lb, 0, 4); int msgLength = BitConverter.ToInt32(lb, 0); buffer = new byte[msgLength]; gstr.Position = 0; using (GZipStream str = new GZipStream(gstr, CompressionMode.Decompress)) { str.Read(buffer, 0, msgLength); } } int pos = 0; int xs = buffer[0]; int ys = buffer[1]; int zs = buffer[2]; int frames = buffer[3]; sprite = new VoxelSprite(xs, ys, zs); sprite.AnimChunks.Clear(); sprite.ChunkRTs.Clear(); pos = 4; for (int i = 0; i < 10; i++) { // don't need swatches in game! pos += 3; } for (int frame = 0; frame < frames; frame++) { sprite.AddFrame(false); AnimChunk c = sprite.AnimChunks[frame]; while (pos < buffer.Length) { if (Convert.ToChar(buffer[pos]) != 'c') { //str.Seek(-1, SeekOrigin.Current); //str.Read(ba, 0, 10); int vx = buffer[pos]; int vy = buffer[pos + 1]; int vz = buffer[pos + 2]; Color top = new Color(buffer[pos + 3], buffer[pos + 4], buffer[pos + 5]); c.SetVoxel(vx, vy, vz, true, top); pos += 6; } else { pos++; break; } } c.UpdateMesh(); } GC.Collect(); }
public Ooze(Vector3 pos, Room room, VoxelSprite sprite) : base(pos, room, sprite) { Target = new Vector3(room.World.X_SIZE * Voxel.SIZE, room.World.Y_SIZE * Voxel.SIZE, pos.Z); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { generatedPercent = 0; // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); if (firstRun) { AudioController.LoadContent(Content); tileSheet = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(Content.RootDirectory, "tiles.vxs"), ref tileSheet); doorSheet = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(Content.RootDirectory, "door.vxs"), ref doorSheet); objectSheet = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(Content.RootDirectory, "dynamic.vxs"), ref objectSheet); } else if (AudioController.instances["roomscrape"].State == SoundState.Playing) AudioController.instances["roomscrape"].Pause(); gameCamera = new Camera(GraphicsDevice, GraphicsDevice.Viewport); particleController = new ParticleController(GraphicsDevice); projectileController = new ProjectileController(GraphicsDevice); pickupController = new PickupController(GraphicsDevice); bombController = new BombController(GraphicsDevice, objectSheet); enemyController = new EnemyController(GraphicsDevice); projectileController.LoadContent(Content); pickupController.LoadContent(Content); enemyController.LoadContent(Content); drawEffect = new BasicEffect(GraphicsDevice) { World = gameCamera.worldMatrix, View = gameCamera.viewMatrix, Projection = gameCamera.projectionMatrix, VertexColorEnabled = true, }; gameHero = new Hero(0, 0, Vector3.Zero, Vector3.Zero); gameHero.LoadContent(Content, GraphicsDevice); ThreadPool.QueueUserWorkItem(delegate { CreateRoomsAsync(); }); doorCountdown = 10000; roomMovesLeft = 0; roomShift = null; roomState = RoomState.DoorsOpen; deadTime = 0; allRoomsComplete = false; shownComplete = false; showCompleteTime = 0; showCompleteAlpha = 0f; Doors.Clear(); Doors.Add(new Door(VoxelWorld.ToScreenSpace((7 * 16) + 7, 7, 21) + new Vector3(Voxel.HALF_SIZE,Voxel.HALF_SIZE,Voxel.HALF_SIZE), 0, doorSheet)); Doors.Add(new Door(VoxelWorld.ToScreenSpace((14 * 16) + 7, (4 * 16) + 7, 21) + new Vector3(Voxel.HALF_SIZE, Voxel.HALF_SIZE, Voxel.HALF_SIZE), 1, doorSheet)); Doors.Add(new Door(VoxelWorld.ToScreenSpace((7 * 16) + 7, (8 * 16) + 7, 21) + new Vector3(Voxel.HALF_SIZE, Voxel.HALF_SIZE, Voxel.HALF_SIZE), 2, doorSheet)); Doors.Add(new Door(VoxelWorld.ToScreenSpace(7, (4 * 16) + 7, 21) + new Vector3(Voxel.HALF_SIZE, Voxel.HALF_SIZE, Voxel.HALF_SIZE), 3, doorSheet)); if (firstRun) { roomIcon = Content.Load<Texture2D>("roomicon"); texHud = Content.Load<Texture2D>("hud"); texTitle = Content.Load<Texture2D>("titlesheet"); texTitleBG = Content.Load<Texture2D>("title-bg"); texStingers = Content.Load<Texture2D>("stingers"); font = Content.Load<SpriteFont>("font"); timerFontLarge = Content.Load<SpriteFont>("timerfont-large"); timerFontSmall = Content.Load<SpriteFont>("timerfont-small"); } firstRun = false; }
public void LoadContent(ContentManager content) { pickupStrip = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "dynamic.vxs"), ref pickupStrip); }
public void LoadContent(ContentManager content, GraphicsDevice gd) { spriteSheet = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "dude.vxs"), ref spriteSheet); drawEffect = new BasicEffect(gd) { VertexColorEnabled = true }; }
public void LoadContent(ContentManager content) { projectileStrip = new VoxelSprite(5, 5, 5); LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "projectiles.vxs"), ref projectileStrip); }
public void LoadContent(ContentManager content) { VoxelSprite manhack = new VoxelSprite(16,16,16); LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "enemies", "manhack.vxs"), ref manhack); spriteSheets.Add("Manhack", manhack); VoxelSprite sentinel = new VoxelSprite(16,16,16); LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "enemies", "sentinel.vxs"), ref sentinel); spriteSheets.Add("Sentinel", sentinel); VoxelSprite head = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "enemies", "head.vxs"), ref head); spriteSheets.Add("Head", head); VoxelSprite ooze = new VoxelSprite(16, 16, 16); LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "enemies", "ooze.vxs"), ref ooze); spriteSheets.Add("Ooze", ooze); }