Multiple bugfixes and turret rotation improvements
This commit is contained in:
@@ -79,8 +79,8 @@ project(":core") {
|
|||||||
apply plugin: "java"
|
apply plugin: "java"
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
//compile fileTree(dir: '../core/lib', include: '*.jar')
|
compile fileTree(dir: '../core/lib', include: '*.jar')
|
||||||
compile 'com.github.anuken:ucore:c93833a2b5'
|
//compile 'com.github.anuken:ucore:1e7163626f'
|
||||||
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||||
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import io.anuke.mindustry.world.Tile;
|
|||||||
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||||
import io.anuke.ucore.core.*;
|
import io.anuke.ucore.core.*;
|
||||||
import io.anuke.ucore.entities.Entities;
|
import io.anuke.ucore.entities.Entities;
|
||||||
|
import io.anuke.ucore.entities.Entity;
|
||||||
import io.anuke.ucore.graphics.Atlas;
|
import io.anuke.ucore.graphics.Atlas;
|
||||||
import io.anuke.ucore.modules.RendererModule;
|
import io.anuke.ucore.modules.RendererModule;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
@@ -41,8 +42,6 @@ public class Control extends RendererModule{
|
|||||||
|
|
||||||
float respawntime;
|
float respawntime;
|
||||||
|
|
||||||
//GifRecorder recorder = new GifRecorder(batch);
|
|
||||||
|
|
||||||
public Control(){
|
public Control(){
|
||||||
cameraScale = baseCameraScale;
|
cameraScale = baseCameraScale;
|
||||||
pixelate();
|
pixelate();
|
||||||
@@ -293,6 +292,13 @@ public class Control extends RendererModule{
|
|||||||
Renderer.clearTiles();
|
Renderer.clearTiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(Inputs.keyUp(Keys.C)){
|
||||||
|
for(Entity entity : Entities.all()){
|
||||||
|
if(entity instanceof Enemy)
|
||||||
|
entity.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(Inputs.keyDown(Keys.SPACE)){
|
if(Inputs.keyDown(Keys.SPACE)){
|
||||||
Effects.shake(6, 4);
|
Effects.shake(6, 4);
|
||||||
}
|
}
|
||||||
@@ -351,7 +357,7 @@ public class Control extends RendererModule{
|
|||||||
|
|
||||||
float prex = camera.position.x, prey = camera.position.y;
|
float prex = camera.position.x, prey = camera.position.y;
|
||||||
|
|
||||||
updateShake(1f);
|
updateShake(0.75f);
|
||||||
float prevx = camera.position.x, prevy = camera.position.y;
|
float prevx = camera.position.x, prevy = camera.position.y;
|
||||||
clampCamera(-tilesize / 2f, -tilesize / 2f, World.pixsize - tilesize / 2f, World.pixsize - tilesize / 2f);
|
clampCamera(-tilesize / 2f, -tilesize / 2f, World.pixsize - tilesize / 2f, World.pixsize - tilesize / 2f);
|
||||||
|
|
||||||
@@ -381,7 +387,7 @@ public class Control extends RendererModule{
|
|||||||
|
|
||||||
camera.position.set(lastx - deltax, lasty - deltay, 0);
|
camera.position.set(lastx - deltax, lasty - deltay, 0);
|
||||||
|
|
||||||
//recorder.update();
|
record();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!GameState.is(State.paused)){
|
if(!GameState.is(State.paused)){
|
||||||
|
|||||||
@@ -207,19 +207,25 @@ public class Renderer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void drawHealth(float x, float y, float health, float maxhealth){
|
public static void drawHealth(float x, float y, float health, float maxhealth){
|
||||||
|
drawBar(Color.RED, x, y, health/maxhealth);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void drawBar(Color color, float x, float y, float fraction){
|
||||||
float len = 3;
|
float len = 3;
|
||||||
float offset = 7;
|
float offset = 7;
|
||||||
|
|
||||||
float fraction = Mathf.clamp((float) health / maxhealth);
|
float w = (int)(len * 2 * fraction) + 0.5f;
|
||||||
float w = (len * 2 * fraction);
|
|
||||||
|
x -= 0.5f;
|
||||||
|
y += 0.5f;
|
||||||
|
|
||||||
Draw.thickness(3f);
|
Draw.thickness(3f);
|
||||||
Draw.color(Color.GRAY);
|
Draw.color(Color.SLATE);
|
||||||
Draw.line(x - len + 1, y - offset, x + len + 1, y - offset);
|
Draw.line(x - len + 1, y - offset, x + len + 1.5f, y - offset);
|
||||||
Draw.thickness(1f);
|
Draw.thickness(1f);
|
||||||
Draw.color(Color.BLACK);
|
Draw.color(Color.BLACK);
|
||||||
Draw.line(x - len + 1, y - offset, x + len, y - offset);
|
Draw.line(x - len + 1, y - offset, x + len + 0.5f, y - offset);
|
||||||
Draw.color(Color.RED);
|
Draw.color(color);
|
||||||
if(w >= 1)
|
if(w >= 1)
|
||||||
Draw.line(x - len + 1, y - offset, x - len + w, y - offset);
|
Draw.line(x - len + 1, y - offset, x - len + w, y - offset);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
|
|||||||
@@ -451,6 +451,15 @@ public class UI extends SceneModule{
|
|||||||
get().setVisible(nplay);
|
get().setVisible(nplay);
|
||||||
}}.end();
|
}}.end();
|
||||||
|
|
||||||
|
if(debug){
|
||||||
|
new table(){{
|
||||||
|
atop();
|
||||||
|
new table("button"){{
|
||||||
|
new label("[red]DEBUG MODE").scale(1);
|
||||||
|
}}.end();
|
||||||
|
}}.end();
|
||||||
|
}
|
||||||
|
|
||||||
new table(){{
|
new table(){{
|
||||||
//atop();
|
//atop();
|
||||||
new table(){{
|
new table(){{
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class Vars{
|
|||||||
//how much the zoom changes every zoom button press
|
//how much the zoom changes every zoom button press
|
||||||
public static final int zoomScale = Math.round(Unit.dp.inPixels(1));
|
public static final int zoomScale = Math.round(Unit.dp.inPixels(1));
|
||||||
//if true, player speed will be increased, massive amounts of resources will be given on start, and other debug options will be available
|
//if true, player speed will be increased, massive amounts of resources will be given on start, and other debug options will be available
|
||||||
public static boolean debug = false;
|
public static boolean debug = true;
|
||||||
//number of save slots-- increasing may lead to layout issues
|
//number of save slots-- increasing may lead to layout issues
|
||||||
public static final int saveSlots = 4;
|
public static final int saveSlots = 4;
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ public class Conveyor extends Block{
|
|||||||
public void draw(Tile tile){
|
public void draw(Tile tile){
|
||||||
ConveyorEntity entity = tile.entity();
|
ConveyorEntity entity = tile.entity();
|
||||||
|
|
||||||
Draw.rect(name() + (Timers.time() % ((20 / 100f) / speed) < (10 / 100f) / speed ? "" : "move"), tile.worldx(), tile.worldy(), tile.rotation * 90);
|
Draw.rect(name() +
|
||||||
|
(Timers.time() % ((20 / 100f) / speed) < (10 / 100f) / speed && accept(Item.stone, tile, null) ? "" : "move"), tile.worldx(), tile.worldy(), tile.rotation * 90);
|
||||||
|
|
||||||
for(ItemPos pos : entity.convey){
|
for(ItemPos pos : entity.convey){
|
||||||
vector.set(tilesize, 0).rotate(tile.rotation * 90);
|
vector.set(tilesize, 0).rotate(tile.rotation * 90);
|
||||||
@@ -44,19 +45,39 @@ public class Conveyor extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
|
|
||||||
ConveyorEntity entity = tile.entity();
|
ConveyorEntity entity = tile.entity();
|
||||||
|
entity.minitem = 1f;
|
||||||
|
|
||||||
entity.convey.begin();
|
entity.convey.begin();
|
||||||
|
|
||||||
for(ItemPos pos : entity.convey){
|
for(ItemPos pos : entity.convey){
|
||||||
|
boolean canmove = true;
|
||||||
|
|
||||||
|
for(int i = 0; i < entity.convey.size; i ++){
|
||||||
|
ItemPos other = entity.convey.get(i);
|
||||||
|
|
||||||
|
if(other.pos > pos.pos && other.pos-pos.pos < 0.14){
|
||||||
|
canmove = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(canmove){
|
||||||
pos.pos += speed * Mathf.delta();
|
pos.pos += speed * Mathf.delta();
|
||||||
pos.y = MathUtils.lerp(pos.y, 0, 0.14f * Mathf.delta());
|
pos.y = MathUtils.lerp(pos.y, 0, 0.14f * Mathf.delta());
|
||||||
|
}else{
|
||||||
|
pos.y = MathUtils.lerp(pos.y, pos.seed/128f/3f, 0.1f * Mathf.delta());
|
||||||
|
}
|
||||||
|
|
||||||
if(pos.pos >= 1f && offloadDir(tile, pos.item)){
|
if(pos.pos >= 1f && offloadDir(tile, pos.item)){
|
||||||
entity.convey.removeValue(pos, true);
|
entity.convey.removeValue(pos, true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pos.pos = Mathf.clamp(pos.pos);
|
pos.pos = Mathf.clamp(pos.pos);
|
||||||
|
|
||||||
|
if(pos.pos < entity.minitem)
|
||||||
|
entity.minitem = pos.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.convey.end();
|
entity.convey.end();
|
||||||
@@ -69,7 +90,7 @@ public class Conveyor extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(Item item, Tile dest, Tile source){
|
public boolean accept(Item item, Tile dest, Tile source){
|
||||||
return true;
|
return dest.<ConveyorEntity>entity().minitem > 0.05f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -92,6 +113,7 @@ public class Conveyor extends Block{
|
|||||||
|
|
||||||
public static class ConveyorEntity extends TileEntity{
|
public static class ConveyorEntity extends TileEntity{
|
||||||
DelayedRemovalArray<ItemPos> convey = new DelayedRemovalArray<>();
|
DelayedRemovalArray<ItemPos> convey = new DelayedRemovalArray<>();
|
||||||
|
float minitem = 1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(DataOutputStream stream) throws IOException{
|
public void write(DataOutputStream stream) throws IOException{
|
||||||
@@ -120,13 +142,15 @@ public class Conveyor extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class ItemPos{
|
static class ItemPos{
|
||||||
public Item item;
|
Item item;
|
||||||
public float pos, y;
|
float pos, y;
|
||||||
|
byte seed;
|
||||||
|
|
||||||
public ItemPos(Item item, float pos, float y){
|
public ItemPos(Item item, float pos, float y){
|
||||||
this.item = item;
|
this.item = item;
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
|
seed = (byte)MathUtils.random(255);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.anuke.mindustry.world.blocks;
|
package io.anuke.mindustry.world.blocks;
|
||||||
|
|
||||||
import io.anuke.mindustry.Inventory;
|
import io.anuke.mindustry.Inventory;
|
||||||
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
@@ -11,7 +12,7 @@ public class ProductionBlocks{
|
|||||||
|
|
||||||
core = new Block("core"){
|
core = new Block("core"){
|
||||||
{
|
{
|
||||||
health = 300;
|
health = Vars.debug ? 999999999 : 300;
|
||||||
solid = true;
|
solid = true;
|
||||||
update = true;
|
update = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import io.anuke.mindustry.World;
|
|||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Draw;
|
import io.anuke.ucore.core.Draw;
|
||||||
import io.anuke.ucore.graphics.Hue;
|
import io.anuke.ucore.graphics.Hue;
|
||||||
|
import io.anuke.ucore.util.Angles;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Timers;
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
public class RepairTurret extends Turret{
|
public class RepairTurret extends Turret{
|
||||||
@@ -21,9 +23,10 @@ public class RepairTurret extends Turret{
|
|||||||
entity.target = World.findTileTarget(tile.worldx(), tile.worldy(), tile, range, true);
|
entity.target = World.findTileTarget(tile.worldx(), tile.worldy(), tile, range, true);
|
||||||
|
|
||||||
if(entity.target != null){
|
if(entity.target != null){
|
||||||
entity.rotation = entity.angleTo(entity.target);
|
float target = entity.angleTo(entity.target);
|
||||||
|
entity.rotation = Mathf.slerp(entity.rotation, target, 0.2f*Mathf.delta());
|
||||||
|
|
||||||
if(Timers.get(tile, reload)){
|
if(Timers.get(tile, reload) && Angles.angleDist(target, entity.rotation) < 12){
|
||||||
entity.target.health++;
|
entity.target.health++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
package io.anuke.mindustry.world.blocks;
|
package io.anuke.mindustry.world.blocks;
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -8,6 +6,7 @@ import java.io.IOException;
|
|||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.Renderer;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.entities.Bullet;
|
import io.anuke.mindustry.entities.Bullet;
|
||||||
import io.anuke.mindustry.entities.BulletType;
|
import io.anuke.mindustry.entities.BulletType;
|
||||||
@@ -20,6 +19,7 @@ import io.anuke.ucore.core.Draw;
|
|||||||
import io.anuke.ucore.core.Effects;
|
import io.anuke.ucore.core.Effects;
|
||||||
import io.anuke.ucore.entities.Entities;
|
import io.anuke.ucore.entities.Entities;
|
||||||
import io.anuke.ucore.util.Angles;
|
import io.anuke.ucore.util.Angles;
|
||||||
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Timers;
|
import io.anuke.ucore.util.Timers;
|
||||||
|
|
||||||
public class Turret extends Block{
|
public class Turret extends Block{
|
||||||
@@ -28,6 +28,7 @@ public class Turret extends Block{
|
|||||||
protected String shootsound = "shoot";
|
protected String shootsound = "shoot";
|
||||||
protected BulletType bullet;
|
protected BulletType bullet;
|
||||||
protected Item ammo;
|
protected Item ammo;
|
||||||
|
protected int maxammo = 400;
|
||||||
|
|
||||||
public Turret(String name) {
|
public Turret(String name) {
|
||||||
super(name);
|
super(name);
|
||||||
@@ -51,29 +52,38 @@ public class Turret extends Block{
|
|||||||
Draw.color("green");
|
Draw.color("green");
|
||||||
Draw.dashcircle(tile.worldx(), tile.worldy(), range);
|
Draw.dashcircle(tile.worldx(), tile.worldy(), range);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
|
|
||||||
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
|
float fract = (float)entity.ammo/maxammo;
|
||||||
|
if(fract > 0)
|
||||||
|
fract = Mathf.clamp(fract, 0.24f, 1f);
|
||||||
|
|
||||||
|
Renderer.drawBar(Color.GREEN, tile.worldx(), tile.worldy() + 13, fract);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawOverlay(Tile tile){
|
public void drawOverlay(Tile tile){
|
||||||
|
/*
|
||||||
TurretEntity entity = tile.entity();
|
TurretEntity entity = tile.entity();
|
||||||
|
|
||||||
if(entity.ammo <= 0 && ammo != null){
|
if(entity.ammo <= 0 && ammo != null){
|
||||||
Draw.tcolor(Color.SCARLET);
|
Draw.tcolor(Color.SCARLET);
|
||||||
Draw.tscl(1 / 8f);
|
Draw.tscl(1 / 8f);
|
||||||
Draw.text("No ammo!", tile.worldx(), tile.worldy() + tilesize);
|
//Draw.text("No ammo!", tile.worldx(), tile.worldy() + tilesize);
|
||||||
|
|
||||||
}else if(ammo != null){
|
}else if(ammo != null){
|
||||||
Draw.tscl(1 / 8f);
|
Draw.tscl(1 / 8f);
|
||||||
Draw.tcolor(Color.GREEN);
|
Draw.tcolor(Color.GREEN);
|
||||||
Draw.text("Ammo: " + entity.ammo, tile.worldx(), tile.worldy() - tilesize);
|
//Draw.text("Ammo: " + entity.ammo, tile.worldx(), tile.worldy() - tilesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.tscl(Vars.fontscale);
|
Draw.tscl(Vars.fontscale);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean accept(Item item, Tile dest, Tile source){
|
public boolean accept(Item item, Tile dest, Tile source){
|
||||||
return item == ammo;
|
return item == ammo && dest.<TurretEntity>entity().ammo < maxammo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -96,7 +106,9 @@ public class Turret extends Block{
|
|||||||
});
|
});
|
||||||
|
|
||||||
if(enemy != null){
|
if(enemy != null){
|
||||||
entity.rotation = MathUtils.lerpAngleDeg(entity.rotation, Angles.predictAngle(tile.worldx(), tile.worldy(), enemy.x, enemy.y, enemy.xvelocity, enemy.yvelocity, bullet.speed - 0.1f), 0.2f);
|
entity.rotation = MathUtils.lerpAngleDeg(entity.rotation,
|
||||||
|
Angles.predictAngle(tile.worldx(), tile.worldy(), enemy.x, enemy.y, enemy.xvelocity, enemy.yvelocity, bullet.speed - 0.1f),
|
||||||
|
0.2f*Mathf.delta());
|
||||||
float reload = Vars.multiplier*this.reload;
|
float reload = Vars.multiplier*this.reload;
|
||||||
if(Timers.get(tile, reload)){
|
if(Timers.get(tile, reload)){
|
||||||
Effects.sound(shootsound, entity);
|
Effects.sound(shootsound, entity);
|
||||||
|
|||||||
Reference in New Issue
Block a user