Removed Upgrade class / Buffed units / Bugfixes

This commit is contained in:
Anuken
2018-08-24 09:39:02 -04:00
parent ee835f6514
commit 5e8686db77
15 changed files with 96 additions and 89 deletions

View File

@@ -16,7 +16,6 @@ import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.graphics.Shaders;
import io.anuke.mindustry.type.ContentList;
import io.anuke.mindustry.type.Mech;
import io.anuke.mindustry.type.Upgrade;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Core;
import io.anuke.ucore.core.Effects;
@@ -45,6 +44,7 @@ public class Mechs implements ContentList{
boostSpeed = 0.85f;
weapon = Weapons.blaster;
maxSpeed = 4f;
altChargeAlpha = 0.03f;
}
@Override
@@ -250,6 +250,6 @@ public class Mechs implements ContentList{
@Override
public Array<? extends Content> getAll(){
return Upgrade.all();
return Mech.all();
}
}

View File

@@ -20,7 +20,7 @@ public class UnitTypes implements ContentList{
ammoCapacity = 0;
range = 50f;
healSpeed = 0.05f;
health = 45;
health = 60;
}};
dagger = new UnitType("dagger", Dagger.class, Dagger::new){{
@@ -29,7 +29,7 @@ public class UnitTypes implements ContentList{
drag = 0.4f;
range = 40f;
weapon = Weapons.chainBlaster;
health = 90;
health = 180;
}};
titan = new UnitType("titan", Titan.class, Titan::new){{
@@ -37,8 +37,8 @@ public class UnitTypes implements ContentList{
speed = 0.18f;
drag = 0.4f;
range = 10f;
weapon = Weapons.chainBlaster;
health = 280;
weapon = Weapons.flamethrower;
health = 500;
}};
interceptor = new UnitType("interceptor", Interceptor.class, Interceptor::new){{
@@ -47,10 +47,11 @@ public class UnitTypes implements ContentList{
drag = 0.01f;
weapon = Weapons.chainBlaster;
isFlying = true;
health = 70;
}};
monsoon = new UnitType("monsoon", Monsoon.class, Monsoon::new){{
health = 230;
health = 250;
speed = 0.2f;
maxVelocity = 1.4f;
drag = 0.01f;
@@ -67,8 +68,7 @@ public class UnitTypes implements ContentList{
ammoCapacity = 0;
range = 70f;
itemCapacity = 70;
health = 120;
health = 45;
health = 220;
buildPower = 0.9f;
minePower = 1.1f;
healSpeed = 0.09f;

View File

@@ -5,7 +5,6 @@ import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.content.fx.ShootFx;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.type.ContentList;
import io.anuke.mindustry.type.Upgrade;
import io.anuke.mindustry.type.Weapon;
public class Weapons implements ContentList{
@@ -117,6 +116,6 @@ public class Weapons implements ContentList{
@Override
public Array<? extends Content> getAll(){
return Upgrade.all();
return Weapon.all();
}
}

View File

@@ -16,7 +16,7 @@ public class UnitBlocks extends BlockList implements ContentList{
public void load(){
dronePad = new UnitPad("drone-pad"){{
type = UnitTypes.drone;
produceTime = 4300;
produceTime = 5500;
size = 2;
consumes.power(0.08f);
consumes.items(new ItemStack[]{new ItemStack(Items.silicon, 30), new ItemStack(Items.lead, 30)});
@@ -24,7 +24,7 @@ public class UnitBlocks extends BlockList implements ContentList{
fabricatorPad = new UnitPad("fabricator-pad"){{
type = UnitTypes.fabricator;
produceTime = 5000;
produceTime = 7000;
size = 2;
consumes.power(0.2f);
consumes.items(new ItemStack[]{new ItemStack(Items.silicon, 70), new ItemStack(Items.lead, 80), new ItemStack(Items.titanium, 80)});

View File

@@ -22,7 +22,6 @@ import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.net.NetConnection;
import io.anuke.mindustry.type.ItemStack;
import io.anuke.mindustry.type.Mech;
import io.anuke.mindustry.type.Upgrade;
import io.anuke.mindustry.type.Weapon;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
@@ -762,13 +761,13 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
byte mechid = stream.readByte();
int index = stream.readByte();
players[index].readSaveSuper(stream);
players[index].mech = Upgrade.getByID(mechid);
players[index].mech = Mech.getByID(mechid);
players[index].dead = false;
}else if(local){
byte mechid = stream.readByte();
stream.readByte();
readSaveSuper(stream);
mech = Upgrade.getByID(mechid);
mech = Mech.getByID(mechid);
dead = false;
}
}
@@ -804,7 +803,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
boolean boosting = (bools & 4) != 0;
boolean alt = (bools & 8) != 0;
color.set(buffer.readInt());
mech = Upgrade.getByID(buffer.readByte());
mech = Mech.getByID(buffer.readByte());
int mine = buffer.readInt();
spawner = buffer.readInt();
float baseRotation = buffer.readShort() / 2f;

View File

@@ -8,7 +8,6 @@ import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.type.Upgrade;
import io.anuke.mindustry.type.Weapon;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.Floor;
@@ -211,7 +210,7 @@ public abstract class GroundUnit extends BaseUnit{
@Override
public void read(DataInput data, long time) throws IOException{
super.read(data, time);
weapon = Upgrade.getByID(data.readByte());
weapon = Weapon.getByID(data.readByte());
}
@Override
@@ -222,7 +221,7 @@ public abstract class GroundUnit extends BaseUnit{
@Override
public void readSave(DataInput stream) throws IOException{
weapon = Upgrade.getByID(stream.readByte());
weapon = Weapon.getByID(stream.readByte());
super.readSave(stream);
}

View File

@@ -223,7 +223,7 @@ public class TypeIO{
@ReadClass(Weapon.class)
public static Weapon readWeapon(ByteBuffer buffer){
return Upgrade.getByID(buffer.get());
return Weapon.getByID(buffer.get());
}
@WriteClass(Mech.class)
@@ -233,7 +233,7 @@ public class TypeIO{
@ReadClass(Mech.class)
public static Mech readMech(ByteBuffer buffer){
return Upgrade.getByID(buffer.get());
return Mech.getByID(buffer.get());
}
@WriteClass(Liquid.class)

View File

@@ -2,20 +2,29 @@ package io.anuke.mindustry.type;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.content.Weapons;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.game.UnlockableContent;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.ui.ContentDisplay;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.scene.ui.layout.Table;
import io.anuke.ucore.util.Bundles;
import static io.anuke.mindustry.Vars.mobile;
//TODO merge unit type with mech
public class Mech extends Upgrade implements UnlockableContent{
public boolean flying;
public class Mech implements UnlockableContent{
private static Array<Mech> mechs = new Array<>();
private static byte lastid;
public final byte id;
public final String name;
public final String description;
public boolean flying;
public float speed = 1.1f;
public float maxSpeed = 1.1f;
public float boostSpeed = 0.75f;
@@ -39,8 +48,24 @@ public class Mech extends Upgrade implements UnlockableContent{
public TextureRegion baseRegion, legRegion, region, iconRegion;
public Mech(String name, boolean flying){
super(name);
this.flying = flying;
this.id = lastid++;
this.name = name;
this.description = Bundles.get("mech." + name + ".description");
mechs.add(this);
}
public static Array<Mech> all() {
return mechs;
}
public static Mech getByID(int id){
return mechs.get(id);
}
public String localizedName(){
return Bundles.get("mech." + name + ".name");
}
public void updateAlt(Player player){}
@@ -92,4 +117,14 @@ public class Mech extends Upgrade implements UnlockableContent{
region = Draw.region(name);
iconRegion = Draw.region("mech-icon-" + name);
}
@Override
public String toString(){
return localizedName();
}
@Override
public Array<? extends Content> getAll(){
return all();
}
}

View File

@@ -1,54 +0,0 @@
package io.anuke.mindustry.type;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.game.Content;
import io.anuke.ucore.function.Consumer;
import io.anuke.ucore.function.Predicate;
import io.anuke.ucore.util.Bundles;
public abstract class Upgrade implements Content{
private static Array<Upgrade> upgrades = new Array<>();
private static byte lastid;
public final byte id;
public final String name;
public final String description;
public Upgrade(String name){
this.id = lastid++;
this.name = name;
this.description = Bundles.get("upgrade." + name + ".description");
upgrades.add(this);
}
public static <T extends Upgrade> void forEach(Consumer<T> type, Predicate<Upgrade> pred){
for(Upgrade u : upgrades){
if(pred.test(u)){
type.accept((T) u);
}
}
}
public static Array<Upgrade> all(){
return upgrades;
}
public static <T extends Upgrade> T getByID(byte id){
return (T) upgrades.get(id);
}
public String localizedName(){
return Bundles.get("upgrade." + name + ".name");
}
@Override
public String toString(){
return localizedName();
}
@Override
public Array<? extends Content> getAll(){
return all();
}
}

View File

@@ -1,6 +1,7 @@
package io.anuke.mindustry.type;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.Array;
import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.Annotations.Remote;
import io.anuke.mindustry.Vars;
@@ -8,6 +9,7 @@ import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.bullet.Bullet;
import io.anuke.mindustry.entities.traits.ShooterTrait;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.gen.Call;
import io.anuke.mindustry.net.Net;
import io.anuke.ucore.core.Effects;
@@ -17,7 +19,13 @@ import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Translator;
public class Weapon extends Upgrade{
public class Weapon implements Content{
private static Array<Weapon> weapons = new Array<>();
private static byte lastid;
public final byte id;
public final String name;
/**minimum cursor distance from player, fixes 'cross-eyed' shooting.*/
protected static float minPlayerDist = 20f;
/**ammo type map. set with setAmmo()*/
@@ -50,7 +58,9 @@ public class Weapon extends Upgrade{
public TextureRegion equipRegion, region;
protected Weapon(String name){
super(name);
this.id = lastid ++;
this.name = name;
weapons.add(this);
}
@Remote(targets = Loc.server, called = Loc.both, unreliable = true)
@@ -92,6 +102,14 @@ public class Weapon extends Upgrade{
shooter.getTimer().get(shooter.getShootTimer(left), weapon.reload);
}
public static Array<Weapon> all() {
return weapons;
}
public static Weapon getByID(int id){
return weapons.get(id);
}
@Override
public void load(){
equipRegion = Draw.region(name + "-equip");
@@ -103,6 +121,11 @@ public class Weapon extends Upgrade{
return "weapon";
}
@Override
public Array<? extends Content> getAll() {
return weapons;
}
public AmmoType getAmmo(){
return ammo;
}

View File

@@ -14,7 +14,7 @@ public class ItemImage extends Stack{
public ItemImage(TextureRegion region, Supplier<CharSequence> text){
Table t = new Table().left().bottom();
t.label(text).color(Color.DARK_GRAY).padBottom(-21).get().setFontScale(Unit.dp.scl(0.5f));
t.label(text).color(Color.DARK_GRAY).padBottom(-20).get().setFontScale(Unit.dp.scl(0.5f));
t.row();
t.label(text).get().setFontScale(Unit.dp.scl(0.5f));
@@ -25,7 +25,7 @@ public class ItemImage extends Stack{
public ItemImage(ItemStack stack){
Table t = new Table().left().bottom();
t.add(stack.amount + "").color(Color.DARK_GRAY).padBottom(-21).get().setFontScale(Unit.dp.scl(0.5f));
t.add(stack.amount + "").color(Color.DARK_GRAY).padBottom(-20).get().setFontScale(Unit.dp.scl(0.5f));
t.row();
t.add(stack.amount + "").get().setFontScale(Unit.dp.scl(0.5f));

View File

@@ -139,7 +139,7 @@ public class SettingsMenuDialog extends SettingsDialog{
}
if(!gwt){
graphics.checkPref("multithread", true, threads::setEnabled);
graphics.checkPref("multithread", mobile, threads::setEnabled);
if(Settings.getBool("multithread")){
threads.setEnabled(true);