mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-08-03 16:39:37 +07:00
Balanced multiple generators, bugfixes, made some turrets use power
This commit is contained in:
@ -79,7 +79,7 @@ project(":core") {
|
||||
apply plugin: "java"
|
||||
|
||||
dependencies {
|
||||
compile 'com.github.anuken:ucore:2d86b0497e'
|
||||
compile 'com.github.anuken:ucore:91e4e11010'
|
||||
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
|
||||
compile "com.badlogicgames.gdx:gdx-ai:1.8.1"
|
||||
}
|
||||
|
BIN
core/assets-raw/sprites/blocks/block-2x2.png
Normal file
BIN
core/assets-raw/sprites/blocks/block-2x2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 215 B |
BIN
core/assets-raw/sprites/blocks/block-3x3.png
Normal file
BIN
core/assets-raw/sprites/blocks/block-3x3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 226 B |
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 44 KiB |
@ -15,7 +15,7 @@ import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class EMP extends TimedEntity{
|
||||
static final int maxTargets = 8;
|
||||
static final int maxTargets = 10;
|
||||
static Array<Tile> array = new Array<>();
|
||||
|
||||
int radius = 4;
|
||||
@ -53,6 +53,7 @@ public class EMP extends TimedEntity{
|
||||
|
||||
if(tile.block() instanceof PowerAcceptor){
|
||||
PowerAcceptor p = (PowerAcceptor)tile.block();
|
||||
tile.entity.damage(damage*2); //extra damage
|
||||
p.setPower(tile, 0f);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class TeslaOrb extends Entity{
|
||||
if(Mathf.chance(stopchance)){
|
||||
break;
|
||||
}
|
||||
Array<SolidEntity> enemies = Entities.getNearby(curx, cury, range);
|
||||
Array<SolidEntity> enemies = Entities.getNearby(curx, cury, range*2f);
|
||||
|
||||
for(SolidEntity entity : enemies){
|
||||
if(entity instanceof Enemy && entity.distanceTo(curx, cury) < range
|
||||
|
@ -1,7 +1,9 @@
|
||||
package io.anuke.mindustry.entities.enemies;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.Bullet;
|
||||
import io.anuke.mindustry.entities.BulletType;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
|
||||
public class BlastEnemy extends Enemy{
|
||||
|
||||
@ -17,7 +19,13 @@ public class BlastEnemy extends Enemy{
|
||||
|
||||
void move(){
|
||||
super.move();
|
||||
if(target != null && target.distanceTo(this) < 10f){
|
||||
float range = 10f;
|
||||
if(target instanceof TileEntity){
|
||||
TileEntity e = (TileEntity)target;
|
||||
range = (e.tile.block().width * Vars.tilesize) /2f + 6f;
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -101,7 +101,7 @@ public class Enemy extends DestructibleEntity{
|
||||
int cindex = -1;
|
||||
float dst = Float.MAX_VALUE;
|
||||
|
||||
|
||||
//find closest node index
|
||||
for(Tile tile : path){
|
||||
if(Vector2.dst(tile.worldx(), tile.worldy(), x, y) < dst){
|
||||
dst = Vector2.dst(tile.worldx(), tile.worldy(), x, y);
|
||||
@ -111,11 +111,13 @@ public class Enemy extends DestructibleEntity{
|
||||
index ++;
|
||||
}
|
||||
|
||||
//set node to that index
|
||||
node = cindex;
|
||||
|
||||
int x2 = path[node].x, y2 = path[node].y;
|
||||
|
||||
if(World.raycast(Mathf.scl2(x, Vars.tilesize), Mathf.scl2(y, Vars.tilesize), x2, y2) != null){
|
||||
//if the enemy can move to that node right now, set its position to it
|
||||
if(World.raycast(Mathf.scl2(x, Vars.tilesize), Mathf.scl2(y, Vars.tilesize), x2, y2) == null){
|
||||
Timers.run(Mathf.random(15f), ()->{
|
||||
set(x2 * Vars.tilesize, y2 * Vars.tilesize);
|
||||
});
|
||||
|
@ -12,13 +12,12 @@ import io.anuke.ucore.graphics.Hue;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
|
||||
public class HealerEnemy extends Enemy{
|
||||
int healTime = 14;
|
||||
|
||||
public HealerEnemy(int spawn) {
|
||||
super(spawn);
|
||||
|
||||
speed = 0.2f;
|
||||
reload = 30;
|
||||
reload = 14;
|
||||
maxhealth = 130;
|
||||
range = 90f;
|
||||
bullet = BulletType.shot;
|
||||
@ -48,7 +47,7 @@ public class HealerEnemy extends Enemy{
|
||||
void updateShooting(){
|
||||
Enemy enemy = (Enemy)target;
|
||||
|
||||
if(enemy.health < enemy.maxhealth && Timers.get(this, "heal", healTime)){
|
||||
if(enemy.health < enemy.maxhealth && Timers.get(this, "heal", reload)){
|
||||
enemy.health ++;
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class TitanEnemy extends Enemy{
|
||||
|
||||
speed = 0.1f;
|
||||
reload = 30;
|
||||
maxhealth = 330;
|
||||
maxhealth = 400;
|
||||
range = 80f;
|
||||
bullet = BulletType.small;
|
||||
hitbox.setSize(7f);
|
||||
|
@ -93,7 +93,10 @@ public class SaveIO{
|
||||
TankEnemy.class,
|
||||
BlastEnemy.class,
|
||||
MortarEnemy.class,
|
||||
TestEnemy.class
|
||||
TestEnemy.class,
|
||||
HealerEnemy.class,
|
||||
TitanEnemy.class,
|
||||
EmpEnemy.class
|
||||
);
|
||||
|
||||
private static final ObjectMap<Class<? extends Enemy>, Byte> idEnemies = new ObjectMap<Class<? extends Enemy>, Byte>(){{
|
||||
|
@ -362,6 +362,10 @@ public class World{
|
||||
for(int ry = -rad; ry <= rad; ry ++){
|
||||
Tile other = tile(rx+tilex, ry+tiley);
|
||||
|
||||
if(other != null && other.getLinked() != null){
|
||||
other = other.getLinked();
|
||||
}
|
||||
|
||||
if(other == null || other.entity == null ||(tile != null && other.entity == tile.entity)) continue;
|
||||
|
||||
TileEntity e = other.entity;
|
||||
|
@ -185,13 +185,18 @@ public class ProductionBlocks{
|
||||
generateAmount = 4f;
|
||||
powerCapacity = 40f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String description(){
|
||||
return "Generates power from coal.";
|
||||
}
|
||||
},
|
||||
thermalgenerator = new LiquidPowerGenerator("thermalgenerator"){
|
||||
{
|
||||
formalName = "thermal generator";
|
||||
//TODO
|
||||
generateLiquid = Liquid.lava;
|
||||
inputLiquid = 2f;
|
||||
inputLiquid = 5f;
|
||||
generatePower = 1f;
|
||||
powerCapacity = 40f;
|
||||
}
|
||||
@ -206,7 +211,7 @@ public class ProductionBlocks{
|
||||
formalName = "combustion generator";
|
||||
//TODO
|
||||
generateLiquid = Liquid.oil;
|
||||
inputLiquid = 2f;
|
||||
inputLiquid = 8f;
|
||||
generatePower = 1f;
|
||||
powerCapacity = 40f;
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.types.defense.LaserTurret;
|
||||
import io.anuke.mindustry.world.blocks.types.defense.PowerTurret;
|
||||
import io.anuke.mindustry.world.blocks.types.defense.Turret;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
@ -118,21 +119,18 @@ public class WeaponBlocks{
|
||||
},
|
||||
|
||||
laserturret = new LaserTurret("laserturret"){
|
||||
|
||||
|
||||
{
|
||||
beamColor = Color.SKY;
|
||||
formalName = "laser turret";
|
||||
range = 60;
|
||||
reload = 4f;
|
||||
damage = 10;
|
||||
ammo = Item.coal;
|
||||
health = 110;
|
||||
ammoMultiplier = 60;
|
||||
powerUsed = 0.2f;
|
||||
}
|
||||
},
|
||||
|
||||
teslaturret = new Turret("waveturret"){
|
||||
teslaturret = new PowerTurret("waveturret"){
|
||||
{
|
||||
formalName = "tesla turret";
|
||||
range = 70;
|
||||
@ -148,7 +146,7 @@ public class WeaponBlocks{
|
||||
Angles.translation(entity.rotation, 4);
|
||||
|
||||
new TeslaOrb(tile.worldx() + Angles.x(), tile.worldy() + Angles.y(),
|
||||
70, (int)(9*Vars.multiplier)).add();
|
||||
range, (int)(9*Vars.multiplier)).add();
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -12,7 +12,7 @@ import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
public class LaserTurret extends Turret{
|
||||
public class LaserTurret extends PowerTurret{
|
||||
protected Color beamColor = Color.WHITE.cpy();
|
||||
protected String hiteffect = "laserhit";
|
||||
protected int damage = 4;
|
||||
|
@ -0,0 +1,103 @@
|
||||
package io.anuke.mindustry.world.blocks.types.defense;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.types.PowerAcceptor;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class PowerTurret extends Turret implements PowerAcceptor{
|
||||
public float powerCapacity = 20f;
|
||||
public float powerUsed = 0.5f;
|
||||
|
||||
public PowerTurret(String name) {
|
||||
super(name);
|
||||
ammo = Item.stone;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPixelOverlay(Tile tile){
|
||||
Vector2 offset = getPlaceOffset();
|
||||
|
||||
Draw.color("green");
|
||||
Draw.dashcircle(tile.worldx() + offset.x, tile.worldy() + offset.y, range);
|
||||
Draw.reset();
|
||||
|
||||
PowerTurretEntity entity = tile.entity();
|
||||
|
||||
float fract = (float)entity.power / powerCapacity;
|
||||
if(fract > 0)
|
||||
fract = Mathf.clamp(fract, 0.24f, 1f);
|
||||
|
||||
Vars.renderer.drawBar(Color.YELLOW, tile.worldx() + offset.x, tile.worldy() + 6 + offset.y, fract);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasAmmo(Tile tile){
|
||||
PowerTurretEntity entity = tile.entity();
|
||||
return entity.power >= powerUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consumeAmmo(Tile tile){
|
||||
PowerTurretEntity entity = tile.entity();
|
||||
entity.power -= powerUsed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile dest, Tile source){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptsPower(Tile tile){
|
||||
PowerTurretEntity entity = tile.entity();
|
||||
|
||||
return entity.power + 0.001f <= powerCapacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float addPower(Tile tile, float amount){
|
||||
PowerTurretEntity entity = tile.entity();
|
||||
|
||||
float canAccept = Math.min(powerCapacity - entity.power, amount);
|
||||
|
||||
entity.power += canAccept;
|
||||
|
||||
return canAccept;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(Tile tile, float power){
|
||||
PowerTurretEntity entity = tile.entity();
|
||||
entity.power = power;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
return new PowerTurretEntity();
|
||||
}
|
||||
|
||||
public static class PowerTurretEntity extends TurretEntity{
|
||||
public float power;
|
||||
|
||||
@Override
|
||||
public void write(DataOutputStream stream) throws IOException{
|
||||
stream.writeFloat(power);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(DataInputStream stream) throws IOException{
|
||||
power = stream.readFloat();
|
||||
}
|
||||
}
|
||||
}
|
@ -35,7 +35,7 @@ public class Turret extends Block{
|
||||
protected int ammoMultiplier = 20;
|
||||
protected int maxammo = 400;
|
||||
protected float rotatespeed = 0.2f;
|
||||
protected float shootCone = 2f;
|
||||
protected float shootCone = 5f;
|
||||
|
||||
public Turret(String name) {
|
||||
super(name);
|
||||
@ -112,7 +112,7 @@ public class Turret extends Block{
|
||||
if(entity.target != null && entity.target.isDead())
|
||||
entity.target = null;
|
||||
|
||||
if(entity.ammo > 0){
|
||||
if(hasAmmo(tile)){
|
||||
|
||||
if(Timers.get(entity, "target", targetInterval)){
|
||||
entity.target = (Enemy)Entities.getClosest(tile.worldx(), tile.worldy(), range, e->{
|
||||
@ -132,12 +132,23 @@ public class Turret extends Block{
|
||||
if(Angles.angleDist(entity.rotation, targetRot) < shootCone && Timers.get(tile, "reload", reload)){
|
||||
Effects.sound(shootsound, entity);
|
||||
shoot(tile);
|
||||
consumeAmmo(tile);
|
||||
entity.ammo --;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasAmmo(Tile tile){
|
||||
TurretEntity entity = tile.entity();
|
||||
return entity.ammo > 0;
|
||||
}
|
||||
|
||||
public void consumeAmmo(Tile tile){
|
||||
TurretEntity entity = tile.entity();
|
||||
entity.ammo --;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity getEntity(){
|
||||
return new TurretEntity();
|
||||
|
@ -22,13 +22,12 @@ public class Generator extends PowerBlock{
|
||||
public int laserRange = 6;
|
||||
public int laserDirections = 4;
|
||||
public int powerRange = 4;
|
||||
public float powerSpeed = 0.03f;
|
||||
public float powerSpeed = 0.06f;
|
||||
public boolean explosive = true;
|
||||
public boolean drawRadius = false;
|
||||
|
||||
public Generator(String name) {
|
||||
super(name);
|
||||
explosionEffect = "generatorexplosion";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -41,7 +40,7 @@ public class Generator extends PowerBlock{
|
||||
|
||||
Timers.run(Mathf.random(8f + Mathf.random(6f)), () -> {
|
||||
Effects.shake(6f, 8f, x, y);
|
||||
Effects.effect(explosionEffect, x, y);
|
||||
Effects.effect("generatorexplosion", x, y);
|
||||
Effects.effect("shockwave", x, y);
|
||||
|
||||
Timers.run(12f + Mathf.random(20f), () -> {
|
||||
@ -128,9 +127,12 @@ public class Generator extends PowerBlock{
|
||||
|
||||
for(i = 1; i < laserRange; i++){
|
||||
Tile other = World.tile(tile.x + i * point.x, tile.y + i * point.y);
|
||||
|
||||
|
||||
if(other != null && other.block() instanceof PowerAcceptor){
|
||||
return other;
|
||||
Tile linked = other.getLinked();
|
||||
if(linked == null || linked instanceof PowerAcceptor){
|
||||
return other;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -20,7 +20,7 @@ public class LiquidPowerGenerator extends Generator implements LiquidAcceptor{
|
||||
/**Power to generate per generateInput.*/
|
||||
public float generatePower = 1f;
|
||||
/**How much liquid to consume to get one generatePower.*/
|
||||
public float inputLiquid = 1f;
|
||||
public float inputLiquid = 5f;
|
||||
public float liquidCapacity = 30f;
|
||||
public String generateEffect = "generate";
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user