Tau mech implemented

This commit is contained in:
Anuken
2018-08-22 23:29:14 -04:00
parent 8d9ec206bf
commit 30dd089c8b
29 changed files with 744 additions and 545 deletions

View File

@@ -12,6 +12,7 @@ import io.anuke.mindustry.type.ContentList;
public class AmmoTypes implements ContentList{
public static AmmoType bulletCopper, bulletDense, bulletThorium, bulletSilicon, bulletPyratite,
shotgunTungsten, bombExplosive, bombIncendiary, bombOil, shellCarbide, flamerThermite, weaponMissile, weaponMissileSwarm, bulletMech,
healBlaster,
flakLead, flakExplosive, flakPlastic, flakSurge, missileExplosive, missileIncindiary, missileSurge,
artilleryDense, artilleryPlastic, artilleryHoming, artilleryIncindiary, artilleryExplosive,
basicFlame, lancerLaser, lightning, spectreLaser, meltdownLaser, fuseShotgun, oil, water, lava, cryofluid;
@@ -28,6 +29,13 @@ public class AmmoTypes implements ContentList{
inaccuracy = 5f;
}};
healBlaster = new AmmoType(TurretBullets.healBullet){{
shootEffect = ShootFx.shootHeal;
smokeEffect = BulletFx.hitLaser;
reloadMultiplier = 1f;
inaccuracy = 2f;
}};
shotgunTungsten = new AmmoType(WeaponBullets.tungstenShotgun){{
shootEffect = ShootFx.shootBig;
smokeEffect = ShootFx.shootBigSmoke;

View File

@@ -2,18 +2,29 @@ package io.anuke.mindustry.content;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.content.fx.UnitFx;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.Units;
import io.anuke.mindustry.entities.effect.Fire;
import io.anuke.mindustry.game.Content;
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;
import io.anuke.ucore.core.Graphics;
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;
public class Mechs implements ContentList{
public static Mech alpha, delta, tau, omega, dart, javelin, trident, halberd;
@@ -33,34 +44,98 @@ public class Mechs implements ContentList{
maxSpeed = 4f;
}};
delta = new Mech("delta-mech", false){{
drillPower = -1;
speed = 0.75f;
boostSpeed = 0.95f;
itemCapacity = 15;
armor = 30f;
weaponOffsetX = -1;
itemCapacity = 15;
weaponOffsetY = -1;
weapon = Weapons.shockgun;
trailColorTo = Color.valueOf("d3ddff");
maxSpeed = 5f;
}};
delta = new Mech("delta-mech", false){
{
drillPower = -1;
speed = 0.75f;
boostSpeed = 0.95f;
itemCapacity = 15;
armor = 30f;
weaponOffsetX = -1;
itemCapacity = 15;
weaponOffsetY = -1;
weapon = Weapons.shockgun;
trailColorTo = Color.valueOf("d3ddff");
maxSpeed = 5f;
altChargeAlpha = 0.05f;
}
tau = new Mech("tau-mech", false){{
drillPower = 3;
mineSpeed = 3f;
itemCapacity = 70;
speed = 0.44f;
drag = 0.35f;
boostSpeed = 0.8f;
weapon = Weapons.blaster;
maxSpeed = 5f;
armor = 30f;
}};
@Override
public void updateAlt(Player player){
if(player.altHeat > 0.01f){
player.applyEffect(StatusEffects.overdrive, 0.1f);
}
}
@Override
public void draw(Player player){
super.draw(player);
player.hitTime = Math.max(player.hitTime, player.altHeat * Unit.hitDuration);
}
};
tau = new Mech("tau-mech", false){
protected float healRange = 60f;
protected float healAmount = 10f;
protected Rectangle rect = new Rectangle();
{
drillPower = 4;
mineSpeed = 3f;
itemCapacity = 70;
weaponOffsetY = -1;
weaponOffsetX = 1;
speed = 0.44f;
drag = 0.35f;
boostSpeed = 0.8f;
weapon = Weapons.healBlaster;
maxSpeed = 5f;
armor = 30f;
altChargeAlpha = 0.05f;
trailColorTo = Palette.heal;
}
@Override
public void draw(Player player){
super.draw(player);
player.hitTime = Math.max(player.hitTime, player.altHeat * Unit.hitDuration);
}
@Override
public void updateAlt(Player player){
if(player.altHeat >= 0.91f){
Effects.effect(UnitFx.healWave, player);
rect.setSize(healRange*2f).setCenter(player.x, player.y);
Units.getNearby(player.getTeam(), rect, unit -> {
if(unit.distanceTo(player) <= healRange){
if(unit.health < unit.maxHealth()){
Effects.effect(UnitFx.heal, unit);
}
unit.healBy(healAmount);
}
});
int blockRange = (int)(healRange/tilesize);
int px = world.toTile(player.x), py = world.toTile(player.y);
for(int x = -blockRange; x <= blockRange; x++){
for(int y = -blockRange; y <= blockRange; y++){
if(Mathf.dst(x, y) > blockRange) continue;
Tile tile = world.tile(px + x, py + y);
if(tile != null){
Fire.extinguish(tile, 1000f);
}
}
}
player.altHeat = 0f;
}
}
};
omega = new Mech("omega-mech", false){
protected TextureRegion armorRegion;
{
drillPower = 2;
mineSpeed = 1.5f;
@@ -76,6 +151,11 @@ public class Mechs implements ContentList{
armor = 50f;
}
@Override
public float getRotationAlpha(Player player){
return 0.6f - player.altHeat * 0.3f;
}
@Override
public float spreadX(Player player){
return player.altHeat*2f;

View File

@@ -129,6 +129,7 @@ public class Recipes implements ContentList{
new Recipe(units, UpgradeBlocks.javelinFactory, new ItemStack(Items.lead, 200), new ItemStack(Items.silicon, 250), new ItemStack(Items.titanium, 300), new ItemStack(Items.plastanium, 200));
new Recipe(units, UpgradeBlocks.deltaFactory, new ItemStack(Items.densealloy, 160), new ItemStack(Items.silicon, 220), new ItemStack(Items.titanium, 250)).setDesktop();
new Recipe(units, UpgradeBlocks.omegaFactory, new ItemStack(Items.densealloy, 160), new ItemStack(Items.silicon, 220), new ItemStack(Items.titanium, 250)).setDesktop();
new Recipe(units, UpgradeBlocks.tauFactory, new ItemStack(Items.densealloy, 160), new ItemStack(Items.silicon, 220), new ItemStack(Items.titanium, 250)).setDesktop();
//new Recipe(units, UpgradeBlocks.deltaFactory, new ItemStack(Items.copper, 30), new ItemStack(Items.lead, 50), new ItemStack(Items.silicon, 30));

View File

@@ -45,6 +45,7 @@ public class UnitTypes implements ContentList{
speed = 0.3f;
maxVelocity = 1.9f;
drag = 0.01f;
weapon = Weapons.chainBlaster;
isFlying = true;
}};

View File

@@ -9,7 +9,7 @@ import io.anuke.mindustry.type.Upgrade;
import io.anuke.mindustry.type.Weapon;
public class Weapons implements ContentList{
public static Weapon blaster, chainBlaster, shockgun, sapper, swarmer, bomber, flakgun, flamethrower, missiles;
public static Weapon blaster, healBlaster, chainBlaster, shockgun, sapper, swarmer, bomber, flakgun, flamethrower, missiles;
@Override
public void load(){
@@ -22,6 +22,15 @@ public class Weapons implements ContentList{
ammo = AmmoTypes.bulletMech;
}};
healBlaster = new Weapon("heal-blaster"){{
length = 1.5f;
reload = 30f;
roundrobin = false;
ejectEffect = Fx.none;
recoil = 2f;
ammo = AmmoTypes.healBlaster;
}};
missiles = new Weapon("missiles"){{
length = 1.5f;
reload = 40f;

View File

@@ -30,11 +30,41 @@ import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.world;
public class TurretBullets extends BulletList implements ContentList{
public static BulletType fireball, basicFlame, lancerLaser, fuseShot, waterShot, cryoShot, lavaShot, oilShot, lightning, driverBolt;
public static BulletType fireball, basicFlame, lancerLaser, fuseShot, waterShot, cryoShot, lavaShot, oilShot, lightning, driverBolt, healBullet;
@Override
public void load(){
healBullet = new BulletType(5.2f, 25){
float healAmount = 14f;
{
hiteffect = BulletFx.hitLaser;
despawneffect = BulletFx.hitLaser;
collidesTeam = true;
}
@Override
public void draw(Bullet b){
Draw.color(Palette.heal);
Lines.stroke(2f);
Lines.lineAngleCenter(b.x, b.y, b.angle(), 7f);
Draw.color(Color.WHITE);
Lines.lineAngleCenter(b.x, b.y, b.angle(), 3f);
Draw.reset();
}
@Override
public void hitTile(Bullet b, Tile tile){
super.hit(b);
if(tile.getTeam() == b.getTeam()){
Effects.effect(BlockFx.healBlock, tile.drawx(), tile.drawy(), tile.block().size);
tile.entity.health += healAmount;
tile.entity.health = Mathf.clamp(tile.entity.health, 0, tile.block().health);
}
}
};
fireball = new BulletType(1f, 4){
{
pierce = true;

View File

@@ -19,7 +19,7 @@ public class BlockFx extends FxList implements ContentList{
public static Effect reactorsmoke, nuclearsmoke, nuclearcloud, redgeneratespark, generatespark, fuelburn, plasticburn,
pulverize, pulverizeRed, pulverizeRedder, pulverizeSmall, pulverizeMedium, producesmoke, smeltsmoke, formsmoke, blastsmoke,
lava, dooropen, doorclose, dooropenlarge, doorcloselarge, purify, purifyoil, purifystone, generate, mine, mineBig, mineHuge,
smelt, teleportActivate, teleport, teleportOut, ripple, bubble, commandSend;
smelt, teleportActivate, teleport, teleportOut, ripple, bubble, commandSend, healBlock;
@Override
public void load(){
@@ -284,5 +284,12 @@ public class BlockFx extends FxList implements ContentList{
Lines.poly(e.x, e.y, 40, 4f + e.finpow() * 120f);
Draw.color();
});
healBlock = new Effect(20, e -> {
Draw.color(Palette.heal);
Lines.stroke(2f * e.fout() + 0.5f);
Lines.square(e.x, e.y, 1f + (e.fin() * e.rotation * tilesize/2f-1f));
Draw.color();
});
}
}

View File

@@ -11,7 +11,7 @@ import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
public class BulletFx extends FxList implements ContentList{
public static Effect hitBulletSmall, hitBulletBig, hitFlameSmall, hitLiquid, hitLancer, despawn, flakExplosion, blastExplosion, plasticExplosion,
public static Effect hitBulletSmall, hitBulletBig, hitFlameSmall, hitLiquid, hitLaser, hitLancer, despawn, flakExplosion, blastExplosion, plasticExplosion,
artilleryTrail, incendTrail, missileTrail;
@Override
@@ -82,6 +82,13 @@ public class BulletFx extends FxList implements ContentList{
Draw.reset();
});
hitLaser = new Effect(8, e -> {
Draw.color(Color.WHITE, Palette.heal, e.fin());
Lines.stroke(0.5f + e.fout());
Lines.circle(e.x, e.y, e.fin()*5f);
Draw.reset();
});
despawn = new Effect(12, e -> {
Draw.color(Palette.lighterOrange, Color.GRAY, e.fin());
Lines.stroke(e.fout());

View File

@@ -13,7 +13,7 @@ import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
public class ShootFx extends FxList implements ContentList{
public static Effect shootSmall, shootSmallSmoke, shootBig, shootBig2, shootBigSmoke, shootBigSmoke2, shootSmallFlame, shootLiquid, shellEjectSmall, shellEjectMedium, shellEjectBig, lancerLaserShoot, lancerLaserShootSmoke, lancerLaserCharge, lancerLaserChargeBegin, lightningCharge, lightningShoot;
public static Effect shootSmall, shootHeal, shootSmallSmoke, shootBig, shootBig2, shootBigSmoke, shootBigSmoke2, shootSmallFlame, shootLiquid, shellEjectSmall, shellEjectMedium, shellEjectBig, lancerLaserShoot, lancerLaserShootSmoke, lancerLaserCharge, lancerLaserChargeBegin, lightningCharge, lightningShoot;
@Override
public void load(){
@@ -26,6 +26,14 @@ public class ShootFx extends FxList implements ContentList{
Draw.reset();
});
shootHeal = new Effect(8, e -> {
Draw.color(Palette.heal);
float w = 1f + 5 * e.fout();
Shapes.tri(e.x, e.y, w, 17f * e.fout(), e.rotation);
Shapes.tri(e.x, e.y, w, 4f * e.fout(), e.rotation + 180f);
Draw.reset();
});
shootSmallSmoke = new Effect(20f, e -> {
Draw.color(Palette.lighterOrange, Color.LIGHT_GRAY, Color.GRAY, e.fin());

View File

@@ -11,7 +11,7 @@ import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
public class UnitFx extends FxList implements ContentList{
public static Effect vtolHover, unitDrop, unitPickup, unitLand, pickup;
public static Effect vtolHover, unitDrop, unitPickup, unitLand, pickup, healWave, heal;
@Override
public void load(){
@@ -53,5 +53,19 @@ public class UnitFx extends FxList implements ContentList{
Lines.spikes(e.x, e.y, 1f + e.fin() * 6f, e.fout() * 4f, 6);
Draw.reset();
});
healWave = new Effect(22, e -> {
Draw.color(Palette.heal);
Lines.stroke(e.fout() * 2f);
Lines.poly(e.x, e.y, 30, 4f + e.finpow() * 60f);
Draw.color();
});
heal = new Effect(11, e -> {
Draw.color(Palette.heal);
Lines.stroke(e.fout() * 2f);
Lines.poly(e.x, e.y, 10, 2f + e.finpow() * 7f);
Draw.color();
});
}
}

View File

@@ -21,10 +21,7 @@ import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockFlag;
import io.anuke.ucore.core.Core;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.core.Settings;
import io.anuke.ucore.core.*;
import io.anuke.ucore.entities.EntityDraw;
import io.anuke.ucore.entities.EntityGroup;
import io.anuke.ucore.entities.impl.EffectEntity;
@@ -253,11 +250,14 @@ public class Renderer extends RendererModule{
blocks.drawBlocks(Layer.overlay);
if(itemGroup.size() > 0){
Shaders.outline.color.set(Team.none.color);
Graphics.beginShaders(Shaders.outline);
Graphics.surface(effectSurface);
drawAndInterpolate(itemGroup);
Graphics.endShaders();
Graphics.surface();
Draw.color(0, 0, 0, 0.2f);
Draw.rect(effectSurface, -1, -1);
Draw.color();
Draw.rect(effectSurface, 0, 0);
}
drawAllTeams(false);

View File

@@ -45,6 +45,7 @@ import static io.anuke.mindustry.Vars.*;
public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTrait{
public static final int timerSync = 2;
public static final int timerAbility = 3;
private static final int timerShootLeft = 0;
private static final int timerShootRight = 1;
private static final float liftoffBoost = 0.2f;
@@ -581,13 +582,14 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
}
if(!ui.chatfrag.chatOpen()){
float baseLerp = mech.getRotationAlpha(this);
if(!isShooting()){
if(!movement.isZero()){
rotation = Mathf.slerpDelta(rotation, movement.angle(), 0.13f);
rotation = Mathf.slerpDelta(rotation, movement.angle(), 0.13f * baseLerp);
}
}else{
float angle = control.input(playerIndex).mouseAngle(x, y);
this.rotation = Mathf.slerpDelta(this.rotation, angle, 0.1f);
this.rotation = Mathf.slerpDelta(this.rotation, angle, 0.1f * baseLerp);
}
}
}

View File

@@ -45,6 +45,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
public UnitInventory inventory = new UnitInventory(this);
public float rotation;
public float hitTime;
protected Interpolator interpolator = new Interpolator();
protected StatusController status = new StatusController();
@@ -52,7 +53,6 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
protected CarryTrait carrier;
protected Vector2 velocity = new Translator(0f, 0.0001f);
protected float hitTime;
protected float drownTime;
@Override

View File

@@ -184,11 +184,13 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
if(tile == null) return false;
tile = tile.target();
if(tile.entity != null && tile.entity.collide(this) && !tile.entity.isDead() && tile.entity.tile.getTeam() != team){
tile.entity.collision(this);
if(tile.entity != null && tile.entity.collide(this) && !tile.entity.isDead() && (type.collidesTeam || tile.entity.tile.getTeam() != team)){
if(tile.entity.getTeam() != team){
tile.entity.collision(this);
}
if(!supressCollision){
type.hit(this);
type.hitTile(this, tile);
remove();
}

View File

@@ -5,6 +5,7 @@ import io.anuke.mindustry.content.StatusEffects;
import io.anuke.mindustry.content.fx.BulletFx;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.type.StatusEffect;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.entities.impl.BaseBulletType;
@@ -27,6 +28,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 type collides with tiles that are of the same team.*/
public boolean collidesTeam = false;
/**Whether this bullet types collides with anything at all.*/
public boolean collides = true;
/**Whether velocity is inherited from the shooter.*/
@@ -51,6 +54,10 @@ public abstract class BulletType extends BaseBulletType<Bullet> implements Conte
return types;
}
public void hitTile(Bullet b, Tile tile){
hit(b);
}
@Override
public void hit(Bullet b, float hitx, float hity){
Effects.effect(hiteffect, hitx, hity, b.angle());

View File

@@ -149,8 +149,8 @@ public class ItemDrop extends SolidEntity implements SaveTrait, SyncTrait, DrawT
int stored = Mathf.clamp(amount / 6, 1, 8);
for(int i = 0; i < stored; i++){
float px = stored == 1 ? 0 : Mathf.randomSeedRange(i + 1, 4f);
float py = stored == 1 ? 0 : Mathf.randomSeedRange(i + 2, 4f);
float px = stored == 1 ? 0 : (int)Mathf.randomSeedRange(i + 1, 4f);
float py = stored == 1 ? 0 : (int)Mathf.randomSeedRange(i + 2, 4f);
Draw.rect(item.region, x + px, y + py, size, size);
}

View File

@@ -42,6 +42,8 @@ public class Palette{
powerLaserFrom = Color.valueOf("e3e3e3"),
powerLaserTo = Color.valueOf("ffe7a8"),
heal = Color.valueOf("98ffa9"),
description = Color.WHITE,
turretinfo = Color.ORANGE,
iteminfo = Color.LIGHT_GRAY,

View File

@@ -53,6 +53,8 @@ public class Mech extends Upgrade implements UnlockableContent{
return 0f;
}
public float getRotationAlpha(Player player){return 1f;}
@Override
public void displayInfo(Table table){
ContentDisplay.displayMech(table, this);

View File

@@ -19,8 +19,10 @@ import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.util.Geometry;
import io.anuke.ucore.util.Mathf;
import java.io.DataInputStream;
@@ -81,6 +83,16 @@ public class MechFactory extends Block{
Math.abs(player.y - tile.drawy()) <= tile.block().size * tilesize / 2f && entity.player == null;
}
@Override
public void drawSelect(Tile tile){
Draw.color(Palette.accent);
for(int i = 0; i < 4; i ++){
float length = tilesize * size/2f + 3 + Mathf.absin(Timers.time(), 5f, 2f);
Draw.rect("transfer-arrow", tile.drawx() + Geometry.d4[i].x * length, tile.drawy() + Geometry.d4[i].y * length, (i+2) * 90);
}
Draw.color();
}
@Override
public boolean isSolidFor(Tile tile){
MechFactoryEntity entity = tile.entity();