Created a functional boss fight
This commit is contained in:
parent
26d55ab6ca
commit
d4426b8b3c
|
|
@ -47,7 +47,7 @@ public class BossBars
|
||||||
}
|
}
|
||||||
|
|
||||||
for(IBossBar bossbar : toRemove) {
|
for(IBossBar bossbar : toRemove) {
|
||||||
bossbars.remove(toRemove);
|
bossbars.remove(bossbar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,12 +42,6 @@ public class EntityBoss extends EntityVertical implements IBossBar
|
||||||
this.noise_walk = new OpenSimplexNoise(rand.nextLong());
|
this.noise_walk = new OpenSimplexNoise(rand.nextLong());
|
||||||
this.noise_spawn = new OpenSimplexNoise(rand.nextLong());
|
this.noise_spawn = new OpenSimplexNoise(rand.nextLong());
|
||||||
|
|
||||||
Main.player.gun_level = 4;
|
|
||||||
Main.player.defence_level = 4;
|
|
||||||
Main.player.getInventory().setItem(new ItemStack(Items.HEALTH_POTION, 100, (byte)50), 0);
|
|
||||||
Main.player.getInventory().setItem(new ItemStack(Items.TNT, 100, (byte)10), 1);
|
|
||||||
Main.player.getInventory().setItem(new ItemStack(Items.GRAPPLING_HOOK, 100, (byte)2), 2);
|
|
||||||
|
|
||||||
BossBars.register(this);
|
BossBars.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -223,4 +217,9 @@ public class EntityBoss extends EntityVertical implements IBossBar
|
||||||
Items.AMMO, RandomHelpers.randrange(rand, 200), (byte)50)));
|
Items.AMMO, RandomHelpers.randrange(rand, 200), (byte)50)));
|
||||||
layer.spawnEntity(new EntityItem(pos.copy(), new ItemStack(Items.GRAPPLING_HOOK, 1, (byte)2)));
|
layer.spawnEntity(new EntityItem(pos.copy(), new ItemStack(Items.GRAPPLING_HOOK, 1, (byte)2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void push(double amount, double angle) {
|
||||||
|
super.push(amount, angle / 10.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,8 @@ public class EntityGrapplingHook extends EntityVertical
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(layer instanceof LayerGenRememberPlayerPos) {
|
if(layer.layergen instanceof LayerGenRememberPlayerPos) {
|
||||||
LayerGenRememberPlayerPos lgrpp = (LayerGenRememberPlayerPos)layer;
|
LayerGenRememberPlayerPos lgrpp = (LayerGenRememberPlayerPos)layer.layergen;
|
||||||
entity.pos = lgrpp.getPlayerPos();
|
entity.pos = lgrpp.getPlayerPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ public class EntityPlayer extends EntityVertical implements EntityAlive, EntityI
|
||||||
int d = (int)(1 + gun_level / 4.0);
|
int d = (int)(1 + gun_level / 4.0);
|
||||||
int b = (int)(1 + gun_level / 4.0);
|
int b = (int)(1 + gun_level / 4.0);
|
||||||
Main.world.getLayer().spawnEntity(new EntityBullet(pos.copy(), this, angle + this.angle,
|
Main.world.getLayer().spawnEntity(new EntityBullet(pos.copy(), this, angle + this.angle,
|
||||||
20*d*d, 5/b, 60));
|
20*d*d, 5/b, 60).withHeight(0, height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,10 @@ import java.util.ArrayList;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import shootergame.Main;
|
import shootergame.Main;
|
||||||
import shootergame.util.math.vec.Vec2d;
|
|
||||||
import shootergame.world.World;
|
import shootergame.world.World;
|
||||||
import shootergame.world.layer.Layer;
|
import shootergame.world.layer.Layer;
|
||||||
import shootergame.world.layer.layergen.LayerGenBossArena;
|
|
||||||
import shootergame.world.layer.layergen.LayerGenCaves;
|
import shootergame.world.layer.layergen.LayerGenCaves;
|
||||||
|
import shootergame.world.layer.layergen.LayerGenEarth;
|
||||||
import shootergame.world.layer.layergen.LayerGenLavaCaves;
|
import shootergame.world.layer.layergen.LayerGenLavaCaves;
|
||||||
|
|
||||||
public class Layers
|
public class Layers
|
||||||
|
|
@ -18,7 +17,7 @@ public class Layers
|
||||||
public static void init(long seed)
|
public static void init(long seed)
|
||||||
{
|
{
|
||||||
// Create all the layers
|
// Create all the layers
|
||||||
EARTH = new Layer(new Random(seed), new LayerGenBossArena(), 0);
|
EARTH = new Layer(new Random(seed), new LayerGenEarth(), 0);
|
||||||
CAVES = new Layer(new Random(seed), new LayerGenCaves(), 1);
|
CAVES = new Layer(new Random(seed), new LayerGenCaves(), 1);
|
||||||
LAVA_CAVES = new Layer(new Random(seed), new LayerGenLavaCaves(), 2);
|
LAVA_CAVES = new Layer(new Random(seed), new LayerGenLavaCaves(), 2);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package shootergame.init;
|
package shootergame.init;
|
||||||
|
|
||||||
import shootergame.tiles.Tile;
|
import shootergame.tiles.Tile;
|
||||||
|
import shootergame.tiles.TileBossPortal;
|
||||||
import shootergame.tiles.TileChest;
|
import shootergame.tiles.TileChest;
|
||||||
import shootergame.tiles.TileDirt;
|
import shootergame.tiles.TileDirt;
|
||||||
import shootergame.tiles.TileFire;
|
import shootergame.tiles.TileFire;
|
||||||
|
|
@ -42,4 +43,5 @@ public class Tiles
|
||||||
public static final Tile CHEST = new TileChest("chest");
|
public static final Tile CHEST = new TileChest("chest");
|
||||||
public static final Tile LANTERN = new TileLantern("lantern");
|
public static final Tile LANTERN = new TileLantern("lantern");
|
||||||
public static final Tile WALL_UNBREAKABLE = new TileWallUnbreakable("wall_unbreakable");
|
public static final Tile WALL_UNBREAKABLE = new TileWallUnbreakable("wall_unbreakable");
|
||||||
|
public static final Tile BOSS_PORTAL = new TileBossPortal("boss_portal");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,11 @@
|
||||||
package shootergame.items;
|
package shootergame.items;
|
||||||
|
|
||||||
import shootergame.Main;
|
|
||||||
import shootergame.entity.Entity;
|
import shootergame.entity.Entity;
|
||||||
import shootergame.entity.EntityGrapplingHook;
|
import shootergame.entity.EntityGrapplingHook;
|
||||||
import shootergame.init.Layers;
|
|
||||||
import shootergame.init.Textures;
|
import shootergame.init.Textures;
|
||||||
import shootergame.util.math.ItemStack;
|
import shootergame.util.math.ItemStack;
|
||||||
import shootergame.util.math.MathHelpers;
|
import shootergame.util.math.MathHelpers;
|
||||||
import shootergame.util.math.vec.Vec2d;
|
import shootergame.util.math.vec.Vec2d;
|
||||||
import shootergame.world.World;
|
|
||||||
import shootergame.world.chunk.Chunk;
|
import shootergame.world.chunk.Chunk;
|
||||||
import shootergame.world.layer.Layer;
|
import shootergame.world.layer.Layer;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,85 @@
|
||||||
|
package shootergame.tiles;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import mainloop.task.IMainloopTask;
|
||||||
|
import shootergame.Main;
|
||||||
|
import shootergame.entity.Entity;
|
||||||
|
import shootergame.entity.player.EntityPlayer;
|
||||||
|
import shootergame.init.Textures;
|
||||||
|
import shootergame.util.math.TileState;
|
||||||
|
import shootergame.util.math.vec.Vec2d;
|
||||||
|
import shootergame.util.math.vec.Vec2i;
|
||||||
|
import shootergame.world.chunk.ChunkEventHandler;
|
||||||
|
import shootergame.world.layer.Layer;
|
||||||
|
import shootergame.world.layer.layergen.LayerGenBossArena;
|
||||||
|
|
||||||
|
public class TileBossPortal extends TileVertical
|
||||||
|
{
|
||||||
|
private static Random rand = new Random();
|
||||||
|
|
||||||
|
public TileBossPortal(String id) {
|
||||||
|
super(id, Textures.TILE_BOSS_PORTAL, new Vec2d(2, 2));
|
||||||
|
|
||||||
|
this.emitsLight = true;
|
||||||
|
this.opaqueTile = true;
|
||||||
|
this.tileHitbox = 0.4;
|
||||||
|
this.tileSolid = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getLightLevel(TileState state, Vec2i pos) {
|
||||||
|
return 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onActivated(Layer layer, Vec2i tpos, Entity entity, TileState state) {
|
||||||
|
super.onActivated(layer, tpos, entity, state);
|
||||||
|
|
||||||
|
if(entity instanceof EntityPlayer)
|
||||||
|
{
|
||||||
|
// Get the player and set some player variables
|
||||||
|
EntityPlayer ep = (EntityPlayer)entity;
|
||||||
|
ep.height = 8;
|
||||||
|
|
||||||
|
// Create the boss arena
|
||||||
|
LayerGenBossArena layergen = new LayerGenBossArena();
|
||||||
|
layergen.spawnPlayer(ep);
|
||||||
|
layer.breakFrontTile(tpos);
|
||||||
|
Main.world.setLayer(new Layer(rand, layergen, rand.nextInt()));
|
||||||
|
|
||||||
|
// Do the arena falling animation
|
||||||
|
Main.mainloop.register(new IMainloopTask()
|
||||||
|
{
|
||||||
|
int stage = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void MainLoopUpdate()
|
||||||
|
{
|
||||||
|
if(stage == 0)
|
||||||
|
{
|
||||||
|
// Only do this if the world is loaded
|
||||||
|
if(ChunkEventHandler.loaded)
|
||||||
|
{
|
||||||
|
ep.height -= 0.05;
|
||||||
|
if(ep.height <= 0) {
|
||||||
|
ep.height = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean MainLoopRepeat() {
|
||||||
|
return ep.height > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean MainLoopDelay(long millis) {
|
||||||
|
return millis > 10;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -3,7 +3,6 @@ package shootergame.world.layer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import bdf.types.BdfObject;
|
|
||||||
import shootergame.Main;
|
import shootergame.Main;
|
||||||
import shootergame.display.Camera;
|
import shootergame.display.Camera;
|
||||||
import shootergame.entity.Entity;
|
import shootergame.entity.Entity;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ public class LayerGenBossArena extends LayerGen implements LayerGenRememberPlaye
|
||||||
private final Vec2i center = new Vec2i(0, 0);
|
private final Vec2i center = new Vec2i(0, 0);
|
||||||
private final int size = 10;
|
private final int size = 10;
|
||||||
private Vec2d player_pos = new Vec2d(0, 0);
|
private Vec2d player_pos = new Vec2d(0, 0);
|
||||||
|
private Random rand = new Random();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateChunk(Chunk chunk, Layer layer, long seed, Random rand, Vec2i pos)
|
public void generateChunk(Chunk chunk, Layer layer, long seed, Random rand, Vec2i pos)
|
||||||
|
|
@ -103,7 +104,9 @@ public class LayerGenBossArena extends LayerGen implements LayerGenRememberPlaye
|
||||||
@Override
|
@Override
|
||||||
public void spawnPlayer(EntityPlayer player) {
|
public void spawnPlayer(EntityPlayer player) {
|
||||||
this.player_pos = player.pos.copy();
|
this.player_pos = player.pos.copy();
|
||||||
player.pos = new Vec2d(0, 0);
|
player.pos = new Vec2d(
|
||||||
|
RandomHelpers.randrange(rand, -size + 2, size - 2),
|
||||||
|
RandomHelpers.randrange(rand, -size + 2, size - 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,14 @@ public class LayerGenLavaCaves extends LayerGen
|
||||||
RandomHelpers.randrange(rand, 16));
|
RandomHelpers.randrange(rand, 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean hasBossPortal = PortalSpawnrates.LavaCaveBossArenaPortal(rand);
|
||||||
|
Vec2i boss_portal_pos = null;
|
||||||
|
if(hasBossPortal) {
|
||||||
|
boss_portal_pos = new Vec2i(
|
||||||
|
RandomHelpers.randrange(rand, 16),
|
||||||
|
RandomHelpers.randrange(rand, 16));
|
||||||
|
}
|
||||||
|
|
||||||
// Get some noise generators
|
// Get some noise generators
|
||||||
OpenSimplexNoise noisegen_n = new OpenSimplexNoise(new Random(seed + layer.id).nextLong());
|
OpenSimplexNoise noisegen_n = new OpenSimplexNoise(new Random(seed + layer.id).nextLong());
|
||||||
|
|
||||||
|
|
@ -79,6 +87,13 @@ public class LayerGenLavaCaves extends LayerGen
|
||||||
chunk.setFrontTile(new TileState(Tiles.LADDER_UP, (short)1), ladder_pos);
|
chunk.setFrontTile(new TileState(Tiles.LADDER_UP, (short)1), ladder_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(
|
||||||
|
hasBossPortal &&
|
||||||
|
chunk.getBackTile(boss_portal_pos).tile == getTileDestroyed().tile &&
|
||||||
|
chunk.getFrontTile(boss_portal_pos).tile == Tiles.VOID) {
|
||||||
|
chunk.setFrontTile(Tiles.BOSS_PORTAL.getDefaultState(), boss_portal_pos);
|
||||||
|
}
|
||||||
|
|
||||||
Vec2i chest_pos = new Vec2i(
|
Vec2i chest_pos = new Vec2i(
|
||||||
RandomHelpers.randrange(rand, Chunk.CHUNK_SIZE.mx),
|
RandomHelpers.randrange(rand, Chunk.CHUNK_SIZE.mx),
|
||||||
RandomHelpers.randrange(rand, Chunk.CHUNK_SIZE.my));
|
RandomHelpers.randrange(rand, Chunk.CHUNK_SIZE.my));
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,14 @@ import shootergame.util.math.random.RandomHelpers;
|
||||||
class PortalSpawnrates
|
class PortalSpawnrates
|
||||||
{
|
{
|
||||||
static boolean WorldCavePortal(Random rand) {
|
static boolean WorldCavePortal(Random rand) {
|
||||||
return RandomHelpers.randrange(rand, 2) == 0;
|
return RandomHelpers.randrange(rand, 10) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean CaveLavaCavePortal(Random rand) {
|
static boolean CaveLavaCavePortal(Random rand) {
|
||||||
return RandomHelpers.randrange(rand, 2) == 0;
|
return RandomHelpers.randrange(rand, 10) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean LavaCaveBossArenaPortal(Random rand) {
|
||||||
|
return RandomHelpers.randrange(rand, 5) == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue