Added shield effects
This commit is contained in:
@@ -80,8 +80,8 @@ public class Vars implements Loadable{
|
|||||||
public static final float miningRange = 70f;
|
public static final float miningRange = 70f;
|
||||||
/** range for building */
|
/** range for building */
|
||||||
public static final float buildingRange = 220f;
|
public static final float buildingRange = 220f;
|
||||||
/** ticks spent out of bound until self destruct. */
|
/** duration of one turn. */
|
||||||
public static final float boundsCountdown = 60 * 7;
|
public static final float turnDuration = 5 * Time.toMinutes;
|
||||||
/** for map generator dialog */
|
/** for map generator dialog */
|
||||||
public static boolean updateEditorOnChange = false;
|
public static boolean updateEditorOnChange = false;
|
||||||
/** size of tiles in units */
|
/** size of tiles in units */
|
||||||
|
|||||||
@@ -1189,6 +1189,23 @@ public class Fx{
|
|||||||
Lines.poly(e.x, e.y, 6, e.rotation + e.fin(), 90);
|
Lines.poly(e.x, e.y, 6, e.rotation + e.fin(), 90);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
unitShieldBreak = new Effect(35, e -> {
|
||||||
|
if(!(e.data instanceof Unitc)) return;
|
||||||
|
|
||||||
|
Unitc unit = e.data();
|
||||||
|
|
||||||
|
float radius = unit.hitSize() * 1.3f;
|
||||||
|
color(Pal.shield, e.fout());
|
||||||
|
|
||||||
|
randLenVectors(e.id, (int)(radius * 0.7f), radius, radius * e.finpow(), (x, y) -> {
|
||||||
|
Fill.poly(e.x + x, e.y + y, 3, e.fout() * 3f, Angles.angle(x, y));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
stroke(1f * e.fout());
|
||||||
|
Lines.circle(e.x, e.y, radius);
|
||||||
|
}),
|
||||||
|
|
||||||
coreLand = new Effect(120f, e -> {
|
coreLand = new Effect(120f, e -> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ public class UnitTypes implements ContentList{
|
|||||||
health = 400;
|
health = 400;
|
||||||
buildSpeed = 0.4f;
|
buildSpeed = 0.4f;
|
||||||
engineOffset = 6.5f;
|
engineOffset = 6.5f;
|
||||||
hitsize = 7f;
|
hitsize = 8f;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,21 +1,31 @@
|
|||||||
package mindustry.entities.def;
|
package mindustry.entities.def;
|
||||||
|
|
||||||
|
import arc.util.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
|
import mindustry.content.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
abstract class ShieldComp implements Healthc{
|
abstract class ShieldComp implements Healthc, Posc{
|
||||||
@Import float health, hitTime;
|
@Import float health, hitTime;
|
||||||
@Import boolean dead;
|
@Import boolean dead;
|
||||||
|
|
||||||
/** Absorbs health damage. */
|
/** Absorbs health damage. */
|
||||||
float shield;
|
float shield;
|
||||||
|
/** Shield opacity. */
|
||||||
|
transient float shieldAlpha = 0f;
|
||||||
|
|
||||||
@Replace
|
@Replace
|
||||||
@Override
|
@Override
|
||||||
public void damage(float amount){
|
public void damage(float amount){
|
||||||
hitTime = 1f;
|
hitTime = 1f;
|
||||||
|
|
||||||
|
boolean hadShields = shield > 0.0001f;
|
||||||
|
|
||||||
|
if(hadShields){
|
||||||
|
shieldAlpha = 1f;
|
||||||
|
}
|
||||||
|
|
||||||
float shieldDamage = Math.min(shield, amount);
|
float shieldDamage = Math.min(shield, amount);
|
||||||
shield -= shieldDamage;
|
shield -= shieldDamage;
|
||||||
amount -= shieldDamage;
|
amount -= shieldDamage;
|
||||||
@@ -25,6 +35,16 @@ abstract class ShieldComp implements Healthc{
|
|||||||
if(health <= 0 && !dead){
|
if(health <= 0 && !dead){
|
||||||
kill();
|
kill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(hadShields && shield <= 0.0001f){
|
||||||
|
Fx.unitShieldBreak.at(x(), y(), 0, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(){
|
||||||
|
shieldAlpha -= Time.delta() / 12f;
|
||||||
|
if(shieldAlpha < 0) shieldAlpha = 0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import static mindustry.Vars.*;
|
|||||||
public class GlobalData{
|
public class GlobalData{
|
||||||
private ObjectMap<ContentType, ObjectSet<String>> unlocked = new ObjectMap<>();
|
private ObjectMap<ContentType, ObjectSet<String>> unlocked = new ObjectMap<>();
|
||||||
private ObjectIntMap<Item> items = new ObjectIntMap<>();
|
private ObjectIntMap<Item> items = new ObjectIntMap<>();
|
||||||
private Array<Satellite> satellites = new Array<>();
|
|
||||||
private boolean modified;
|
private boolean modified;
|
||||||
|
|
||||||
public GlobalData(){
|
public GlobalData(){
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
package mindustry.game;
|
|
||||||
|
|
||||||
public class Turns{
|
|
||||||
}
|
|
||||||
@@ -6,12 +6,14 @@ import arc.util.*;
|
|||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
|
|
||||||
import static mindustry.Vars.state;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
/** Updates the campaign universe. Has no relevance to other gamemodes. */
|
/** Updates the campaign universe. Has no relevance to other gamemodes. */
|
||||||
public class Universe{
|
public class Universe{
|
||||||
private long seconds;
|
private long seconds;
|
||||||
private float secondCounter;
|
private float secondCounter;
|
||||||
|
private int turn;
|
||||||
|
private float turnCounter;
|
||||||
|
|
||||||
public Universe(){
|
public Universe(){
|
||||||
load();
|
load();
|
||||||
@@ -35,6 +37,7 @@ public class Universe{
|
|||||||
|
|
||||||
public void update(){
|
public void update(){
|
||||||
secondCounter += Time.delta() / 60f;
|
secondCounter += Time.delta() / 60f;
|
||||||
|
|
||||||
if(secondCounter >= 1){
|
if(secondCounter >= 1){
|
||||||
seconds += (int)secondCounter;
|
seconds += (int)secondCounter;
|
||||||
secondCounter %= 1f;
|
secondCounter %= 1f;
|
||||||
@@ -45,6 +48,15 @@ public class Universe{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//update turn state - happens only in-game
|
||||||
|
turnCounter += Time.delta();
|
||||||
|
|
||||||
|
if(turnCounter >= turnDuration){
|
||||||
|
turn ++;
|
||||||
|
turnCounter = 0;
|
||||||
|
onTurn();
|
||||||
|
}
|
||||||
|
|
||||||
if(state.hasSector()){
|
if(state.hasSector()){
|
||||||
//update sector light
|
//update sector light
|
||||||
float light = state.getSector().getLight();
|
float light = state.getSector().getLight();
|
||||||
@@ -56,6 +68,10 @@ public class Universe{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void onTurn(){
|
||||||
|
//create a random event here, e.g. invasion
|
||||||
|
}
|
||||||
|
|
||||||
public float secondsMod(float mod, float scale){
|
public float secondsMod(float mod, float scale){
|
||||||
return (seconds / scale) % mod;
|
return (seconds / scale) % mod;
|
||||||
}
|
}
|
||||||
@@ -69,11 +85,16 @@ public class Universe{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void save(){
|
private void save(){
|
||||||
Core.settings.putSave("utime", seconds);
|
Core.settings.put("utime", seconds);
|
||||||
|
Core.settings.put("turn", turn);
|
||||||
|
Core.settings.put("turntime", turnCounter);
|
||||||
|
Core.settings.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void load(){
|
private void load(){
|
||||||
seconds = Core.settings.getLong("utime");
|
seconds = Core.settings.getLong("utime");
|
||||||
|
turn = Core.settings.getInt("turn");
|
||||||
|
turnCounter = Core.settings.getFloat("turntime");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ public class Pal{
|
|||||||
items = Color.valueOf("2ea756"),
|
items = Color.valueOf("2ea756"),
|
||||||
command = Color.valueOf("eab678"),
|
command = Color.valueOf("eab678"),
|
||||||
|
|
||||||
|
shield = Color.valueOf("7e8ffc").mul(1.3f).a(0.7f),
|
||||||
|
shieldIn = Color.black.cpy().a(0f),
|
||||||
|
|
||||||
bulletYellow = Color.valueOf("fff8e8"),
|
bulletYellow = Color.valueOf("fff8e8"),
|
||||||
bulletYellowBack = Color.valueOf("f9c27a"),
|
bulletYellowBack = Color.valueOf("f9c27a"),
|
||||||
|
|
||||||
|
|||||||
12
core/src/mindustry/logic/LogicDialog.java
Normal file
12
core/src/mindustry/logic/LogicDialog.java
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package mindustry.logic;
|
||||||
|
|
||||||
|
import mindustry.ui.dialogs.*;
|
||||||
|
|
||||||
|
public class LogicDialog extends FloatingDialog{
|
||||||
|
|
||||||
|
public LogicDialog(){
|
||||||
|
super("");
|
||||||
|
clear();
|
||||||
|
addCloseButton();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package mindustry.world.blocks.experimental;
|
package mindustry.logic;
|
||||||
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
|
||||||
4
core/src/mindustry/logic/LogicNode.java
Normal file
4
core/src/mindustry/logic/LogicNode.java
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
package mindustry.logic;
|
||||||
|
|
||||||
|
public class LogicNode{
|
||||||
|
}
|
||||||
@@ -141,6 +141,16 @@ public class UnitType extends UnlockableContent{
|
|||||||
if(drawCell) drawCell(unit);
|
if(drawCell) drawCell(unit);
|
||||||
if(drawItems) drawItems(unit);
|
if(drawItems) drawItems(unit);
|
||||||
drawLight(unit);
|
drawLight(unit);
|
||||||
|
|
||||||
|
if(unit.shieldAlpha() > 0){
|
||||||
|
drawShield(unit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void drawShield(Unitc unit){
|
||||||
|
float alpha = unit.shieldAlpha();
|
||||||
|
float radius = unit.hitSize() * 1.3f;
|
||||||
|
Fill.light(unit.x(), unit.y(), Lines.circleVertices(radius), radius, Tmp.c1.set(Pal.shieldIn), Tmp.c2.set(Pal.shield).lerp(Color.white, Mathf.clamp(unit.hitTime())).a(Pal.shield.a * alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawControl(Unitc unit){
|
public void drawControl(Unitc unit){
|
||||||
|
|||||||
Reference in New Issue
Block a user