Added new wave spawning system

This commit is contained in:
Anuken
2018-06-27 10:56:39 -04:00
parent c89123b18a
commit e799187aaf
19 changed files with 260 additions and 160 deletions

View File

@@ -169,7 +169,8 @@ public class Damage {
private static float calculateDamage(float x, float y, float tx, float ty, float radius, float damage){
float dist = Vector2.dst(x, y, tx, ty);
float scaled = 1f - dist/radius;
float falloff = 0.4f;
float scaled = Mathf.lerp(1f - dist/radius, 1f, falloff);
return damage * scaled;
}
}

View File

@@ -228,6 +228,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
float explosiveness = 2f + (player.inventory.hasItem() ? player.inventory.getItem().item.explosiveness * player.inventory.getItem().amount : 0f);
float flammability = (player.inventory.hasItem() ? player.inventory.getItem().item.flammability * player.inventory.getItem().amount : 0f);
Damage.dynamicExplosion(player.x, player.y, flammability, explosiveness, 0f, player.getSize()/2f, Palette.darkFlame);
ScorchDecal.create(player.x, player.y);
Effects.sound("die", player);
player.onDeath();
@@ -471,7 +472,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
if(ui.chatfrag.chatOpen()) return;
float speed = isBoosting && !mech.flying ? mech.boostSpeed : mech.speed;
float speed = isBoosting && !mech.flying ? debug ? 5f : mech.boostSpeed : mech.speed;
//fraction of speed when at max load
float carrySlowdown = 0.7f;

View File

@@ -6,6 +6,7 @@ import io.anuke.annotations.Annotations.Loc;
import io.anuke.annotations.Annotations.Remote;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.content.fx.ExplosionFx;
import io.anuke.mindustry.entities.Damage;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.entities.Units;
@@ -15,9 +16,11 @@ import io.anuke.mindustry.entities.traits.TargetTrait;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.game.TeamInfo.TeamData;
import io.anuke.mindustry.gen.CallEntity;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.net.In;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.Item;
import io.anuke.mindustry.type.ItemStack;
import io.anuke.mindustry.type.Weapon;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.units.UnitFactory.UnitFactoryEntity;
@@ -25,9 +28,8 @@ import io.anuke.mindustry.world.meta.BlockFlag;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.EntityGroup;
import io.anuke.ucore.util.Geometry;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Timer;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.util.*;
import java.io.DataInput;
import java.io.DataOutput;
@@ -149,6 +151,23 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
return null;
}
protected void drawItems(){
float backTrns = 4f, itemSize = 5f;
if(inventory.hasItem()){
ItemStack stack = inventory.getItem();
int stored = Mathf.clamp(stack.amount / 6, 1, 8);
for(int i = 0; i < stored; i ++) {
float angT = i == 0 ? 0 : Mathf.randomSeedRange(i + 2, 60f);
float lenT = i == 0 ? 0 : Mathf.randomSeedRange(i + 3, 1f) - 1f;
Draw.rect(stack.item.region,
x + Angles.trnsx(rotation + 180f + angT, backTrns + lenT),
y + Angles.trnsy(rotation + 180f + angT, backTrns + lenT),
itemSize, itemSize, rotation);
}
}
}
@Override
public Timer getTimer() {
return timer;
@@ -354,9 +373,14 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
public static void onUnitDeath(BaseUnit unit){
if(unit == null) return;
unit.onSuperDeath();
UnitDrops.dropItems(unit);
float explosiveness = 2f + (unit.inventory.hasItem() ? unit.inventory.getItem().item.explosiveness * unit.inventory.getItem().amount : 0f);
float flammability = (unit.inventory.hasItem() ? unit.inventory.getItem().item.flammability * unit.inventory.getItem().amount : 0f);
Damage.dynamicExplosion(unit.x, unit.y, flammability, explosiveness, 0f, unit.getSize()/2f, Palette.darkFlame);
unit.onSuperDeath();
ScorchDecal.create(unit.x, unit.y);
Effects.effect(ExplosionFx.explosion, unit);
Effects.shake(2f, 2f, unit);

View File

@@ -9,7 +9,6 @@ import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.graphics.Trail;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.AmmoType;
import io.anuke.mindustry.type.ItemStack;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockFlag;
import io.anuke.ucore.core.Timers;
@@ -66,20 +65,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
Draw.rect(type.name, x, y, rotation - 90);
float backTrns = 4f, itemSize = 5f;
if(inventory.hasItem()){
ItemStack stack = inventory.getItem();
int stored = Mathf.clamp(stack.amount / 6, 1, 8);
for(int i = 0; i < stored; i ++) {
float angT = i == 0 ? 0 : Mathf.randomSeedRange(i + 2, 60f);
float lenT = i == 0 ? 0 : Mathf.randomSeedRange(i + 3, 1f) - 1f;
Draw.rect(stack.item.region,
x + Angles.trnsx(rotation + 180f + angT, backTrns + lenT),
y + Angles.trnsy(rotation + 180f + angT, backTrns + lenT),
itemSize, itemSize, rotation);
}
}
drawItems();
Draw.alpha(1f);
}

View File

@@ -28,9 +28,6 @@ import static io.anuke.mindustry.Vars.world;
public abstract class GroundUnit extends BaseUnit {
protected static Translator vec = new Translator();
protected static float maxAim = 30f;
protected static final int timerReloadAlt = timerIndex++;
protected float walkTime;
protected float baseRotation;
@@ -53,7 +50,9 @@ public abstract class GroundUnit extends BaseUnit {
@Override
public void move(float x, float y){
baseRotation = Mathf.slerpDelta(baseRotation, Mathf.atan2(x, y), type.baseRotateSpeed);
if(Mathf.dst(x, y) > 0.01f){
baseRotation = Mathf.slerpDelta(baseRotation, Mathf.atan2(x, y), type.baseRotateSpeed);
}
super.move(x, y);
}
@@ -66,7 +65,7 @@ public abstract class GroundUnit extends BaseUnit {
public void update() {
super.update();
if(!velocity.isZero(0.001f) && (target == null || !inventory.hasAmmo() || (inventory.hasAmmo() && distanceTo(target) > inventory.getAmmoRange()))){
if(!velocity.isZero(0.0001f) && (target == null || !inventory.hasAmmo() || (inventory.hasAmmo() && distanceTo(target) > inventory.getAmmoRange()))){
rotation = Mathf.slerpDelta(rotation, velocity.angle(), 0.2f);
}
}
@@ -115,6 +114,8 @@ public abstract class GroundUnit extends BaseUnit {
y + Angles.trnsy(tra, type.weaponOffsetX * i, trY), w, 12, rotation - 90);
}
drawItems();
Draw.alpha(1f);
}