Moved bullet FX to ammo type, beginning of weapon rework

This commit is contained in:
Anuken
2018-04-23 21:35:40 -04:00
parent 19d058a644
commit 8581213126
16 changed files with 311 additions and 275 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 203 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

File diff suppressed because it is too large Load Diff
Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 106 KiB

+2 -2
View File
@@ -1,7 +1,7 @@
#Autogenerated file. Do not modify. #Autogenerated file. Do not modify.
#Sun Apr 22 16:19:48 EDT 2018 #Mon Apr 23 21:27:41 EDT 2018
version=pre-alpha version=pre-alpha
androidBuildCode=1087 androidBuildCode=1090
name=Mindustry name=Mindustry
code=4.0 code=4.0
build=custom build build=custom build
@@ -1,28 +1,40 @@
package io.anuke.mindustry.content; package io.anuke.mindustry.content;
import io.anuke.mindustry.content.bullets.TurretBullets; import io.anuke.mindustry.content.bullets.TurretBullets;
import io.anuke.mindustry.content.fx.ShootFx;
import io.anuke.mindustry.resource.AmmoType; import io.anuke.mindustry.resource.AmmoType;
public class AmmoTypes { public class AmmoTypes {
public static final AmmoType public static final AmmoType
basicIron = new AmmoType(Items.iron, TurretBullets.basicIron, 5, 0.9f), basicIron = new AmmoType(Items.iron, TurretBullets.basicIron, 5){{
shootEffect = ShootFx.shootSmall;
smokeEffect = ShootFx.shootSmallSmoke;
}},
basicSteel = new AmmoType(Items.steel, TurretBullets.basicSteel, 5, 0.8f), basicSteel = new AmmoType(Items.steel, TurretBullets.basicSteel, 5){{
shootEffect = ShootFx.shootBig;
smokeEffect = ShootFx.shootBigSmoke;
}},
basicFlame = new AmmoType(Liquids.oil, TurretBullets.basicFlame, 0.3f, 0.9f), basicFlame = new AmmoType(Liquids.oil, TurretBullets.basicFlame, 0.3f){{
shootEffect = ShootFx.shootSmallFlame;
}},
basicLeadFrag = new AmmoType(Items.lead, TurretBullets.basicLeadFragShell, 1, 0.8f), basicLeadFrag = new AmmoType(Items.lead, TurretBullets.basicLeadFragShell, 1){{
shootEffect = ShootFx.shootBig2;
smokeEffect = ShootFx.shootBigSmoke2;
}},
lancerLaser = new AmmoType(TurretBullets.lancerLaser), lancerLaser = new AmmoType(TurretBullets.lancerLaser),
lightning = new AmmoType(TurretBullets.lightning), lightning = new AmmoType(TurretBullets.lightning),
oil = new AmmoType(Liquids.oil, TurretBullets.oilShot, 0.3f, 1f), oil = new AmmoType(Liquids.oil, TurretBullets.oilShot, 0.3f),
water = new AmmoType(Liquids.water, TurretBullets.waterShot, 0.3f, 1f), water = new AmmoType(Liquids.water, TurretBullets.waterShot, 0.3f),
lava = new AmmoType(Liquids.lava, TurretBullets.lavaShot, 0.3f, 1f), lava = new AmmoType(Liquids.lava, TurretBullets.lavaShot, 0.3f),
cryofluid = new AmmoType(Liquids.cryofluid, TurretBullets.cryoShot, 0.3f, 1f); cryofluid = new AmmoType(Liquids.cryofluid, TurretBullets.cryoShot, 0.3f);
} }
@@ -114,11 +114,11 @@ public class Recipes {
new Recipe(liquid, LiquidBlocks.pump, stack(Items.steel, 10)), new Recipe(liquid, LiquidBlocks.pump, stack(Items.steel, 10)),
new Recipe(liquid, LiquidBlocks.fluxpump, stack(Items.steel, 10), stack(Items.densealloy, 5)), new Recipe(liquid, LiquidBlocks.fluxpump, stack(Items.steel, 10), stack(Items.densealloy, 5)),
new Recipe(units, UnitBlocks.droneFactory, stack(Items.steel, 10)), //new Recipe(units, UnitBlocks.droneFactory, stack(Items.steel, 10)),
new Recipe(units, UnitBlocks.vtolFactory, stack(Items.steel, 10)), //new Recipe(units, UnitBlocks.vtolFactory, stack(Items.steel, 10)),
new Recipe(units, UnitBlocks.droneFactory, stack(Items.steel, 10)), //new Recipe(units, UnitBlocks.droneFactory, stack(Items.steel, 10)),
new Recipe(units, UnitBlocks.droneFactory, stack(Items.steel, 10)), //new Recipe(units, UnitBlocks.droneFactory, stack(Items.steel, 10)),
new Recipe(units, UnitBlocks.walkerFactory, stack(Items.steel, 10)), //new Recipe(units, UnitBlocks.walkerFactory, stack(Items.steel, 10)),
new Recipe(units, DebugBlocks.itemSource, stack(Items.steel, 10)).setDebug(), new Recipe(units, DebugBlocks.itemSource, stack(Items.steel, 10)).setDebug(),
new Recipe(units, DebugBlocks.itemVoid, stack(Items.steel, 10)).setDebug(), new Recipe(units, DebugBlocks.itemVoid, stack(Items.steel, 10)).setDebug(),
@@ -19,8 +19,6 @@ public class WeaponBlocks{
ammoTypes = new AmmoType[]{AmmoTypes.basicIron}; ammoTypes = new AmmoType[]{AmmoTypes.basicIron};
reload = 25f; reload = 25f;
restitution = 0.03f; restitution = 0.03f;
shootEffect = ShootFx.shootSmall;
smokeEffect = ShootFx.shootSmallSmoke;
ammoUseEffect = ShootFx.shellEjectSmall; ammoUseEffect = ShootFx.shellEjectSmall;
}}, }},
@@ -32,8 +30,6 @@ public class WeaponBlocks{
restitution = 0.03f; restitution = 0.03f;
recoil = 1.5f; recoil = 1.5f;
burstSpacing = 6f; burstSpacing = 6f;
shootEffect = ShootFx.shootSmall;
smokeEffect = ShootFx.shootSmallSmoke;
ammoUseEffect = ShootFx.shellEjectSmall; ammoUseEffect = ShootFx.shellEjectSmall;
}}, }},
@@ -42,7 +38,6 @@ public class WeaponBlocks{
recoil = 0f; recoil = 0f;
reload = 5f; reload = 5f;
shootCone = 50f; shootCone = 50f;
shootEffect = ShootFx.shootSmallFlame;
ammoUseEffect = ShootFx.shellEjectSmall; ammoUseEffect = ShootFx.shellEjectSmall;
drawer = (tile, entity) -> { drawer = (tile, entity) -> {
@@ -58,8 +53,6 @@ public class WeaponBlocks{
ammoEjectBack = 2f; ammoEjectBack = 2f;
recoil = 3f; recoil = 3f;
shootShake = 2f; shootShake = 2f;
shootEffect = ShootFx.shootBig;
smokeEffect = ShootFx.shootBigSmoke;
ammoUseEffect = ShootFx.shellEjectMedium; ammoUseEffect = ShootFx.shellEjectMedium;
}}, }},
@@ -73,8 +66,6 @@ public class WeaponBlocks{
cooldown = 0.03f; cooldown = 0.03f;
recoil = 3f; recoil = 3f;
shootShake = 2f; shootShake = 2f;
shootEffect = ShootFx.shootBig2;
smokeEffect = ShootFx.shootBigSmoke2;
ammoUseEffect = ShootFx.shellEjectBig; ammoUseEffect = ShootFx.shellEjectBig;
drawer = (tile, entity) -> { drawer = (tile, entity) -> {
@@ -2,9 +2,10 @@ package io.anuke.mindustry.entities.units;
import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.ObjectSet; import com.badlogic.gdx.utils.ObjectSet;
import io.anuke.mindustry.content.bullets.TurretBullets;
import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.entities.Unit; import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.game.TeamInfo.TeamData; import io.anuke.mindustry.game.TeamInfo.TeamData;
import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Effects; import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers; import io.anuke.ucore.core.Timers;
@@ -21,7 +22,7 @@ public class FlyingUnitType extends UnitType {
public FlyingUnitType(String name) { public FlyingUnitType(String name) {
super(name); super(name);
speed = 0.2f; speed = 0.2f;
maxVelocity = 4f; maxVelocity = 2f;
drag = 0.01f; drag = 0.01f;
isFlying = true; isFlying = true;
} }
@@ -65,7 +66,7 @@ public class FlyingUnitType extends UnitType {
unit.velocity.add(vec); //TODO clamp it so it doesn't glitch out at low fps unit.velocity.add(vec); //TODO clamp it so it doesn't glitch out at low fps
if(unit.timer.get(timerReload, reload) && len < range){ if(unit.timer.get(timerReload, reload) && len < range){
//shoot(unit, BulletType.shot, ang, 4f); shoot(unit, TurretBullets.basicIron, unit.rotation, 4f);
} }
} }
@@ -3,7 +3,9 @@ package io.anuke.mindustry.entities.units.types;
import io.anuke.mindustry.entities.units.GroundUnitType; import io.anuke.mindustry.entities.units.GroundUnitType;
public class Brute extends GroundUnitType { public class Brute extends GroundUnitType {
public Brute(String name) { public Brute(String name) {
super(name); super(name);
} }
} }
@@ -4,6 +4,7 @@ import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.units.BaseUnit; import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.entities.units.FlyingUnitType; import io.anuke.mindustry.entities.units.FlyingUnitType;
import io.anuke.ucore.graphics.Draw; import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.util.Mathf;
public class Vtol extends FlyingUnitType { public class Vtol extends FlyingUnitType {
@@ -16,6 +17,10 @@ public class Vtol extends FlyingUnitType {
Draw.alpha(unit.hitTime / Unit.hitDuration); Draw.alpha(unit.hitTime / Unit.hitDuration);
Draw.rect(name, unit.x, unit.y, unit.rotation - 90); Draw.rect(name, unit.x, unit.y, unit.rotation - 90);
for(int i : Mathf.signs){
Draw.rect(name + "-booster-1", unit.x, unit.y, 12*i, 12, unit.rotation - 90);
Draw.rect(name + "-booster-2", unit.x, unit.y, 12*i, 12, unit.rotation - 90);
}
Draw.alpha(1f); Draw.alpha(1f);
} }
@@ -1,7 +1,9 @@
package io.anuke.mindustry.resource; package io.anuke.mindustry.resource;
import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.entities.BulletType; import io.anuke.mindustry.entities.BulletType;
import io.anuke.ucore.core.Effects.Effect;
public class AmmoType { public class AmmoType {
private static int lastID = 0; private static int lastID = 0;
@@ -17,8 +19,12 @@ public class AmmoType {
/**For item ammo, this is amount given per ammo item. /**For item ammo, this is amount given per ammo item.
* For liquid ammo, this is amount used per shot.*/ * For liquid ammo, this is amount used per shot.*/
public final float quantityMultiplier; public final float quantityMultiplier;
/**Turret shoot speed multiplier.*/ /**Reload speed multiplier.*/
public final float speedMultiplier; public float speedMultiplier = 1f;
/**Effect created when shooting.*/
public Effect shootEffect = Fx.none;
/**Extra smoke effect created when shooting.*/
public Effect smokeEffect = Fx.none;
{ {
this.id = (byte)(lastID++); this.id = (byte)(lastID++);
@@ -33,20 +39,18 @@ public class AmmoType {
this.speedMultiplier = 1f; this.speedMultiplier = 1f;
} }
public AmmoType(Item item, BulletType result, float multiplier, float speedMultiplier){ public AmmoType(Item item, BulletType result, float multiplier){
this.item = item; this.item = item;
this.liquid = null; this.liquid = null;
this.bullet = result; this.bullet = result;
this.quantityMultiplier = multiplier; this.quantityMultiplier = multiplier;
this.speedMultiplier = speedMultiplier;
} }
public AmmoType(Liquid liquid, BulletType result, float multiplier, float speedMultiplier){ public AmmoType(Liquid liquid, BulletType result, float multiplier){
this.item = null; this.item = null;
this.liquid = liquid; this.liquid = liquid;
this.bullet = result; this.bullet = result;
this.quantityMultiplier = multiplier; this.quantityMultiplier = multiplier;
this.speedMultiplier = speedMultiplier;
} }
public static Array<AmmoType> getAllTypes() { public static Array<AmmoType> getAllTypes() {
@@ -1,8 +1,6 @@
package io.anuke.mindustry.resource; package io.anuke.mindustry.resource;
import io.anuke.mindustry.Vars; import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.Bullet;
import io.anuke.mindustry.entities.BulletType;
import io.anuke.mindustry.entities.Player; import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.Unit; import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.net.Net; import io.anuke.mindustry.net.Net;
@@ -16,8 +14,6 @@ import io.anuke.ucore.util.Translator;
public class Weapon extends Upgrade{ public class Weapon extends Upgrade{
/**weapon reload in frames*/ /**weapon reload in frames*/
protected float reload; protected float reload;
/**type of bullet shot*/
protected BulletType type;
/**sound made when shooting*/ /**sound made when shooting*/
protected String shootsound = "shoot"; protected String shootsound = "shoot";
/**amount of shots per fire*/ /**amount of shots per fire*/
@@ -37,10 +33,9 @@ public class Weapon extends Upgrade{
/**translator for vector calulations*/ /**translator for vector calulations*/
protected Translator tr = new Translator(); protected Translator tr = new Translator();
protected Weapon(String name, float reload, BulletType type){ protected Weapon(String name, float reload){
super(name); super(name);
this.reload = reload; this.reload = reload;
this.type = type;
} }
public void update(Player p, boolean left){ public void update(Player p, boolean left){
@@ -78,7 +73,7 @@ public class Weapon extends Upgrade{
void bullet(Unit owner, float x, float y, float angle){ void bullet(Unit owner, float x, float y, float angle){
tr.trns(angle, 3f); tr.trns(angle, 3f);
//TODO implement!
Bullet.create(type, owner, x + tr.x, y + tr.y, angle); //Bullet.create(type, owner, x + tr.x, y + tr.y, angle);
} }
} }
@@ -67,7 +67,9 @@ public class DebugFragment implements Fragment {
row(); row();
new button("death", () -> player.damage(99999, false)); new button("death", () -> player.damage(99999, false));
row(); row();
new button("spawn", () -> new BaseUnit(UnitTypes.scout, Team.red).set(player.x, player.y).add()); new button("spawn1", () -> new BaseUnit(UnitTypes.vtol, Team.red).set(player.x, player.y).add());
row();
new button("spawn2", () -> new BaseUnit(UnitTypes.scout, Team.red).set(player.x, player.y).add());
row(); row();
}}.end(); }}.end();
@@ -225,6 +225,9 @@ public abstract class Turret extends Block{
} }
protected void effects(Tile tile){ protected void effects(Tile tile){
Effect shootEffect = this.shootEffect == Fx.none ? peekAmmo(tile).shootEffect : this.shootEffect;
Effect smokeEffect = this.smokeEffect == Fx.none ? peekAmmo(tile).smokeEffect : this.smokeEffect;
TurretEntity entity = tile.entity(); TurretEntity entity = tile.entity();
Effects.effect(shootEffect, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation); Effects.effect(shootEffect, tile.drawx() + tr.x, tile.drawy() + tr.y, entity.rotation);