mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-30 22:49:06 +07:00
Added indicator when core is under attack
This commit is contained in:
@ -42,6 +42,7 @@ Once you have selected some blocks, press the checkbox to confirm, and your ship
|
||||
- [accent]Remove blocks in an area[] by tapping and holding an empty spot, then dragging in a direction.\n\
|
||||
- [accent]Cancel deconstruction or selection[] by pressing the X at the bottom left.
|
||||
text.showagain=Don't show again next session
|
||||
text.coreattack=< Core is under attack! >
|
||||
text.unlocks=Unlocks
|
||||
text.savegame=Save Game
|
||||
text.loadgame=Load Game
|
||||
|
@ -1,11 +1,13 @@
|
||||
package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.Interpolation;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Scaling;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.game.EventType.StateChangeEvent;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
@ -13,9 +15,8 @@ import io.anuke.mindustry.net.Packets.AdminAction;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.ui.IntFormat;
|
||||
import io.anuke.mindustry.ui.Minimap;
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Inputs;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.graphics.Hue;
|
||||
import io.anuke.ucore.scene.Element;
|
||||
import io.anuke.ucore.scene.Group;
|
||||
import io.anuke.ucore.scene.actions.Actions;
|
||||
@ -26,6 +27,7 @@ import io.anuke.ucore.scene.ui.Label;
|
||||
import io.anuke.ucore.scene.ui.layout.Stack;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@ -40,6 +42,8 @@ public class HudFragment extends Fragment{
|
||||
private boolean shown = true;
|
||||
private float dsize = 58;
|
||||
private float isize = 40;
|
||||
private float coreAttackTime;
|
||||
private float lastCoreHP;
|
||||
|
||||
public void build(Group parent){
|
||||
|
||||
@ -128,6 +132,39 @@ public class HudFragment extends Fragment{
|
||||
t.table("pane", top -> top.add("[orange]< " + Bundles.get("text.paused") + " >").pad(6).get().setFontScale(fontScale * 1.5f));
|
||||
});
|
||||
|
||||
//'core is under attack' table
|
||||
parent.fill(t -> {
|
||||
float notifDuration = 240f;
|
||||
|
||||
Events.on(StateChangeEvent.class, (from, to) -> {
|
||||
if(to == State.menu || from == State.menu){
|
||||
coreAttackTime = 0f;
|
||||
lastCoreHP = Float.NaN;
|
||||
}
|
||||
});
|
||||
|
||||
t.top().visible(() -> {
|
||||
if(state.is(State.menu) || state.teams.get(players[0].getTeam()).cores.size == 0){
|
||||
coreAttackTime = 0f;
|
||||
return false;
|
||||
}
|
||||
|
||||
float curr = state.teams.get(players[0].getTeam()).cores.first().entity.health;
|
||||
if(!Float.isNaN(lastCoreHP) && curr < lastCoreHP){
|
||||
coreAttackTime = notifDuration;
|
||||
}
|
||||
lastCoreHP = curr;
|
||||
|
||||
t.getColor().a = Mathf.clamp(coreAttackTime / 30f);
|
||||
|
||||
coreAttackTime -= Timers.delta();
|
||||
|
||||
return coreAttackTime > 0;
|
||||
});
|
||||
t.table("clear", top -> top.add("$text.coreattack").pad(6)
|
||||
.update(label -> label.setColor(Hue.mix(Color.ORANGE, Color.SCARLET, Mathf.absin(Timers.time(), 2f, 1f)))));
|
||||
});
|
||||
|
||||
//'saving' indicator
|
||||
parent.fill(t -> {
|
||||
t.bottom().visible(() -> !state.is(State.menu) && control.getSaves().isSaving());
|
||||
|
@ -14,7 +14,6 @@ import io.anuke.mindustry.entities.Units;
|
||||
import io.anuke.mindustry.entities.traits.SpawnerTrait;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
import io.anuke.mindustry.entities.units.UnitType;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.graphics.Shaders;
|
||||
@ -104,7 +103,7 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
@Override
|
||||
public float handleDamage(Tile tile, float amount){
|
||||
return debug && tile.getTeam() == Team.blue ? 0 : amount;
|
||||
return amount;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user