mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-15 05:43:02 -08:00
A few more minor bugfixes; added targeting debugging
This commit is contained in:
parent
3e9aca023a
commit
61dbd33f51
13 changed files with 79 additions and 34 deletions
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="io.anuke.mindustry"
|
||||
android:versionCode="10"
|
||||
android:versionName="2.0" >
|
||||
android:versionCode="11"
|
||||
android:versionName="2.1" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="25" />
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ project(":core") {
|
|||
apply plugin: "java"
|
||||
|
||||
dependencies {
|
||||
compile 'com.github.anuken:ucore:2a0a7a54cc'
|
||||
compile 'com.github.anuken:ucore:7d37e1f5d0'
|
||||
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -352,8 +352,8 @@ public class Control extends Module{
|
|||
}
|
||||
}
|
||||
|
||||
if(Inputs.keyDown(Keys.Y)){
|
||||
new TestEnemy(0).set(player.x, player.y).add();
|
||||
if(Inputs.keyUp(Keys.Y)){
|
||||
new FastEnemy(0).set(player.x, player.y).add();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ public class Mindustry extends ModuleCore {
|
|||
|
||||
@Override
|
||||
public void init(){
|
||||
add(Vars.control = new Control());
|
||||
add(Vars.renderer = new Renderer());
|
||||
add(Vars.ui = new UI());
|
||||
module(Vars.control = new Control());
|
||||
module(Vars.renderer = new Renderer());
|
||||
module(Vars.ui = new UI());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ public class Renderer extends RendererModule{
|
|||
if(android && player.breaktime > 0){
|
||||
Vector2 vec = Graphics.world(Gdx.input.getX(0), Gdx.input.getY(0));
|
||||
Tile tile = World.tile(Mathf.scl2(vec.x, tilesize), Mathf.scl2(vec.y, tilesize));
|
||||
if(tile.breakable() && tile.block() != ProductionBlocks.core){
|
||||
if(tile != null && tile.breakable() && tile.block() != ProductionBlocks.core){
|
||||
float fract = player.breaktime / tile.block().breaktime;
|
||||
Draw.color(Color.YELLOW, Color.SCARLET, fract);
|
||||
Draw.circle(tile.worldx(), tile.worldy(), 4 + (1f - fract) * 26);
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
|
|||
lifetime = 110f;
|
||||
hitsize = 8f;
|
||||
}
|
||||
|
||||
public void draw(Bullet b){
|
||||
float rad = 8f;
|
||||
Draw.color(Color.GRAY);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package io.anuke.mindustry.world;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
|
|
@ -12,9 +11,6 @@ import io.anuke.ucore.core.Draw;
|
|||
public class Block{
|
||||
private static int lastid;
|
||||
private static Array<Block> blocks = new Array<Block>();
|
||||
|
||||
protected static Vector2 vector = new Vector2();
|
||||
protected static Vector2 vector2 = new Vector2();
|
||||
protected static TextureRegion temp = new TextureRegion();
|
||||
|
||||
public final String name;
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class ProductionBlocks{
|
|||
}},
|
||||
|
||||
liquidrouter = new LiquidRouter("liquidrouter"){{
|
||||
|
||||
formalName = "liquid router";
|
||||
}},
|
||||
|
||||
conveyor = new Conveyor("conveyor"){{
|
||||
|
|
|
|||
|
|
@ -42,11 +42,11 @@ public class WeaponBlocks{
|
|||
protected void shoot(Tile tile){
|
||||
TurretEntity entity = tile.entity();
|
||||
|
||||
vector.set(4, -2).rotate(entity.rotation);
|
||||
bullet(tile, entity.rotation);
|
||||
Angles.vector.set(4, -2).rotate(entity.rotation);
|
||||
bullet(tile, entity.rotation);
|
||||
|
||||
vector.set(4, 2).rotate(entity.rotation);
|
||||
bullet(tile, entity.rotation);
|
||||
Angles.vector.set(4, 2).rotate(entity.rotation);
|
||||
bullet(tile, entity.rotation);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ public class WeaponBlocks{
|
|||
|
||||
for(int i = 0; i < 7; i ++)
|
||||
Timers.run(i/1.5f, ()->{
|
||||
vector.set(4, 0).setAngle(entity.rotation);
|
||||
Angles.translation(entity.rotation, 4f);
|
||||
bullet(tile, entity.rotation + Mathf.range(30));
|
||||
});
|
||||
}
|
||||
|
|
@ -115,7 +115,6 @@ public class WeaponBlocks{
|
|||
ammo = Item.coal;
|
||||
ammoMultiplier = 5;
|
||||
health = 110;
|
||||
overPrediction = 0.09f;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -159,7 +158,7 @@ public class WeaponBlocks{
|
|||
inaccuracy = 7f;
|
||||
formalName = "plasma turret";
|
||||
range = 60f;
|
||||
reload = 2f;
|
||||
reload = 3f;
|
||||
bullet = BulletType.plasmaflame;
|
||||
ammo = Item.coal;
|
||||
health = 180;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,11 @@ public class Conduit extends Block{
|
|||
update = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description(){
|
||||
return "Transports liquids";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Tile tile){
|
||||
ConduitEntity entity = tile.entity();
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import io.anuke.mindustry.world.Tile;
|
|||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
public class Conveyor extends Block{
|
||||
protected float speed = 0.02f;
|
||||
|
|
@ -38,12 +39,12 @@ public class Conveyor extends Block{
|
|||
(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){
|
||||
vector.set(tilesize, 0).rotate(tile.rotation * 90);
|
||||
vector2.set(-tilesize / 2, pos.y*tilesize/2).rotate(tile.rotation * 90);
|
||||
Tmp.v1.set(tilesize, 0).rotate(tile.rotation * 90);
|
||||
Tmp.v2.set(-tilesize / 2, pos.y*tilesize/2).rotate(tile.rotation * 90);
|
||||
|
||||
Draw.rect("icon-" + pos.item.name(),
|
||||
tile.x * tilesize + vector.x * pos.pos + vector2.x,
|
||||
tile.y * tilesize + vector.y * pos.pos + vector2.y, 4, 4);
|
||||
tile.x * tilesize + Tmp.v1.x * pos.pos + Tmp.v2.x,
|
||||
tile.y * tilesize + Tmp.v1.y * pos.pos + Tmp.v2.y, 4, 4);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,11 @@ public class LiquidRouter extends Conduit{
|
|||
solid = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description(){
|
||||
return "Splits input liquid into 3 directions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Tile tile){
|
||||
ConduitEntity entity = tile.entity();
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
package io.anuke.mindustry.world.blocks.types;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.MathUtils;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.Bullet;
|
||||
|
|
@ -34,7 +34,6 @@ public class Turret extends Block{
|
|||
protected int maxammo = 400;
|
||||
protected float rotatespeed = 0.2f;
|
||||
protected float shootCone = 8f;
|
||||
protected float overPrediction = 0f;
|
||||
|
||||
public Turret(String name) {
|
||||
super(name);
|
||||
|
|
@ -51,6 +50,10 @@ public class Turret extends Block{
|
|||
public void drawOver(Tile tile){
|
||||
TurretEntity entity = tile.entity();
|
||||
Draw.rect(name(), tile.worldx(), tile.worldy(), entity.rotation - 90);
|
||||
|
||||
if(Vars.debug){
|
||||
drawTargeting(tile);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -70,7 +73,6 @@ public class Turret extends Block{
|
|||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, boolean valid){
|
||||
//TODO?
|
||||
Draw.color(Color.PURPLE);
|
||||
Draw.thick(1f);
|
||||
Draw.dashcircle(x*Vars.tilesize, y*Vars.tilesize, range);
|
||||
|
|
@ -109,9 +111,9 @@ public class Turret extends Block{
|
|||
if(entity.target != null){
|
||||
|
||||
float targetRot = Angles.predictAngle(tile.worldx(), tile.worldy(),
|
||||
entity.target.x, entity.target.y, entity.target.xvelocity, entity.target.yvelocity, bullet.speed + overPrediction);
|
||||
|
||||
entity.rotation = MathUtils.lerpAngleDeg(entity.rotation, targetRot,
|
||||
entity.target.x, entity.target.y, entity.target.xvelocity, entity.target.yvelocity, bullet.speed);
|
||||
|
||||
entity.rotation = Mathf.slerp(entity.rotation, targetRot,
|
||||
rotatespeed*Timers.delta());
|
||||
|
||||
float reload = Vars.multiplier*this.reload;
|
||||
|
|
@ -129,18 +131,54 @@ public class Turret extends Block{
|
|||
return new TurretEntity();
|
||||
}
|
||||
|
||||
void drawTargeting(Tile tile){
|
||||
TurretEntity entity = tile.entity();
|
||||
|
||||
if(entity.target == null) return;
|
||||
|
||||
float dst = entity.distanceTo(entity.target);
|
||||
float hittime = dst / bullet.speed;
|
||||
|
||||
float angle = Angles.predictAngle(tile.worldx(), tile.worldy(),
|
||||
entity.target.x, entity.target.y, entity.target.xvelocity, entity.target.yvelocity, bullet.speed);
|
||||
|
||||
float predictX = entity.target.x + entity.target.xvelocity * hittime,
|
||||
predictY = entity.target.y + entity.target.yvelocity * hittime;
|
||||
|
||||
Draw.color(Color.GREEN);
|
||||
Draw.line(tile.worldx(), tile.worldy(), entity.target.x, entity.target.y);
|
||||
|
||||
Draw.color(Color.RED);
|
||||
Draw.line(tile.worldx(), tile.worldy(), entity.target.x + entity.target.xvelocity * hittime,
|
||||
entity.target.y + entity.target.yvelocity * hittime);
|
||||
|
||||
Draw.color(Color.PURPLE);
|
||||
Draw.thick(2f);
|
||||
Draw.lineAngle(tile.worldx(), tile.worldy(), angle, 7f);
|
||||
|
||||
Draw.reset();
|
||||
|
||||
if(Timers.getTime(tile, "reload") <= 0){
|
||||
Timers.run(hittime, ()->{
|
||||
Effects.effect("spawn", predictX, predictY);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected void shoot(Tile tile){
|
||||
TurretEntity entity = tile.entity();
|
||||
|
||||
float inac = Mathf.range(inaccuracy);
|
||||
|
||||
vector.set(0, 4).setAngle(entity.rotation + inac);
|
||||
Bullet out = new Bullet(bullet, tile.entity, tile.worldx()+vector.x, tile.worldy()+vector.y, entity.rotation + inac).add();
|
||||
Angles.translation(entity.rotation + inac, 4f);
|
||||
|
||||
Bullet out = new Bullet(bullet, tile.entity,
|
||||
tile.worldx() + Angles.x(), tile.worldy() + Angles.y(), entity.rotation + inac).add();
|
||||
out.damage = (int)(bullet.damage*Vars.multiplier);
|
||||
}
|
||||
|
||||
protected void bullet(Tile tile, float angle){
|
||||
Bullet out = new Bullet(bullet, tile.entity, tile.worldx()+vector.x, tile.worldy()+vector.y, angle).add();
|
||||
Bullet out = new Bullet(bullet, tile.entity, tile.worldx() + Angles.x(), tile.worldy() + Angles.y(), angle).add();
|
||||
out.damage = (int)(bullet.damage*Vars.multiplier);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue