More block descriptions, improved indicators

This commit is contained in:
Anuken
2017-12-02 14:59:28 -05:00
parent 597c5161e3
commit 9cadb08024
8 changed files with 50 additions and 31 deletions

View File

@ -37,6 +37,7 @@ import io.anuke.ucore.scene.utils.Cursors;
import io.anuke.ucore.util.*; import io.anuke.ucore.util.*;
public class Renderer extends RendererModule{ public class Renderer extends RendererModule{
String[] surfaces = {"shadow", "shield", "pixel", "indicators"};
int targetscale = baseCameraScale; int targetscale = baseCameraScale;
int chunksize = 32; int chunksize = 32;
Cache[][] floorCache; Cache[][] floorCache;
@ -45,15 +46,14 @@ public class Renderer extends RendererModule{
public Renderer() { public Renderer() {
Core.cameraScale = baseCameraScale; Core.cameraScale = baseCameraScale;
Graphics.addSurface("pixel", Core.cameraScale);
} }
@Override @Override
public void init(){ public void init(){
pixelate = Settings.getBool("pixelate"); pixelate = Settings.getBool("pixelate");
Graphics.addSurface("shadow", Settings.getBool("pixelate") ? Core.cameraScale : 1); for(String surface : surfaces){
Graphics.addSurface("shield", Settings.getBool("pixelate") ? Core.cameraScale : 1); Graphics.addSurface(surface, Settings.getBool("pixelate") ? Core.cameraScale : 1);
}
} }
public void setPixelate(boolean pixelate){ public void setPixelate(boolean pixelate){
@ -186,8 +186,9 @@ public class Renderer extends RendererModule{
} }
void drawEnemyMarkers(){ void drawEnemyMarkers(){
Graphics.surface("indicators");
Draw.color(Color.RED); Draw.color(Color.RED);
Draw.alpha(0.6f); //Draw.alpha(0.6f);
for(Enemy enemy : control.enemyGroup.all()){ for(Enemy enemy : control.enemyGroup.all()){
if(Tmp.r1.setSize(camera.viewportWidth, camera.viewportHeight).setCenter(camera.position.x, camera.position.y).overlaps(enemy.hitbox.getRect(enemy.x, enemy.y))){ if(Tmp.r1.setSize(camera.viewportWidth, camera.viewportHeight).setCenter(camera.position.x, camera.position.y).overlaps(enemy.hitbox.getRect(enemy.x, enemy.y))){
@ -199,6 +200,9 @@ public class Renderer extends RendererModule{
Draw.rect("enemyarrow", camera.position.x + Angles.x(), camera.position.y + Angles.y(), angle); Draw.rect("enemyarrow", camera.position.x + Angles.x(), camera.position.y + Angles.y(), angle);
} }
Draw.color(); Draw.color();
Draw.alpha(0.4f);
Graphics.flushSurface();
Draw.color();
} }
void drawShield(){ void drawShield(){
@ -513,9 +517,9 @@ public class Renderer extends RendererModule{
targetscale = amount; targetscale = amount;
clampScale(); clampScale();
if(Settings.getBool("pixelate")){ if(Settings.getBool("pixelate")){
Graphics.getSurface("pixel").setScale(targetscale); for(String surface : surfaces){
Graphics.getSurface("shadow").setScale(targetscale); Graphics.getSurface(surface).setScale(targetscale);
Graphics.getSurface("shield").setScale(targetscale); }
} }
} }

View File

@ -96,6 +96,7 @@ public class UI extends SceneModule{
Colors.put("craftinfo", Color.LIGHT_GRAY); Colors.put("craftinfo", Color.LIGHT_GRAY);
Colors.put("missingitems", Color.SCARLET); Colors.put("missingitems", Color.SCARLET);
Colors.put("health", Color.YELLOW); Colors.put("health", Color.YELLOW);
Colors.put("healthstats", Color.SCARLET);
Colors.put("interact", Color.ORANGE); Colors.put("interact", Color.ORANGE);
Colors.put("accent", Color.valueOf("f4ba6e")); Colors.put("accent", Color.valueOf("f4ba6e"));
} }

View File

@ -84,7 +84,7 @@ public class Block{
public void getStats(Array<String> list){ public void getStats(Array<String> list){
list.add("[gray]size: " + width + "x" + height); list.add("[gray]size: " + width + "x" + height);
list.add("[health]health: " + health); list.add("[healthstats]health: " + health);
} }
public String name(){ public String name(){

View File

@ -6,7 +6,8 @@ import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
/**Used for multiblocks. Each block that is not the center of the multiblock is a blockpart. /**Used for multiblocks. Each block that is not the center of the multiblock is a blockpart.
* Think of these as delegates to the actual block; all events are passed to the target block.*/ * Think of these as delegates to the actual block; all events are passed to the target block.
* They are made to share all properties from the linked tile/block.*/
public class BlockPart extends Block implements PowerAcceptor, LiquidAcceptor{ public class BlockPart extends Block implements PowerAcceptor, LiquidAcceptor{
public BlockPart() { public BlockPart() {
@ -79,10 +80,6 @@ public class BlockPart extends Block implements PowerAcceptor, LiquidAcceptor{
} }
} }
private Block linked(Tile tile){
return tile.getLinked().block();
}
@Override @Override
public void setPower(Tile tile, float power){ public void setPower(Tile tile, float power){
Block block = linked(tile); Block block = linked(tile);
@ -92,5 +89,8 @@ public class BlockPart extends Block implements PowerAcceptor, LiquidAcceptor{
} }
} }
private Block linked(Tile tile){
return tile.getLinked().block();
}
} }

View File

@ -1,5 +1,7 @@
package io.anuke.mindustry.world.blocks.types.defense; package io.anuke.mindustry.world.blocks.types.defense;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.TileEntity; import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.effect.Fx; import io.anuke.mindustry.entities.effect.Fx;
@ -9,10 +11,11 @@ import io.anuke.mindustry.world.blocks.types.PowerBlock;
import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.BulletEntity; import io.anuke.ucore.entities.BulletEntity;
import io.anuke.ucore.util.Strings;
public class ShieldBlock extends PowerBlock{ public class ShieldBlock extends PowerBlock{
public float shieldRadius = 40f; public float shieldRadius = 40f;
public float powerDrain = 0.005f; public float powerDrain = 0.006f;
public float powerPerDamage = 0.1f; public float powerPerDamage = 0.1f;
public ShieldBlock(String name) { public ShieldBlock(String name) {
@ -20,6 +23,14 @@ public class ShieldBlock extends PowerBlock{
voltage = powerDrain; voltage = powerDrain;
} }
@Override
public void getStats(Array<String> list){
super.getStats(list);
list.add("[powerinfo]Power Drain/second: " + Strings.toFixed(powerDrain*60, 2));
list.add("[powerinfo]Power Drain/damage taken: " + Strings.toFixed(powerPerDamage, 2));
list.add("[powerinfo]Shield Radius: " + (int)shieldRadius + " units");
}
@Override @Override
public void update(Tile tile){ public void update(Tile tile){
ShieldEntity entity = tile.entity(); ShieldEntity entity = tile.entity();

View File

@ -7,18 +7,28 @@ import io.anuke.mindustry.Vars;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.PowerAcceptor; import io.anuke.mindustry.world.blocks.types.PowerAcceptor;
import io.anuke.mindustry.world.blocks.types.production.Generator; import io.anuke.mindustry.world.blocks.types.production.Generator;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Mathf; import io.anuke.ucore.util.Mathf;
public class PowerBooster extends Generator{ public class PowerBooster extends Generator{
public int powerRange = 4;
public PowerBooster(String name) { public PowerBooster(String name) {
super(name); super(name);
drawRadius = true;
explosive = false; explosive = false;
hasLasers = false; hasLasers = false;
} }
@Override
public void drawPixelOverlay(Tile tile){
super.drawPixelOverlay(tile);
Draw.color("yellow");
Draw.dashcircle(tile.worldx(), tile.worldy(), powerRange * Vars.tilesize);
Draw.reset();
}
@Override @Override
public void getStats(Array<String> list){ public void getStats(Array<String> list){
super.getStats(list); super.getStats(list);

View File

@ -21,10 +21,8 @@ public class Generator extends PowerBlock{
public int laserRange = 6; public int laserRange = 6;
public int laserDirections = 4; public int laserDirections = 4;
public int powerRange = 4;
public float powerSpeed = 0.06f; public float powerSpeed = 0.06f;
public boolean explosive = true; public boolean explosive = true;
public boolean drawRadius = false;
public boolean hasLasers = true; public boolean hasLasers = true;
public boolean outputOnly = false; public boolean outputOnly = false;
@ -35,6 +33,12 @@ public class Generator extends PowerBlock{
@Override @Override
public void getStats(Array<String> list){ public void getStats(Array<String> list){
super.getStats(list); super.getStats(list);
if(hasLasers){
list.add("[powerinfo]Laser range: " + laserRange + " blocks");
list.add("[powerinfo]Max power transfer/second: " + Strings.toFixed(powerSpeed*2, 2));
}
if(explosive){ if(explosive){
list.add("[orange]Highly explosive!"); list.add("[orange]Highly explosive!");
} }
@ -65,17 +69,6 @@ public class Generator extends PowerBlock{
} }
} }
@Override
public void drawPixelOverlay(Tile tile){
super.drawPixelOverlay(tile);
if(drawRadius){
Draw.color("yellow");
Draw.dashcircle(tile.worldx(), tile.worldy(), powerRange * Vars.tilesize);
Draw.reset();
}
}
@Override @Override
public void drawOver(Tile tile){ public void drawOver(Tile tile){
PowerEntity entity = tile.entity(); PowerEntity entity = tile.entity();

View File

@ -29,7 +29,7 @@ public class NuclearReactor extends LiquidItemPowerGenerator{
protected float coolantPower = 0.007f; //how much heat decreases per coolant unit protected float coolantPower = 0.007f; //how much heat decreases per coolant unit
protected float smokeThreshold = 0.3f; //threshold at which block starts smoking protected float smokeThreshold = 0.3f; //threshold at which block starts smoking
protected int explosionRadius = 19; protected int explosionRadius = 19;
protected int explosionDamage = 128; protected int explosionDamage = 135;
protected float flashThreshold = 0.46f; protected float flashThreshold = 0.46f;
public NuclearReactor(String name) { public NuclearReactor(String name) {