Removed all usage of drawBullet, switched to BasicBulletType
This commit is contained in:
@@ -7,6 +7,7 @@ import io.anuke.mindustry.content.StatusEffects;
|
|||||||
import io.anuke.mindustry.content.fx.BulletFx;
|
import io.anuke.mindustry.content.fx.BulletFx;
|
||||||
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
import io.anuke.mindustry.content.fx.EnvironmentFx;
|
||||||
import io.anuke.mindustry.content.fx.Fx;
|
import io.anuke.mindustry.content.fx.Fx;
|
||||||
|
import io.anuke.mindustry.entities.bullet.BasicBulletType;
|
||||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
import io.anuke.mindustry.entities.bullet.Bullet;
|
||||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
import io.anuke.mindustry.entities.bullet.BulletType;
|
||||||
import io.anuke.mindustry.entities.effect.DamageArea;
|
import io.anuke.mindustry.entities.effect.DamageArea;
|
||||||
@@ -21,7 +22,6 @@ import io.anuke.ucore.core.Timers;
|
|||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.graphics.Fill;
|
import io.anuke.ucore.graphics.Fill;
|
||||||
import io.anuke.ucore.graphics.Lines;
|
import io.anuke.ucore.graphics.Lines;
|
||||||
import io.anuke.ucore.util.Angles;
|
|
||||||
import io.anuke.ucore.util.Geometry;
|
import io.anuke.ucore.util.Geometry;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
@@ -71,72 +71,46 @@ public class TurretBullets {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
basicIron = new BulletType(3f, 5) {
|
basicIron = new BasicBulletType(3f, 5) {
|
||||||
@Override
|
{
|
||||||
public void draw(Bullet b) {
|
bulletWidth = 7f;
|
||||||
drawBullet(Palette.bulletYellow, Palette.bulletYellowBack,
|
bulletHeight = 9f;
|
||||||
"bullet", b.x, b.y, 9f, 5f + b.fout()*7f, b.angle() - 90);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
basicSteel = new BulletType(6f, 0) {
|
basicSteel = new BasicBulletType(6f, 0) {
|
||||||
{
|
{
|
||||||
hiteffect = BulletFx.hitBulletBig;
|
hiteffect = BulletFx.hitBulletBig;
|
||||||
knockback = 0.5f;
|
knockback = 0.5f;
|
||||||
}
|
bulletWidth = 9f;
|
||||||
|
bulletHeight = 11f;
|
||||||
@Override
|
|
||||||
public void draw(Bullet b) {
|
|
||||||
drawBullet(Palette.bulletYellow, Palette.bulletYellowBack,
|
|
||||||
"bullet", b.x, b.y, 11f, 9f + b.fout()*8f, b.angle() - 90);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
basicLeadFragShell = new BulletType(3f, 0) {
|
basicLeadFragShell = new BasicBulletType(3f, 0) {
|
||||||
{
|
{
|
||||||
hiteffect = BulletFx.flakExplosion;
|
hiteffect = BulletFx.flakExplosion;
|
||||||
knockback = 0.8f;
|
knockback = 0.8f;
|
||||||
lifetime = 90f;
|
lifetime = 90f;
|
||||||
drag = 0.01f;
|
drag = 0.01f;
|
||||||
}
|
bulletWidth = bulletHeight = 9f;
|
||||||
|
fragBullet = basicLeadFrag;
|
||||||
@Override
|
bulletSprite = "frag";
|
||||||
public void draw(Bullet b) {
|
bulletShrink = 0.1f;
|
||||||
drawBullet(Palette.bulletYellow, Palette.bulletYellowBack,
|
|
||||||
"shell", b.x, b.y, 9f, 9f, b.angle() - 90);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hit(Bullet b, float x, float y) {
|
|
||||||
super.hit(b, x, y);
|
|
||||||
for(int i = 0; i < 9; i ++){
|
|
||||||
float len = Mathf.random(1f, 7f);
|
|
||||||
float a = Mathf.random(360f);
|
|
||||||
Bullet bullet = Bullet.create(TurretBullets.basicLeadFrag, b,
|
|
||||||
x + Angles.trnsx(a, len), y + Angles.trnsy(a, len), a);
|
|
||||||
bullet.velocity.scl(Mathf.random(0.2f, 1f));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void despawned(Bullet b) {
|
|
||||||
hit(b);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
basicLeadFrag = new BulletType(3f, 0) {
|
basicLeadFrag = new BasicBulletType(3f, 0) {
|
||||||
{
|
{
|
||||||
drag = 0.1f;
|
drag = 0.1f;
|
||||||
hiteffect = Fx.none;
|
hiteffect = Fx.none;
|
||||||
despawneffect = Fx.none;
|
despawneffect = Fx.none;
|
||||||
hitsize = 4;
|
hitsize = 4;
|
||||||
lifetime = 20f;
|
lifetime = 20f;
|
||||||
}
|
bulletWidth = 9f;
|
||||||
|
bulletHeight = 11f;
|
||||||
@Override
|
bulletShrink = 1f;
|
||||||
public void draw(Bullet b) {
|
//todo scaling
|
||||||
drawBullet(Palette.bulletYellow, Palette.bulletYellowBack,
|
|
||||||
"bullet", b.x, b.y, 7f + b.fout()*3f, 1f + b.fout()*11f, b.angle() - 90);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -239,14 +213,6 @@ public class TurretBullets {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private static void drawBullet(Color first, Color second, String name, float x, float y, float w, float h, float rot){
|
|
||||||
Draw.color(second);
|
|
||||||
Draw.rect(name + "-back", x, y, w, h, rot);
|
|
||||||
Draw.color(first);
|
|
||||||
Draw.rect(name, x, y, w, h, rot);
|
|
||||||
Draw.color();
|
|
||||||
}
|
|
||||||
|
|
||||||
private abstract static class LiquidShot extends BulletType{
|
private abstract static class LiquidShot extends BulletType{
|
||||||
Liquid liquid;
|
Liquid liquid;
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +1,42 @@
|
|||||||
package io.anuke.mindustry.entities.bullet;
|
package io.anuke.mindustry.entities.bullet;
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import io.anuke.mindustry.content.bullets.TurretBullets;
|
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.util.Angles;
|
import io.anuke.ucore.util.Angles;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
/**A BulletType for most ammo-based bullets shot from turrets and units.*/
|
/**A BulletType for most ammo-based bullets shot from turrets and units.*/
|
||||||
public abstract class BasicBulletType extends BulletType {
|
public class BasicBulletType extends BulletType {
|
||||||
public Color backColor = Palette.bulletYellowBack, frontColor = Palette.bulletYellow;
|
public Color backColor = Palette.bulletYellowBack, frontColor = Palette.bulletYellow;
|
||||||
public String bulletSprite = "bullet";
|
public String bulletSprite = "bullet";
|
||||||
public float bulletWidth = 5f, bulletHeight = 7f;
|
public float bulletWidth = 5f, bulletHeight = 7f;
|
||||||
|
public float bulletShrink = 0.5f;
|
||||||
|
|
||||||
public boolean frag;
|
|
||||||
public int fragBullets = 9;
|
public int fragBullets = 9;
|
||||||
public float fragVelocityMin = 0.2f, fragVelocityMax = 1f;
|
public float fragVelocityMin = 0.2f, fragVelocityMax = 1f;
|
||||||
public BulletType fragBullet = TurretBullets.basicLeadFrag;
|
public BulletType fragBullet = null;
|
||||||
|
|
||||||
public BasicBulletType(float speed, float damage) {
|
public BasicBulletType(float speed, float damage) {
|
||||||
super(speed, damage);
|
super(speed, damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Bullet b) {
|
||||||
|
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
||||||
|
|
||||||
|
Draw.color(backColor);
|
||||||
|
Draw.rect(bulletSprite + "-back", b.x, b.y, bulletWidth, height, b.angle() - 90);
|
||||||
|
Draw.color(frontColor);
|
||||||
|
Draw.rect(bulletSprite, b.x, b.y, bulletWidth, height, b.angle() - 90);
|
||||||
|
Draw.color();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void hit(Bullet b, float x, float y) {
|
public void hit(Bullet b, float x, float y) {
|
||||||
super.hit(b, x, y);
|
super.hit(b, x, y);
|
||||||
|
|
||||||
if(frag) {
|
if(fragBullet != null) {
|
||||||
for (int i = 0; i < fragBullets; i++) {
|
for (int i = 0; i < fragBullets; i++) {
|
||||||
float len = Mathf.random(1f, 7f);
|
float len = Mathf.random(1f, 7f);
|
||||||
float a = Mathf.random(360f);
|
float a = Mathf.random(360f);
|
||||||
@@ -38,7 +49,7 @@ public abstract class BasicBulletType extends BulletType {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void despawned(Bullet b) {
|
public void despawned(Bullet b) {
|
||||||
if(frag){
|
if(fragBullet != null){
|
||||||
hit(b);
|
hit(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user