Implemented artillery turret, carbide artillery shells

This commit is contained in:
Anuken
2018-06-24 21:05:00 -04:00
parent c7fb517e6c
commit 6e5aec080a
11 changed files with 112 additions and 13 deletions

View File

@@ -298,7 +298,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
}
public float getViewDistance(){
return 130f;
return 135f;
}
public abstract TextureRegion getIconRegion();

View File

@@ -0,0 +1,36 @@
package io.anuke.mindustry.entities.bullet;
import io.anuke.mindustry.content.fx.BulletFx;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.graphics.Draw;
//TODO scale velocity depending on fslope()
public class ArtilleryBulletType extends BasicBulletType {
public ArtilleryBulletType(float speed, float damage, String bulletSprite) {
super(speed, damage, bulletSprite);
collidesTiles = false;
collides = false;
}
@Override
public void update(Bullet b) {
if(b.timer.get(0, 3 + b.fslope()*2f)){
Effects.effect(BulletFx.artilleryTrail, b.x, b.y, b.fslope() * 4f);
}
}
@Override
public void draw(Bullet b) {
float baseScale = 0.7f;
float scale = (baseScale + b.fslope()*(1f-baseScale));
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
Draw.color(backColor);
Draw.rect(backRegion, b.x, b.y, bulletWidth * scale, height * scale, b.angle() - 90);
Draw.color(frontColor);
Draw.rect(frontRegion, b.x, b.y, bulletWidth * scale, height * scale, b.angle() - 90);
Draw.color();
}
}

View File

@@ -2,6 +2,7 @@ package io.anuke.mindustry.entities.bullet;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.mindustry.entities.Damage;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.util.Angles;
@@ -18,6 +19,10 @@ public class BasicBulletType extends BulletType {
public float fragVelocityMin = 0.2f, fragVelocityMax = 1f;
public BulletType fragBullet = null;
/**Use a negative value to disable splash damage.*/
public float splashDamageRadius = -1f;
public float splashDamage = 6f;
public TextureRegion backRegion;
public TextureRegion frontRegion;
@@ -54,11 +59,15 @@ public class BasicBulletType extends BulletType {
Bullet.create(fragBullet, b, x + Angles.trnsx(a, len), y + Angles.trnsy(a, len), a, Mathf.random(fragVelocityMin, fragVelocityMax));
}
}
if(splashDamageRadius > 0){
Damage.damage(x, y, splashDamageRadius, splashDamage);
}
}
@Override
public void despawned(Bullet b) {
if(fragBullet != null){
if(fragBullet != null || splashDamageRadius > 0){
hit(b);
}
}

View File

@@ -166,7 +166,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
@Override
public boolean collides(SolidTrait other){
return super.collides(other);
return type.collides && super.collides(other);
}
@Override

View File

@@ -27,6 +27,8 @@ public abstract class BulletType extends BaseBulletType<Bullet> implements Conte
public boolean syncable;
/**Whether this bullet type collides with tiles.*/
public boolean collidesTiles = true;
/**Whether this bullet types collides with anything at all.*/
public boolean collides = true;
public BulletType(float speed, float damage){
this.id = lastid ++;

View File

@@ -170,7 +170,7 @@ public abstract class GroundUnit extends BaseUnit {
TileEntity core = getClosestEnemyCore();
float dst = core == null ? 0 :distanceTo(core);
if(core != null && dst < inventory.getAmmo().getRange()){
if(core != null && inventory.hasAmmo() && dst < inventory.getAmmo().getRange()){
target = core;
}else {
retarget(() -> targetClosest());