This commit is contained in:
Anuken
2020-01-20 18:34:35 -05:00
parent 2fe3fea7f4
commit 26e93c2f06
6 changed files with 28 additions and 44 deletions

View File

@@ -249,35 +249,15 @@ public class Control implements ApplicationListener, Loadable{
});
}
//TODO remove, make it viable on a server
/*public void playZone(Zone zone){
ui.loadAnd(() -> {
logic.reset();
net.reset();
world.loadGenerator(zone.generator);
zone.rules.get(state.rules);
state.rules.zone = zone;
for(TileEntity core : state.teams.playerCores()){
for(ItemStack stack : zone.getStartingItems()){
core.items.add(stack.item, stack.amount);
}
}
state.set(State.playing);
state.wavetime = state.rules.waveSpacing;
control.saves.zoneSave();
logic.play();
Events.fire(Trigger.newGame);
});
}*/
public void playSector(Sector sector){
ui.loadAnd(() -> {
net.reset();
logic.reset();
world.loadSector(sector);
state.set(State.playing);
logic.play();
control.saves.zoneSave();
ui.planet.hide();
Events.fire(Trigger.newGame);
});
}

View File

@@ -16,7 +16,6 @@ import mindustry.type.*;
import mindustry.world.*;
import mindustry.world.blocks.*;
import mindustry.world.blocks.BuildBlock.*;
import mindustry.world.blocks.power.*;
import java.util.*;
@@ -100,6 +99,7 @@ public class Logic implements ApplicationListener{
}
}
/** Adds starting items, resets wave time, and sets state to playing. */
public void play(){
state.set(State.playing);
state.wavetime = state.rules.waveSpacing * 2; //grace period of 2x wave time before game starts

View File

@@ -18,7 +18,7 @@ import static mindustry.Vars.*;
public class PlanetRenderer implements PlanetGenerator{
private final Color outlineColor = Pal.accent.cpy().a(0.7f);
private final float camLength = 4f, outlineRad = 1.15f;
private final boolean drawnRect = true;
private final boolean drawRect = false;
private final PlanetMesh[] outlines = new PlanetMesh[10];
private final Camera3D cam = new Camera3D();
@@ -58,8 +58,7 @@ public class PlanetRenderer implements PlanetGenerator{
}
batch.flush(cam.combined(), Gl.triangleFan);
if(drawnRect){
//TODO hack.
if(drawRect){
SectorRect rect = sector.rect;
rect.center.scl(outlineRad);
rect.right.scl(outlineRad);
@@ -78,12 +77,13 @@ public class PlanetRenderer implements PlanetGenerator{
rect.center.scl(1f / outlineRad);
rect.right.scl(1f / outlineRad);
rect.top.scl(1f / outlineRad);
if(Core.input.keyTap(KeyCode.SPACE)){
control.playSector(sector);
ui.planet.hide();
}
}
if(Core.input.keyTap(KeyCode.SPACE)){
control.playSector(sector);
ui.planet.hide();
}
}
Gl.disable(Gl.depthTest);

View File

@@ -15,14 +15,14 @@ public class TestPlanetGenerator implements PlanetGenerator{
int waterLevel = 5;
float water;
float scl = 5f;
Array<Block> blocks = Array.with(Blocks.sporeMoss, Blocks.moss, Blocks.ice, Blocks.snow, Blocks.sand, Blocks.darksand, Blocks.darksandWater, Blocks.darksandTaintedWater);
Array<Block> blocks = Array.with(Blocks.sporeMoss, Blocks.moss, Blocks.ice, Blocks.snow, Blocks.sand, Blocks.darksand, Blocks.darksandWater, Blocks.darksandTaintedWater, Blocks.iceSnow);
public TestPlanetGenerator(){
try{
pix = new Pixmap("planets/colors.png");
water = waterLevel / (float)(pix.getHeight());
}catch(Exception ignored){
//ignored during headless loading for now
}
}
@@ -39,6 +39,15 @@ public class TestPlanetGenerator implements PlanetGenerator{
@Override
public Color getColor(Vec3 position){
return getBlock(position).color;
}
@Override
public void generate(Vec3 position, TileGen tile){
tile.floor = getBlock(position);
}
Block getBlock(Vec3 position){
float height = getHeight(position);
position = Tmp.v33.set(position).scl(scl);
float rad = scl;
@@ -49,12 +58,7 @@ public class TestPlanetGenerator implements PlanetGenerator{
height = Mathf.clamp(height);
Color color = Tmp.c1.set(pix.getPixel((int)(temp * (pix.getWidth()-1)), (int)((1f-height) * (pix.getHeight()-1))));
return blocks.min(c -> color.diff(c.color)).color;
}
@Override
public void generate(Vec3 position, TileGen tile){
Color color = getColor(position);
tile.floor = blocks.min(c -> color.diff(c.color));
return blocks.min(c -> color.diff(c.color));
}
}

View File

@@ -122,7 +122,7 @@ public class DeployDialog extends FloatingDialog{
setFilter(TextureFilter.Linear);
}}){{
float[] time = {0};
setColor(Color.gray(0.3f));
setColor(Color.grays(0.3f));
setScale(1.5f);
update(() -> {
setOrigin(Align.center);
@@ -140,7 +140,7 @@ public class DeployDialog extends FloatingDialog{
Stack sub = new Stack();
if(slot.getZone() != null){
sub.add(new Table(f -> f.margin(4f).add(new Image()).color(Color.gray(0.1f)).grow()));
sub.add(new Table(f -> f.margin(4f).add(new Image()).color(Color.grays(0.1f)).grow()));
//sub.add(new Table(f -> f.margin(4f).add(new Image(slot.getZone().preview).setScaling(Scaling.fit)).update(img -> {
//TextureRegionDrawable draw = (TextureRegionDrawable)img.getDrawable();
@@ -254,7 +254,7 @@ public class DeployDialog extends FloatingDialog{
//}
// stack.setSize(Tmp.v1.x, Tmp.v1.y);
// stack.add(new Table(t -> t.margin(4f).add(new Image(node.zone.preview).setScaling(Scaling.stretch)).color(node.zone.unlocked() ? Color.darkGray : Color.gray(0.2f)).grow()));
// stack.add(new Table(t -> t.margin(4f).add(new Image(node.zone.preview).setScaling(Scaling.stretch)).color(node.zone.unlocked() ? Color.darkGray : Color.grays(0.2f)).grow()));
stack.update(() -> stack.setPosition(node.x + panX + width / 2f, node.y + panY + height / 2f, Align.center));
Button button = new Button(Styles.squaret);