Save fixes / Implemented overdrive projector

This commit is contained in:
Anuken
2018-09-06 21:46:50 -04:00
parent 1960b59629
commit 7b63eac3eb
10 changed files with 76 additions and 37 deletions

View File

@@ -121,10 +121,10 @@ public class StatusEffects implements ContentList{
}
};
overdrive = new StatusEffect(6f){
overdrive = new StatusEffect(60f*15){
{
armorMultiplier = 0.95f;
speedMultiplier = 1.05f;
speedMultiplier = 1.15f;
damageMultiplier = 1.4f;
}
@@ -132,6 +132,10 @@ public class StatusEffects implements ContentList{
public void update(Unit unit, float time){
//idle regen boosted
unit.health += 0.01f * Timers.delta();
if(Mathf.chance(Timers.delta() * 0.25f)){
Effects.effect(EnvironmentFx.overdriven, unit.x + Mathf.range(unit.getSize() / 2f), unit.y + Mathf.range(unit.getSize() / 2f), 0f, unit);
}
}
};

View File

@@ -8,7 +8,7 @@ import io.anuke.mindustry.world.blocks.defense.*;
public class DefenseBlocks extends BlockList implements ContentList{
public static Block copperWall, copperWallLarge, compositeWall, compositeWallLarge, thoriumWall, thoriumWallLarge, door, doorLarge,
phaseWall, phaseWallLarge, surgeWall, surgeWallLarge, mendProjector, overdriveProjector, shockMine;
phaseWall, phaseWallLarge, surgeWall, surgeWallLarge, mendProjector, overdriveProjector, forceProjector, shockMine;
@Override
public void load(){
@@ -82,6 +82,12 @@ public class DefenseBlocks extends BlockList implements ContentList{
consumes.item(Items.phasematter).optional(true);
}};
forceProjector = new ForceProjector("force-projector"){{
consumes.power(0.25f);
size = 3;
consumes.item(Items.phasematter).optional(true);
}};
shockMine = new ShockMine("shock-mine"){{
health = 40;
damage = 11;

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, healBlock, healBlockFull;
smelt, teleportActivate, teleport, teleportOut, ripple, bubble, commandSend, healBlock, healBlockFull, healWaveMend, overdriveWave;
@Override
public void load(){
@@ -285,6 +285,20 @@ public class BlockFx extends FxList implements ContentList{
Draw.color();
});
healWaveMend = new Effect(40, e -> {
Draw.color(e.color);
Lines.stroke(e.fout() * 2f);
Lines.poly(e.x, e.y, 30, e.finpow() * e.rotation);
Draw.color();
});
overdriveWave = new Effect(50, e -> {
Draw.color(e.color);
Lines.stroke(e.fout() * 1f);
Lines.poly(e.x, e.y, 30, e.finpow() * e.rotation);
Draw.color();
});
healBlock = new Effect(20, e -> {
Draw.color(Palette.heal);
Lines.stroke(2f * e.fout() + 0.5f);

View File

@@ -11,7 +11,7 @@ import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
public class EnvironmentFx extends FxList implements ContentList{
public static Effect burning, fire, smoke, steam, fireballsmoke, ballfire, freezing, melting, wet, oily;
public static Effect burning, fire, smoke, steam, fireballsmoke, ballfire, freezing, melting, wet, oily, overdriven;
@Override
public void load(){
@@ -115,5 +115,15 @@ public class EnvironmentFx extends FxList implements ContentList{
Draw.color();
});
overdriven = new Effect(20f, e -> {
Draw.color(Palette.accent);
Angles.randLenVectors(e.id, 2, 1f + e.fin() * 2f, (x, y) -> {
Fill.square(e.x + x, e.y + y, e.fout() * 2.3f+0.5f);
});
Draw.color();
});
}
}

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, healWave, healWaveMend, heal;
public static Effect vtolHover, unitDrop, unitPickup, unitLand, pickup, healWave, heal;
@Override
public void load(){
@@ -61,13 +61,6 @@ public class UnitFx extends FxList implements ContentList{
Draw.color();
});
healWaveMend = new Effect(40, e -> {
Draw.color(e.color);
Lines.stroke(e.fout() * 2f);
Lines.poly(e.x, e.y, 30, e.finpow() * e.rotation);
Draw.color();
});
heal = new Effect(11, e -> {
Draw.color(Palette.heal);
Lines.stroke(e.fout() * 2f);

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry.entities;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.content.StatusEffects;
import io.anuke.mindustry.entities.traits.Saveable;
@@ -8,10 +9,12 @@ import io.anuke.mindustry.type.StatusEffect;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Pooling;
import io.anuke.ucore.util.ThreadArray;
import io.anuke.ucore.util.Tmp;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import static io.anuke.mindustry.Vars.content;
/**
* Class for controlling status effects on an entity.
@@ -59,6 +62,20 @@ public class StatusController implements Saveable{
statuses.add(entry);
}
public Color getStatusColor(){
if(statuses.size == 0){
return Tmp.c1.set(Color.WHITE);
}
float r = 0f, g = 0f, b = 0f;
for(StatusEntry entry : statuses){
r += entry.effect.color.r;
g += entry.effect.color.g;
b += entry.effect.color.b;
}
return Tmp.c1.set(r / statuses.size, g / statuses.size, b / statuses.size, 1f);
}
public void clear(){
statuses.clear();
}

View File

@@ -35,16 +35,16 @@ public abstract class SaveFileVersion{
byte mapped = stream.readByte();
MappableContent[][] map = new MappableContent[mapped][0];
MappableContent[][] map = new MappableContent[ContentType.values().length][0];
for (int i = 0; i < mapped; i++) {
ContentType type = ContentType.values()[stream.readByte()];
short total = stream.readShort();
map[i] = new MappableContent[total];
map[type.ordinal()] = new MappableContent[total];
for (int j = 0; j < total; j++) {
String name = stream.readUTF();
map[i][j] = content.getByName(type, name);
map[type.ordinal()][j] = content.getByName(type, name);
}
}

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry.type;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.utils.ObjectSet;
import io.anuke.mindustry.entities.StatusController.StatusEntry;
import io.anuke.mindustry.entities.Unit;
@@ -12,6 +13,7 @@ public class StatusEffect extends Content{
public float damageMultiplier = 1f; //damage dealt
public float armorMultiplier = 1f; //armor points
public float speedMultiplier = 1f; //speed
public Color color = Color.WHITE.cpy(); //tint color
/**Set of 'opposite' effects, which will decrease the duration of this effect when applied.*/
protected ObjectSet<StatusEffect> opposites = new ObjectSet<>();
@@ -44,9 +46,7 @@ public class StatusEffect extends Content{
return result.set(to, newTime);
}
/**
* Called when this effect transitions to a new status effect.
*/
/**Called when this effect transitions to a new status effect.*/
public void onTransition(Unit unit, StatusEffect to){
}

View File

@@ -5,7 +5,6 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.IntSet;
import io.anuke.mindustry.content.fx.BlockFx;
import io.anuke.mindustry.content.fx.UnitFx;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
@@ -64,7 +63,7 @@ public class MendProjector extends Block{
if(entity.charge >= reload){
float realRange = range + entity.phaseHeat * 20f;
Effects.effect(UnitFx.healWaveMend, Hue.mix(color, phase, entity.phaseHeat), tile.drawx(), tile.drawy(), realRange);
Effects.effect(BlockFx.healWaveMend, Hue.mix(color, phase, entity.phaseHeat), tile.drawx(), tile.drawy(), realRange);
entity.charge = 0f;
Timers.run(10f, () -> {

View File

@@ -3,16 +3,13 @@ package io.anuke.mindustry.world.blocks.defense;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import io.anuke.mindustry.content.StatusEffects;
import io.anuke.mindustry.content.fx.BlockFx;
import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.entities.Units;
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.Hue;
import io.anuke.ucore.graphics.Lines;
import io.anuke.ucore.util.Mathf;
@@ -21,12 +18,12 @@ public class OverdriveProjector extends Block{
private static Color phase = Color.valueOf("ffd59e");
protected int timerUse = timers ++;
protected int timerApply = timers ++;
protected TextureRegion topRegion;
protected float reload = 250f;
protected float range = 50f;
protected float healPercent = 6f;
protected float phaseBoost = 10f;
protected float reload = 60f;
protected float range = 100f;
protected float phaseBoost = 30f;
protected float useTime = 300f;
public OverdriveProjector(String name){
@@ -47,28 +44,28 @@ public class OverdriveProjector extends Block{
@Override
public void update(Tile tile){
OverdriveEntity entity = tile.entity();
entity.heat = Mathf.lerpDelta(entity.heat, entity.cons.valid() ? 1f : 0f, 0.08f);
entity.charge += entity.heat * Timers.delta();
entity.heat = Mathf.lerpDelta(entity.heat, entity.cons.valid() ? 1f : 0f, 0.08f);
entity.phaseHeat = Mathf.lerpDelta(entity.phaseHeat, (float)entity.items.get(consumes.item()) / itemCapacity, 0.1f);
if(entity.timer.get(timerUse, useTime) && entity.items.total() > 0){
entity.items.remove(consumes.item(), 1);
}
if(entity.charge >= reload){
float realRange = range + entity.phaseHeat * 20f;
if(entity.heat > 0.5f && entity.timer.get(timerApply, 10)){
float realRange = range + entity.phaseHeat * phaseBoost;
Effects.effect(BlockFx.commandSend, Hue.mix(color, phase, entity.phaseHeat), tile.drawx(), tile.drawy(), realRange);
Units.getNearby(tile.getTeam(), tile.drawx(), tile.drawy(), realRange, unit -> unit.applyEffect(StatusEffects.overdrive, 1f));
entity.charge = 0f;
Units.getNearby(tile.getTeam(), tile.drawx(), tile.drawy(), realRange, unit -> unit.applyEffect(StatusEffects.overdrive, 1f + entity.phaseHeat));
}
}
@Override
public void drawSelect(Tile tile){
OverdriveEntity entity = tile.entity();
float realRange = range + entity.phaseHeat * phaseBoost;
Draw.color(color);
Lines.dashCircle(tile.drawx(), tile.drawy() - 1f, range);
Lines.poly(tile.drawx(), tile.drawy(), 300, realRange);
Draw.color();
}
@@ -99,7 +96,6 @@ public class OverdriveProjector extends Block{
class OverdriveEntity extends TileEntity{
float heat;
float charge;
float phaseHeat;
}
}