1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2025-03-12 02:49:30 +07:00

More difficulty tweaks, made sandbox work properly

This commit is contained in:
Anuken 2017-12-03 15:29:49 -05:00
parent 19a4dd41e3
commit 9dd2bfaeeb
42 changed files with 249 additions and 149 deletions

View File

Before

(image error) Size: 272 B

After

(image error) Size: 272 B

View File

@ -664,7 +664,7 @@ blocks/oil
index: -1
blocks/oiledge
rotate: false
xy: 456, 423
xy: 470, 423
size: 12, 12
orig: 12, 12
offset: 0, 0
@ -1579,9 +1579,9 @@ laserend
orig: 18, 18
offset: 0, 0
index: -1
mechs/player
mechs/mech-standard
rotate: false
xy: 470, 423
xy: 456, 423
size: 12, 12
orig: 12, 12
offset: 0, 0

Binary file not shown.

Before

(image error) Size: 53 KiB

After

(image error) Size: 53 KiB

View File

@ -159,6 +159,14 @@ public class Control extends Module{
//multiplying by 2 so you start with more time in the beginning
wavetime = waveSpacing()*2;
if(mode == GameMode.sandbox){
for(Item type : Item.values()){
items.put(type, 999999999);
}
}
ui.updateItems();
GameState.set(State.playing);
}
@ -236,7 +244,7 @@ public class Control extends Module{
int index = i;
float range = 12f;
Timers.run(index*50f, ()->{
Timers.run(index*5f, ()->{
try{
Enemy enemy = ClassReflection.newInstance(spawn.type);
enemy.set(tile.worldx() + Mathf.range(range), tile.worldy() + Mathf.range(range));

View File

@ -409,7 +409,8 @@ public class Renderer extends RendererModule{
Draw.thickness(2f);
Draw.linecrect(x + offset.x, y + offset.y, tilesize * player.recipe.result.width + si, tilesize * player.recipe.result.height + si);
player.recipe.result.drawPlace(tilex, tiley, valid);
player.recipe.result.drawPlace(tilex, tiley, player.rotation, valid);
Draw.thickness(2f);
if(player.recipe.result.rotate){
Draw.color("orange");
@ -420,7 +421,7 @@ public class Renderer extends RendererModule{
Draw.thickness(1f);
Draw.color("scarlet");
for(SpawnPoint spawn : control.getSpawnPoints()){
Draw.dashcircle(spawn.start.worldx(), spawn.start.worldy(), enemyspawnspace);
Draw.dashCircle(spawn.start.worldx(), spawn.start.worldy(), enemyspawnspace);
}
if(valid)

View File

@ -379,6 +379,10 @@ public class UI extends SceneModule{
about.show();
}
public boolean onDialog(){
return scene.getKeyboardFocus() instanceof Dialog;
}
public void showUpgrades(){
upgrades.show();
}

View File

@ -132,10 +132,10 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
DamageArea.damage(!(b.owner instanceof Enemy), b.x, b.y, 25f, (int)(damage * 2f/3f));
}
},
titanshell = new BulletType(1.8f, 60){
titanshell = new BulletType(1.8f, 40){
{
lifetime = 70f;
hitsize = 11f;
hitsize = 15f;
}
public void draw(Bullet b){

View File

@ -13,9 +13,11 @@ public class EnemySpawn{
/**The spacing, in waves, of spawns. 2 = spawns every other wave*/
protected int spacing = 1;
/**How many waves need to pass after the start of this spawn for the tier to increase by one*/
protected int tierscale = 15;
protected int tierscale = 14;
/**How many less enemies there are, every time the tier increases*/
protected int tierscaleback = 1;
/**The tier this spawn starts at.*/
protected int tier = 1;
/**Maximum amount of enemies that spawn*/
protected int max = 17;
/**How many waves need to pass before the amount of enemies increases by 1*/
@ -35,6 +37,6 @@ public class EnemySpawn{
}
public int tier(int wave, int lane){
return Mathf.clamp(1 + (wave-after)/tierscale, 1, Enemy.maxtier);
return Mathf.clamp(tier + (wave-after)/tierscale, 1, Enemy.maxtier);
}
}

View File

@ -10,6 +10,7 @@ import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.effect.Fx;
import io.anuke.mindustry.input.Input;
import io.anuke.mindustry.resource.Mech;
import io.anuke.mindustry.resource.Recipe;
import io.anuke.mindustry.resource.Weapon;
import io.anuke.ucore.core.*;
@ -18,6 +19,7 @@ import io.anuke.ucore.util.Angles;
public class Player extends DestructibleEntity{
public Weapon weapon;
public Mech mech = Mech.standard;
public float breaktime = 0;
public Recipe recipe;
@ -50,9 +52,9 @@ public class Player extends DestructibleEntity{
@Override
public void draw(){
if(Vars.snapCamera && Settings.getBool("smoothcam") && Settings.getBool("pixelate")){
Draw.rect("player", (int)x, (int)y, direction.angle()-90);
Draw.rect("mech-"+mech.name(), (int)x, (int)y, direction.angle()-90);
}else{
Draw.rect("player", x, y, direction.angle()-90);
Draw.rect("mech-"+mech.name(), x, y, direction.angle()-90);
}
}

View File

@ -79,7 +79,7 @@ public class TileEntity extends Entity{
}
public boolean collide(Bullet other){
return other.owner instanceof Enemy;
return other.owner instanceof Enemy; //TODO
}
@Override

View File

@ -53,11 +53,18 @@ public class WaveCreator{
amount = 1;
}},
new EnemySpawn(Enemy.class){{
scaling = 3;
after = 8;
spacing = 4;
tier = 2;
}},
new EnemySpawn(TitanEnemy.class){{
after = 6;
amount = 2;
spacing = 5;
scaling = 3;
scaling = 2;
}},
new EnemySpawn(FlamerEnemy.class){{
@ -67,6 +74,13 @@ public class WaveCreator{
scaling = 2;
}},
new EnemySpawn(EmpEnemy.class){{
after = 15;
amount = 1;
spacing = 5;
scaling = 1;
}},
new EnemySpawn(BlastEnemy.class){{
after = 4 + 5 + 5;
amount = 3;

View File

@ -27,10 +27,20 @@ public class BlastEnemy extends Enemy{
}
if(target != null && target.distanceTo(this) < range){
Bullet b = new Bullet(BulletType.blast, this, x, y, 0).add();
b.damage = BulletType.blast.damage + (tier-1) * 40;
damage(999);
explode();
}
}
@Override
public void onDeath(){
super.onDeath();
explode();
}
void explode(){
Bullet b = new Bullet(BulletType.blast, this, x, y, 0).add();
b.damage = BulletType.blast.damage + (tier-1) * 40;
damage(999);
}
}

View File

@ -6,8 +6,8 @@ public class EmpEnemy extends Enemy{
public EmpEnemy() {
speed = 0.27f;
reload = 70;
speed = 0.3f;
reload = 60;
maxhealth = 210;
range = 80f;
bullet = BulletType.emp;

View File

@ -175,7 +175,7 @@ public class Enemy extends DestructibleEntity{
}
maxhealth *= tier;
speed += 0.04f * tier + Mathf.range(0.1f);
speed += 0.04f * tier /*+ Mathf.range(0.1f)*/;
reload /= Math.max(tier / 1.5f, 1f);
range += tier * 5;
speed = Math.max(speed, 0.07f);

View File

@ -15,9 +15,9 @@ public class FortressEnemy extends Enemy{
public FortressEnemy() {
speed = 0.2f;
speed = 0.25f;
reload = 90;
maxhealth = 700;
maxhealth = 800;
range = 70f;
bullet = BulletType.yellowshell;
hitbox.setSize(10f);

View File

@ -15,9 +15,9 @@ public class HealerEnemy extends Enemy{
public HealerEnemy() {
speed = 0.2f;
reload = 14;
maxhealth = 130;
speed = 0.25f;
reload = 10;
maxhealth = 200;
range = 90f;
bullet = BulletType.shot;
range = 30f;

View File

@ -9,9 +9,9 @@ public class TitanEnemy extends Enemy{
public TitanEnemy() {
speed = 0.22f;
speed = 0.26f;
reload = 30;
maxhealth = 421;
maxhealth = 430;
range = 60f;
bullet = BulletType.small;
hitbox.setSize(7f);

View File

@ -25,7 +25,7 @@ public class Input{
//player is dead
if(player.health <= 0) return;
if(Inputs.scrolled() && GameState.is(State.playing)){
if(Inputs.scrolled() && !GameState.is(State.menu) && !Vars.ui.onDialog()){
Vars.renderer.scaleCamera(Inputs.scroll());
}

View File

@ -1,16 +1,15 @@
package io.anuke.mindustry.resource;
public enum Mech{
normal("default"),
scout("scout"){{
standard,
scout{{
}};
public final String name;
public float speedBoost = 1f, damageBoost = 1f;
public int regenRate = 10;
public int health = 20;
private Mech(String name){
this.name = name;
private Mech(){
}
}

View File

@ -43,8 +43,8 @@ public enum Recipe{
mortarturret(weapon, WeaponBlocks.mortarturret, stack(Item.steel, 20), stack(Item.titanium, 15)),
teslaturret(weapon, WeaponBlocks.teslaturret, stack(Item.steel, 10), stack(Item.titanium, 15), stack(Item.dirium, 15)),
plasmaturret(weapon, WeaponBlocks.plasmaturret, stack(Item.steel, 10), stack(Item.titanium, 10), stack(Item.dirium, 15)),
chainturret(weapon, WeaponBlocks.chainturret, stack(Item.steel, 35), stack(Item.titanium, 25), stack(Item.dirium, 35)),
titanturret(weapon, WeaponBlocks.titanturret, stack(Item.steel, 50), stack(Item.titanium, 45), stack(Item.dirium, 55)),
chainturret(weapon, WeaponBlocks.chainturret, stack(Item.steel, 50), stack(Item.titanium, 25), stack(Item.dirium, 35)),
titanturret(weapon, WeaponBlocks.titanturret, stack(Item.steel, 70), stack(Item.titanium, 50), stack(Item.dirium, 55)),
smelter(crafting, ProductionBlocks.smelter, stack(Item.stone, 40), stack(Item.iron, 40)),
crucible(crafting, ProductionBlocks.crucible, stack(Item.titanium, 40), stack(Item.steel, 40)),

View File

@ -1,8 +1,6 @@
package io.anuke.mindustry.ui;
import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.Timer;
import com.badlogic.gdx.utils.Timer.Task;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.core.GameState;
@ -19,19 +17,18 @@ import io.anuke.ucore.scene.ui.layout.Unit;
//TODO unified save/load dialogs
public class LoadDialog extends FloatingDialog{
ScrollPane pane;
public LoadDialog(){
public LoadDialog() {
this("Load Game");
}
public LoadDialog(String title) {
super(title);
setup();
shown(() -> {
setup();
Timers.runTask(2f, ()-> Core.scene.setScrollFocus(pane));
Timers.runTask(2f, () -> Core.scene.setScrollFocus(pane));
});
addCloseButton();
@ -42,11 +39,11 @@ public class LoadDialog extends FloatingDialog{
content().add("Select a save slot.").padBottom(2);
content().row();
Table slots = new Table();
pane = new ScrollPane(slots);
pane.setFadeScrollBars(false);
slots.padRight(Unit.dp.inPixels(24));
for(int i = 0; i < Vars.saveSlots; i++){
@ -55,14 +52,12 @@ public class LoadDialog extends FloatingDialog{
TextButton button = new TextButton("[accent]Slot " + (i + 1));
button.pad(Unit.dp.inPixels(12));
button.getLabelCell().top().left().growX();
button.row();
Label info = new Label("[gray]" + (!SaveIO.isSaveValid(i) ? "<empty>" : SaveIO.getMode(slot) + ", " +
SaveIO.getMap(slot) +
", Wave " + SaveIO.getWave(slot) + "\nLast Saved: " + SaveIO.getTimeString(i)));
Label info = new Label("[gray]" + (!SaveIO.isSaveValid(i) ? "<empty>" : SaveIO.getMode(slot) + ", " + SaveIO.getMap(slot) + ", Wave " + SaveIO.getWave(slot) + "\nLast Saved: " + SaveIO.getTimeString(i)));
info.setAlignment(Align.center, Align.center);
button.add(info).padBottom(3).padTop(7);
button.row();
//button.addImage("white", Color.GRAY)
@ -73,37 +68,33 @@ public class LoadDialog extends FloatingDialog{
slots.add(button).size(404, 104).pad(4).units(Unit.dp);
slots.row();
}
content().add(pane);
}
public void modifyButton(TextButton button, int slot){
button.setDisabled(!SaveIO.isSaveValid(slot));
button.clicked(() -> {
if(!button.isDisabled()){
Vars.ui.showLoading();
Timer.schedule(new Task(){
@Override
public void run(){
Vars.ui.hideLoading();
hide();
try{
SaveIO.loadFromSlot(slot);
GameState.set(State.playing);
Vars.ui.hideMenu();
}catch(Exception e){
e.printStackTrace();
Vars.ui.hideMenu();
GameState.set(State.menu);
Vars.control.reset();
Vars.ui.showError("[orange]Save file corrupted or invalid!");
return;
}
Timers.runTask(3f, () -> {
Vars.ui.hideLoading();
hide();
try{
SaveIO.loadFromSlot(slot);
GameState.set(State.playing);
Vars.ui.hideMenu();
}catch(Exception e){
e.printStackTrace();
Vars.ui.hideMenu();
GameState.set(State.menu);
Vars.control.reset();
Vars.ui.showError("[orange]Save file corrupted or invalid!");
return;
}
}, 3f/60f);
});
}
});
}

View File

@ -1,11 +1,10 @@
package io.anuke.mindustry.ui;
import com.badlogic.gdx.utils.Timer;
import com.badlogic.gdx.utils.Timer.Task;
import com.badlogic.gdx.utils.reflect.ClassReflection;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.io.SaveIO;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.scene.ui.ConfirmDialog;
import io.anuke.ucore.scene.ui.TextButton;
import io.anuke.ucore.scene.ui.layout.Cell;
@ -13,48 +12,44 @@ import io.anuke.ucore.scene.ui.layout.Unit;
//TODO unified save/load dialogs
public class SaveDialog extends LoadDialog{
public SaveDialog(){
public SaveDialog() {
super("Save Game");
}
@Override
public void modifyButton(TextButton button, int slot){
button.clicked(()->{
button.clicked(() -> {
if(SaveIO.isSaveValid(slot)){
new ConfirmDialog("Overwrite", "Are you sure you want to overwrite\nthis save slot?", ()->{
new ConfirmDialog("Overwrite", "Are you sure you want to overwrite\nthis save slot?", () -> {
save(slot);
}){{
content().pad(16);
for(Cell<?> cell : getButtonTable().getCells())
cell.size(110, 45).pad(4).units(Unit.dp);
}}.show();
}){
{
content().pad(16);
for(Cell<?> cell : getButtonTable().getCells())
cell.size(110, 45).pad(4).units(Unit.dp);
}
}.show();
}else{
save(slot);
}
});
}
void save(int slot){
Vars.ui.showLoading("[orange]Saving...");
Timer.schedule(new Task(){
@Override
public void run(){
hide();
Vars.ui.hideLoading();
try{
SaveIO.saveToSlot(slot);
}catch (Throwable e){
e = (e.getCause() == null ? e : e.getCause());
Vars.ui.showError("[orange]Failed to save game!\n[white]" +
ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" +
"at " + e.getStackTrace()[0].getFileName() + ":"+ e.getStackTrace()[0].getLineNumber());
}
Timers.runTask(5f, () -> {
hide();
Vars.ui.hideLoading();
try{
SaveIO.saveToSlot(slot);
}catch(Throwable e){
e = (e.getCause() == null ? e : e.getCause());
Vars.ui.showError("[orange]Failed to save game!\n[white]" + ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" + "at " + e.getStackTrace()[0].getFileName() + ":" + e.getStackTrace()[0].getLineNumber());
}
}, 5f/60f);
});
}
}

View File

@ -101,7 +101,7 @@ public class BlocksFragment implements Fragment{
image.update(()->{
boolean canPlace = !control.getTutorial().active() || control.getTutorial().canPlace();
boolean has = control.hasItems(r.requirements) && canPlace;
boolean has = (control.hasItems(r.requirements)) && canPlace;
//image.setDisabled(!has);
image.setChecked(player.recipe == r);
image.setTouchable(canPlace ? Touchable.enabled : Touchable.disabled);

View File

@ -24,12 +24,14 @@ import io.anuke.ucore.scene.builders.label;
import io.anuke.ucore.scene.builders.table;
import io.anuke.ucore.scene.ui.Image;
import io.anuke.ucore.scene.ui.Label;
import io.anuke.ucore.scene.ui.layout.Cell;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.scene.ui.layout.Unit;
import io.anuke.ucore.util.Profiler;
public class HudFragment implements Fragment{
private Table itemtable, respawntable;
private Cell<Table> itemcell;
private Array<Item> tempItems = new Array<>();
public void build(){
@ -63,6 +65,8 @@ public class HudFragment implements Fragment{
row();
itemtable = new table("button").end().top().left().fillX().size(-1).get();
itemtable.setVisible(()-> control.getMode() != GameMode.sandbox);
itemcell = get().getCell(itemtable);
get().setVisible(()->!GameState.is(State.menu));
@ -167,6 +171,10 @@ public class HudFragment implements Fragment{
itemtable.clear();
itemtable.left();
if(control.getMode() == GameMode.sandbox){
return;
}
tempItems.clear();
for(Item item : control.getItems().keys()){
tempItems.add(item);
@ -174,8 +182,13 @@ public class HudFragment implements Fragment{
tempItems.sort();
for(Item stack : tempItems){
int amount = control.getAmount(stack);
String formatted = Mindustry.formatter.format(amount);
if(amount > 99999999){
formatted = "inf";
}
Image image = new Image(Draw.region("icon-" + stack.name()));
Label label = new Label("" + Mindustry.formatter.format(control.getAmount(stack)));
Label label = new Label(formatted);
label.setFontScale(fontscale*1.5f);
itemtable.add(image).size(8*3).units(Unit.dp);
itemtable.add(label).left();

View File

@ -79,7 +79,7 @@ public class Block{
public void drawOver(Tile tile){}
public void drawPixelOverlay(Tile tile){}
public void drawPlace(int x, int y, boolean valid){}
public void drawPlace(int x, int y, int rotation, boolean valid){}
public void postInit(){}
public void getStats(Array<String> list){

View File

@ -78,7 +78,7 @@ public class Generator{
if(floor == Blocks.stone || floor == Blocks.grass || floor == Blocks.blackstone ||
floor == Blocks.snow || floor == Blocks.sand){
if(Noise.nnoise(x, y, 8, 1) > 0.2){
if(Noise.nnoise(x, y, 8, 1) > 0.21){
floor = Blocks.iron;
}
@ -86,7 +86,7 @@ public class Generator{
floor = Blocks.coal;
}
if(Noise.nnoise(x + 9999, y + 9999, 8, 1) > 0.264){
if(Noise.nnoise(x + 9999, y + 9999, 8, 1) > 0.27){
floor = Blocks.titanium;
}

View File

@ -207,8 +207,8 @@ public class Tile{
}
public void changed(){
if(entity != null && entity.added){
entity.remove();
if(entity != null){
if(entity.added) entity.remove();
entity = null;
}

View File

@ -326,7 +326,7 @@ public class World extends Module{
if(tile == null) return;
Block block = tile.block();
Block block = tile.isLinked() ? tile.getLinked().block() : tile.block();
Recipe result = null;
for(Recipe recipe : Recipe.values()){
@ -420,7 +420,7 @@ public class World extends Module{
other = other.getLinked();
}
if(other == null || other.entity == null ||(tile != null && other.entity == tile.entity)) continue;
if(other == null || other.entity == null || (tile != null && other.entity == tile.entity)) continue;
TileEntity e = other.entity;

View File

@ -72,7 +72,7 @@ public class DefenseBlocks{
+ "Uses small amounts of power.";
formalName = "repair turret";
range = 30;
reload = 40f;
reload = 60f;
health = 60;
}
},
@ -83,7 +83,8 @@ public class DefenseBlocks{
+ "Uses power.";
formalName = "repair turret II";
range = 44;
reload = 20f;
reload = 30f;
powerUsed = 0.15f;
health = 90;
}
},

View File

@ -227,8 +227,8 @@ public class ProductionBlocks{
formalName = "thermal generator";
//TODO
generateLiquid = Liquid.lava;
inputLiquid = 20f;
generatePower = 1f;
inputLiquid = 25f;
generatePower = 0.5f;
powerCapacity = 40f;
description = "Generates power from lava.";
fullDescription = "Generates power from lava. Outputs power as lasers to its 4 sides.";

View File

@ -182,7 +182,7 @@ public class WeaponBlocks{
inaccuracy = 8f;
formalName = "chain turret";
range = 80f;
reload = 7f;
reload = 8f;
bullet = BulletType.chain;
ammo = Item.uranium;
health = 430;
@ -219,7 +219,7 @@ public class WeaponBlocks{
{
formalName = "titan cannon";
range = 120f;
reload = 20f;
reload = 23f;
bullet = BulletType.titanshell;
ammo = Item.uranium;
health = 800;

View File

@ -38,7 +38,7 @@ public class PowerTurret extends Turret implements PowerAcceptor{
Vector2 offset = getPlaceOffset();
Draw.color("green");
Draw.dashcircle(tile.worldx() + offset.x, tile.worldy() + offset.y, range);
Draw.dashCircle(tile.worldx() + offset.x, tile.worldy() + offset.y, range);
Draw.reset();
drawPowerBar(tile);

View File

@ -42,6 +42,10 @@ public class RepairTurret extends PowerTurret{
return;
}
if(entity.blockTarget != null && entity.blockTarget.dead){
entity.blockTarget = null;
}
if(Timers.get(entity, "blocktarget", targetInterval)){
entity.blockTarget = Vars.world.findTileTarget(tile.worldx(), tile.worldy(), tile, range, true);
}
@ -64,7 +68,7 @@ public class RepairTurret extends PowerTurret{
@Override
public void drawPixelOverlay(Tile tile){
Draw.color("green");
Draw.dashcircle(tile.worldx(), tile.worldy(), range);
Draw.dashCircle(tile.worldx(), tile.worldy(), range);
Draw.reset();
drawPowerBar(tile);

View File

@ -103,7 +103,7 @@ public class Turret extends Block{
Vector2 offset = getPlaceOffset();
Draw.color("green");
Draw.dashcircle(tile.worldx() + offset.x, tile.worldy() + offset.y, range);
Draw.dashCircle(tile.worldx() + offset.x, tile.worldy() + offset.y, range);
Draw.reset();
TurretEntity entity = tile.entity();
@ -116,10 +116,10 @@ public class Turret extends Block{
}
@Override
public void drawPlace(int x, int y, boolean valid){
public void drawPlace(int x, int y, int rotation, boolean valid){
Draw.color(Color.PURPLE);
Draw.thick(1f);
Draw.dashcircle(x*Vars.tilesize, y*Vars.tilesize, range);
Draw.dashCircle(x*Vars.tilesize, y*Vars.tilesize, range);
}
@Override

View File

@ -25,7 +25,14 @@ public class PowerBooster extends Generator{
super.drawPixelOverlay(tile);
Draw.color("yellow");
Draw.dashcircle(tile.worldx(), tile.worldy(), powerRange * Vars.tilesize);
Draw.dashCircle(tile.worldx(), tile.worldy(), powerRange * Vars.tilesize);
Draw.reset();
}
@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
Draw.color("purple");
Draw.dashCircle(x * Vars.tilesize, y * Vars.tilesize, laserRange * Vars.tilesize);
Draw.reset();
}

View File

@ -45,7 +45,7 @@ public class Drill extends Block{
@Override
public void drawOver(Tile tile){
if(tile.floor() != resource && !(resource.drops.equals(tile.floor().drops)) && resource != null){
if(tile.floor() != resource && resource != null && !(resource.drops.equals(tile.floor().drops))){
Draw.colorl(0.85f + Mathf.absin(Timers.time(), 6f, 0.15f));
Draw.rect("cross", tile.worldx(), tile.worldy());
Draw.color();

View File

@ -18,6 +18,7 @@ import io.anuke.ucore.util.*;
public class Generator extends PowerBlock{
public static final int powerTime = 2;
public static boolean drawRangeOverlay = false;
public int laserRange = 6;
public int laserDirections = 4;
@ -29,21 +30,71 @@ public class Generator extends PowerBlock{
public Generator(String name) {
super(name);
}
@Override
public void getStats(Array<String> 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));
list.add("[powerinfo]Max power transfer/second: " + Strings.toFixed(powerSpeed * 2, 2));
}
if(explosive){
list.add("[orange]Highly explosive!");
}
}
@Override
public void drawPixelOverlay(Tile tile){
super.drawPixelOverlay(tile);
if(drawRangeOverlay){
int rotation = tile.getRotation();
if(hasLasers){
Draw.color("yellow");
Draw.thick(2f);
for(int i = 0; i < laserDirections; i++){
int dir = Mathf.mod(i + rotation - laserDirections / 2, 4);
float lx = Geometry.getD4Points()[dir].x, ly = Geometry.getD4Points()[dir].y;
float dx = lx * laserRange * Vars.tilesize;
float dy = ly * laserRange * Vars.tilesize;
Draw.dashLine(
tile.worldx() + lx * Vars.tilesize / 2,
tile.worldy() + ly * Vars.tilesize / 2,
tile.worldx() + dx - lx * Vars.tilesize,
tile.worldy() + dy - ly * Vars.tilesize, 9);
}
Draw.reset();
}
}
}
@Override
public void drawPlace(int x, int y, int rotation, boolean valid){
if(hasLasers){
Draw.color("purple");
Draw.thick(2f);
for(int i = 0; i < laserDirections; i++){
int dir = Mathf.mod(i + rotation - laserDirections / 2, 4);
float lx = Geometry.getD4Points()[dir].x, ly = Geometry.getD4Points()[dir].y;
float dx = lx * laserRange * Vars.tilesize;
float dy = ly * laserRange * Vars.tilesize;
Draw.dashLine(
x * Vars.tilesize + lx * Vars.tilesize / 2,
y * Vars.tilesize + ly * Vars.tilesize / 2,
x * Vars.tilesize + dx - lx * Vars.tilesize,
y * Vars.tilesize + dy - ly * Vars.tilesize, 9);
}
Draw.reset();
}
}
@Override
public void onDestroyed(Tile tile){
if(explosive){
@ -58,7 +109,7 @@ public class Generator extends PowerBlock{
Effects.effect(Fx.shockwave, x, y);
Timers.run(12f + Mathf.random(20f), () -> {
tile.damageNearby(4, 40, 0f);
tile.damageNearby(4, 60, 0f);
});
Effects.sound(explosionSound, x, y);
@ -68,7 +119,7 @@ public class Generator extends PowerBlock{
super.onDestroyed(tile);
}
}
@Override
public void drawOver(Tile tile){
PowerEntity entity = tile.entity();
@ -79,12 +130,12 @@ public class Generator extends PowerBlock{
}else{
Draw.alpha(0.5f);
}
drawLaserTo(tile, (tile.getRotation() + i) - laserDirections/2);
drawLaserTo(tile, (tile.getRotation() + i) - laserDirections / 2);
}
Draw.color();
}
@Override
public boolean acceptsPower(Tile tile){
return false;
@ -94,11 +145,12 @@ public class Generator extends PowerBlock{
PowerEntity entity = tile.entity();
for(int i = 0; i < laserDirections; i++){
int rot = (tile.getRotation() + i) - laserDirections/2;
int rot = (tile.getRotation() + i) - laserDirections / 2;
Tile target = laserTarget(tile, rot);
if(target == null || isInterfering(target, rot)) continue;
if(target == null || isInterfering(target, rot))
continue;
PowerAcceptor p = (PowerAcceptor) target.block();
if(p.acceptsPower(target) && entity.power >= powerSpeed){
float accepted = p.addPower(target, powerSpeed);
@ -114,12 +166,10 @@ public class Generator extends PowerBlock{
if(target != null){
boolean interfering = isInterfering(target, rotation);
Tmp.v1.set(Angles.translation(rotation * 90, target.block().width * Vars.tilesize/2 + 2f +
(interfering ?
Vector2.dst(tile.worldx(), tile.worldy(), target.worldx(), target.worldy()) / 2f - Vars.tilesize/2f * target.block().width - 1 : 0)));
Angles.translation(rotation * 90, width * Vars.tilesize/2 + 2f);
Tmp.v1.set(Angles.translation(rotation * 90, target.block().width * Vars.tilesize / 2 + 2f + (interfering ? Vector2.dst(tile.worldx(), tile.worldy(), target.worldx(), target.worldy()) / 2f - Vars.tilesize / 2f * target.block().width - 1 : 0)));
Angles.translation(rotation * 90, width * Vars.tilesize / 2 + 2f);
if(!interfering){
Draw.tint(Hue.mix(Color.GRAY, Color.WHITE, 0.904f + Mathf.sin(Timers.time(), 1.7f, 0.06f)));
@ -129,21 +179,20 @@ public class Generator extends PowerBlock{
Effects.effect(Fx.laserspark, target.worldx() - Tmp.v1.x, target.worldy() - Tmp.v1.y);
}
}
float r = interfering ? 0.8f : 0f;
Draw.laser("laser", "laserend", tile.worldx() + Angles.x(), tile.worldy() + Angles.y(),
target.worldx() - Tmp.v1.x + Mathf.range(r), target.worldy() - Tmp.v1.y + Mathf.range(r), 0.7f + Mathf.sin(Timers.time(), 2f, 0.1f * 0));
Draw.laser("laser", "laserend", tile.worldx() + Angles.x(), tile.worldy() + Angles.y(), target.worldx() - Tmp.v1.x + Mathf.range(r), target.worldy() - Tmp.v1.y + Mathf.range(r), 0.7f + Mathf.sin(Timers.time(), 2f, 0.1f * 0));
Draw.color();
}
}
protected boolean isInterfering(Tile target, int rotation){
if(target.block() instanceof Generator){
Generator other = (Generator)target.block();
Generator other = (Generator) target.block();
int relrot = (rotation + 2) % 4;
if(other.hasLasers && Math.abs(target.getRotation() - relrot) <= other.laserDirections/2){
if(other.hasLasers && Math.abs(target.getRotation() - relrot) <= other.laserDirections / 2){
return true;
}
}
@ -160,7 +209,7 @@ public class Generator extends PowerBlock{
for(i = 1; i < laserRange; i++){
Tile other = Vars.world.tile(tile.x + i * point.x, tile.y + i * point.y);
if(other != null && other.block() instanceof PowerAcceptor){
Tile linked = other.getLinked();
if(linked == null || linked instanceof PowerAcceptor){

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.