Added alpha drone swarm ability
This commit is contained in:
@@ -11,9 +11,12 @@ import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.entities.effect.Fire;
|
||||
import io.anuke.mindustry.entities.effect.Lightning;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
import io.anuke.mindustry.entities.units.types.AlphaDrone;
|
||||
import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.graphics.Shaders;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.ContentList;
|
||||
import io.anuke.mindustry.type.Mech;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
@@ -24,8 +27,7 @@ import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Mechs implements ContentList{
|
||||
public static Mech alpha, delta, tau, omega, dart, javelin, trident, halberd;
|
||||
@@ -37,6 +39,7 @@ public class Mechs implements ContentList{
|
||||
public void load(){
|
||||
|
||||
alpha = new Mech("alpha-mech", false){
|
||||
int maxDrones = 3;
|
||||
{
|
||||
drillPower = 1;
|
||||
mineSpeed = 1.5f;
|
||||
@@ -44,14 +47,41 @@ public class Mechs implements ContentList{
|
||||
boostSpeed = 0.85f;
|
||||
weapon = Weapons.blaster;
|
||||
maxSpeed = 4f;
|
||||
altChargeAlpha = 0.03f;
|
||||
altChargeAlpha = 0.04f;
|
||||
trailColorTo = Color.valueOf("ffd37f");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateAlt(Player player){
|
||||
if(player.altHeat >= 0.91f){
|
||||
|
||||
if(getDrones(player) >= maxDrones){
|
||||
player.altHeat = 0f;
|
||||
}
|
||||
|
||||
if(player.altHeat >= 0.91f){
|
||||
if(!Net.client()) {
|
||||
AlphaDrone drone = (AlphaDrone) UnitTypes.alphaDrone.create(player.getTeam());
|
||||
drone.leader = player;
|
||||
drone.set(player.x, player.y);
|
||||
drone.add();
|
||||
Effects.effect(UnitFx.unitLand, player);
|
||||
}
|
||||
player.altHeat = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Player player){
|
||||
if(getDrones(player) < maxDrones){
|
||||
player.hitTime = Math.max(player.hitTime, player.altHeat * Unit.hitDuration);
|
||||
}
|
||||
}
|
||||
|
||||
int getDrones(Player player){
|
||||
int sum = 0;
|
||||
for(BaseUnit unit : unitGroups[player.getTeam().ordinal()].all()){
|
||||
if(unit instanceof AlphaDrone && ((AlphaDrone) unit).leader == player) sum ++;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.content;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
import io.anuke.mindustry.entities.units.UnitType;
|
||||
@@ -8,7 +9,7 @@ import io.anuke.mindustry.game.Content;
|
||||
import io.anuke.mindustry.type.ContentList;
|
||||
|
||||
public class UnitTypes implements ContentList{
|
||||
public static UnitType drone, dagger, interceptor, monsoon, titan, fabricator;
|
||||
public static UnitType drone, alphaDrone, dagger, interceptor, monsoon, titan, fabricator;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
@@ -17,12 +18,29 @@ public class UnitTypes implements ContentList{
|
||||
drag = 0.01f;
|
||||
speed = 0.2f;
|
||||
maxVelocity = 0.8f;
|
||||
ammoCapacity = 0;
|
||||
range = 50f;
|
||||
healSpeed = 0.05f;
|
||||
health = 60;
|
||||
}};
|
||||
|
||||
alphaDrone = new UnitType("alpha-drone", AlphaDrone.class, AlphaDrone::new){
|
||||
{
|
||||
isFlying = true;
|
||||
drag = 0.005f;
|
||||
speed = 0.5f;
|
||||
maxVelocity = 1.6f;
|
||||
range = 40f;
|
||||
health = 15;
|
||||
weapon = Weapons.droneBlaster;
|
||||
trailColor = Color.valueOf("ffd37f");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHidden() {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
dagger = new UnitType("dagger", Dagger.class, Dagger::new){{
|
||||
maxVelocity = 1.1f;
|
||||
speed = 0.2f;
|
||||
@@ -57,7 +75,6 @@ public class UnitTypes implements ContentList{
|
||||
drag = 0.01f;
|
||||
isFlying = true;
|
||||
weapon = Weapons.bomber;
|
||||
ammoCapacity = 50;
|
||||
}};
|
||||
|
||||
fabricator = new UnitType("fabricator", Fabricator.class, Fabricator::new){{
|
||||
@@ -65,7 +82,6 @@ public class UnitTypes implements ContentList{
|
||||
drag = 0.01f;
|
||||
speed = 0.2f;
|
||||
maxVelocity = 0.9f;
|
||||
ammoCapacity = 0;
|
||||
range = 70f;
|
||||
itemCapacity = 70;
|
||||
health = 220;
|
||||
|
||||
@@ -8,7 +8,7 @@ import io.anuke.mindustry.type.ContentList;
|
||||
import io.anuke.mindustry.type.Weapon;
|
||||
|
||||
public class Weapons implements ContentList{
|
||||
public static Weapon blaster, healBlaster, chainBlaster, shockgun, sapper, swarmer, bomber, flakgun, flamethrower, missiles;
|
||||
public static Weapon blaster, droneBlaster, healBlaster, chainBlaster, shockgun, sapper, swarmer, bomber, flakgun, flamethrower, missiles;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
@@ -21,6 +21,15 @@ public class Weapons implements ContentList{
|
||||
ammo = AmmoTypes.bulletMech;
|
||||
}};
|
||||
|
||||
droneBlaster = new Weapon("blaster"){{
|
||||
length = 2f;
|
||||
reload = 40f;
|
||||
width = 1f;
|
||||
roundrobin = true;
|
||||
ejectEffect = ShootFx.shellEjectSmall;
|
||||
ammo = AmmoTypes.bulletCopper;
|
||||
}};
|
||||
|
||||
healBlaster = new Weapon("heal-blaster"){{
|
||||
length = 1.5f;
|
||||
reload = 30f;
|
||||
|
||||
@@ -5,7 +5,6 @@ import io.anuke.mindustry.entities.Predict;
|
||||
import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.entities.traits.CarriableTrait;
|
||||
import io.anuke.mindustry.entities.traits.CarryTrait;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.graphics.Trail;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.type.AmmoType;
|
||||
@@ -154,7 +153,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
||||
|
||||
@Override
|
||||
public void drawOver(){
|
||||
trail.draw(Palette.lightTrail, 5f);
|
||||
trail.draw(type.trailColor, 5f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.entities.units;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
@@ -43,12 +44,12 @@ public class UnitType implements UnlockableContent{
|
||||
public float retreatPercent = 0.2f;
|
||||
public float armor = 0f;
|
||||
public float carryWeight = 1f;
|
||||
public int ammoCapacity = 200;
|
||||
public int itemCapacity = 30;
|
||||
public ObjectSet<Item> toMine = ObjectSet.with(Items.lead, Items.copper);
|
||||
public float buildPower = 0.3f, minePower = 0.7f, healSpeed = 0.1f;
|
||||
public Weapon weapon = Weapons.blaster;
|
||||
public float weaponOffsetX, weaponOffsetY;
|
||||
public Color trailColor = Color.valueOf("ffa665");
|
||||
|
||||
public TextureRegion iconRegion, legRegion, baseRegion, region;
|
||||
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package io.anuke.mindustry.entities.units.types;
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import io.anuke.mindustry.entities.Predict;
|
||||
import io.anuke.mindustry.entities.Unit;
|
||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||
import io.anuke.mindustry.entities.units.FlyingUnit;
|
||||
import io.anuke.mindustry.entities.units.UnitCommand;
|
||||
import io.anuke.mindustry.entities.units.UnitState;
|
||||
import io.anuke.mindustry.type.AmmoType;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import java.io.DataInput;
|
||||
import java.io.DataOutput;
|
||||
import java.io.IOException;
|
||||
|
||||
public class AlphaDrone extends FlyingUnit {
|
||||
static final float followDistance = 80f;
|
||||
|
||||
public Unit leader;
|
||||
public final UnitState attack = new UnitState() {
|
||||
@Override
|
||||
public void update() {
|
||||
if(leader == null || leader.isDead()){
|
||||
damage(99999f);
|
||||
return;
|
||||
}
|
||||
TargetTrait last = target;
|
||||
target = leader;
|
||||
if(last == null){
|
||||
circle(50f);
|
||||
}
|
||||
target = last;
|
||||
if(distanceTo(leader) < followDistance){
|
||||
targetClosest();
|
||||
}else{
|
||||
target = null;
|
||||
}
|
||||
if(target != null){
|
||||
attack(50f);
|
||||
|
||||
if((Mathf.angNear(angleTo(target), rotation, 15f) && distanceTo(target) < getWeapon().getAmmo().getRange())){
|
||||
AmmoType ammo = getWeapon().getAmmo();
|
||||
|
||||
Vector2 to = Predict.intercept(AlphaDrone.this, target, ammo.bullet.speed);
|
||||
getWeapon().update(AlphaDrone.this, to.x, to.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCommand(UnitCommand command){
|
||||
//nuh
|
||||
}
|
||||
|
||||
@Override
|
||||
public void behavior(){
|
||||
//nope
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnitState getStartState() {
|
||||
return attack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSave(DataOutput stream) throws IOException {
|
||||
super.writeSave(stream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSave(DataInput stream) throws IOException {
|
||||
super.readSave(stream);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import io.anuke.ucore.util.Mathf;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Sectors{
|
||||
private static final int sectorImageSize = 16;
|
||||
private static final int sectorImageSize = 32;
|
||||
private static final float sectorLargeChance = 0.23f;
|
||||
|
||||
private GridMap<Sector> grid = new GridMap<>();
|
||||
|
||||
@@ -65,7 +65,7 @@ public class SectorsDialog extends FloatingDialog{
|
||||
|
||||
class SectorView extends Element{
|
||||
float lastX, lastY;
|
||||
float sectorSize = Unit.dp.scl(100f);
|
||||
float sectorSize = Unit.dp.scl(32*4);
|
||||
float sectorPadding = Unit.dp.scl(14f);
|
||||
boolean clicked = false;
|
||||
float panX = -sectorPadding/2f, panY = -sectorSize/2f;
|
||||
|
||||
Reference in New Issue
Block a user