Prototype health/ammo indication

This commit is contained in:
Anuken 2020-09-13 21:08:24 -04:00
parent be229f441e
commit 7ce93c7f85
28 changed files with 1694 additions and 1542 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 169 B

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 B

After

Width:  |  Height:  |  Size: 257 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 B

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 193 B

View File

@ -910,6 +910,7 @@ unit.gamma.name = Gamma
unit.scepter.name = Scepter
unit.reign.name = Reign
block.resupply-point.name = Resupply Point
block.parallax.name = Parallax
block.cliff.name = Cliff
block.sand-boulder.name = Sand Boulder

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 185 KiB

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 KiB

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

View File

@ -214,7 +214,8 @@ public class Vars implements Loadable{
if(loadLocales){
//load locales
String[] stra = Core.files.internal("locales").readString().split("\n");
String[]
stra = Core.files.internal("locales").readString().split("\n");
locales = new Locale[stra.length];
for(int i = 0; i < locales.length; i++){
String code = stra[i];

View File

@ -1481,14 +1481,14 @@ public class Blocks implements ContentList{
arc = new PowerTurret("arc"){{
requirements(Category.turret, with(Items.copper, 35, Items.lead, 50));
shootType = new LightningBulletType(){{
damage = 21;
damage = 20;
lightningLength = 25;
collidesAir = false;
}};
reloadTime = 35f;
shootCone = 40f;
rotatespeed = 8f;
powerUse = 4.5f;
powerUse = 4f;
targetAir = false;
range = 90f;
shootEffect = Fx.lightningShoot;
@ -1563,7 +1563,7 @@ public class Blocks implements ContentList{
health = 250 * size * size;
range = 140f;
hasPower = true;
consumes.power(3f);
consumes.power(8f);
size = 2;
shootLength = 5f;
bulletDamage = 25f;

View File

@ -53,7 +53,7 @@ public class StatusEffects implements ContentList{
init(() -> {
trans(shocked, ((unit, time, newTime, result) -> {
unit.damagePierce(20f);
unit.damagePierce(14f);
if(unit.team() == state.rules.waveTeam){
Events.fire(Trigger.shock);
}

View File

@ -362,7 +362,7 @@ public class UnitTypes implements ContentList{
speed = 0.85f;
hitsize = 8f;
health = 170;
health = 180;
mechSideSway = 0.25f;
range = 40f;
@ -377,7 +377,7 @@ public class UnitTypes implements ContentList{
speed = 1f;
splashDamageRadius = 55f;
instantDisappear = true;
splashDamage = 45f;
splashDamage = 55f;
killShooter = true;
hittable = false;
collidesAir = true;

View File

@ -61,6 +61,7 @@ public class Renderer implements ApplicationListener{
@Override
public void update(){
Color.white.set(1f, 1f, 1f, 1f);
Gl.clear(Gl.stencilBufferBit);
camerascale = Mathf.lerpDelta(camerascale, targetscale, 0.1f);
laserOpacity = Core.settings.getInt("lasersopacity") / 100f;

View File

@ -16,6 +16,7 @@ import static mindustry.Vars.*;
abstract class WeaponsComp implements Teamc, Posc, Rotc, Velc{
@Import float x, y, rotation, reloadMultiplier;
@Import Vec2 vel;
@Import UnitType type;
/** minimum cursor distance from unit, fixes 'cross-eyed' shooting */
static final float minAimDst = 18f;
@ -29,6 +30,10 @@ abstract class WeaponsComp implements Teamc, Posc, Rotc, Velc{
boolean isShooting;
float ammo;
float ammof(){
return ammo / type.ammoCapacity;
}
void setWeaponRotation(float rotation){
for(WeaponMount mount : mounts){
mount.rotation = rotation;

View File

@ -122,7 +122,7 @@ public class MinimapRenderer implements Disposable{
float dy = (Core.camera.position.y / tilesize);
dx = Mathf.clamp(dx, sz, world.width() - sz);
dy = Mathf.clamp(dy, sz, world.height() - sz);
float invTexWidth = 1f / texture.width;
float invTexWidth = 1f / texture.getWidth();
float invTexHeight = 1f / texture.height;
float x = dx - sz, y = world.height() - dy - sz, width = sz * 2, height = sz * 2;
region.set(x * invTexWidth, y * invTexHeight, (x + width) * invTexWidth, (y + height) * invTexHeight);

View File

@ -46,6 +46,7 @@ public class Pal{
lightishGray = Color.valueOf("a2a2a2"),
darkishGray = new Color(0.3f, 0.3f, 0.3f, 1f),
darkerGray = new Color(0.2f, 0.2f, 0.2f, 1f),
darkestGray = new Color(0.1f, 0.1f, 0.1f, 1f),
ammo = Color.valueOf("ff8947"),
rubble = Color.valueOf("1c1817"),

View File

@ -154,7 +154,7 @@ public class Shaders{
setUniformf("u_progress", progress);
setUniformf("u_uv", region.u, region.v);
setUniformf("u_uv2", region.u2, region.v2);
setUniformf("u_texsize", region.getTexture().width, region.getTexture().height);
setUniformf("u_texsize", region.getTexture().getWidth(), region.getTexture().height);
}
}
@ -174,7 +174,7 @@ public class Shaders{
setUniformf("u_uv", region.u, region.v);
setUniformf("u_uv2", region.u2, region.v2);
setUniformf("u_time", Time.time());
setUniformf("u_texsize", region.getTexture().width, region.getTexture().height);
setUniformf("u_texsize", region.getTexture().getWidth(), region.getTexture().height);
}
}

View File

@ -54,9 +54,9 @@ public class Styles{
}};
waveb = new ButtonStyle(){{
up = buttonEdge4;
over = buttonEdgeOver4;
disabled = buttonEdge4;
up = wavepane;
over = wavepane; //TODO wrong
disabled = wavepane;
}};
defaultt = new TextButtonStyle(){{
@ -183,6 +183,9 @@ public class Styles{
over = buttonRightOver;
down = buttonRightDown;
up = buttonRight;
disabled = buttonRightDisabled;
imageDisabledColor = Color.clear;
imageUpColor = Color.white;
}};
emptyi = new ImageButtonStyle(){{
imageDownColor = Pal.accent;

View File

@ -1,7 +1,9 @@
package mindustry.ui.fragments;
import arc.*;
import arc.func.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.input.*;
import arc.math.*;
import arc.scene.*;
@ -29,7 +31,7 @@ import mindustry.ui.dialogs.*;
import static mindustry.Vars.*;
public class HudFragment extends Fragment{
private static final float dsize = 47f;
private static final float dsize = 65f;
public final PlacementFragment blockfrag = new PlacementFragment();
@ -147,48 +149,54 @@ public class HudFragment extends Fragment{
cont.stack(wavesMain = new Table(), editorMain = new Table()).height(wavesMain.getPrefHeight());
{
wavesMain.visible(() -> shown && !state.isEditor());
wavesMain.top().left();
Stack stack = new Stack();
Button waves = new Button(Styles.waveb);
Table btable = new Table().margin(0);
wavesMain.visible(() -> shown && !state.isEditor());
wavesMain.top().left();
stack.add(waves);
stack.add(btable);
wavesMain.table(s -> {
//wave info button with text
s.add(makeStatusTable()).grow();
addWaveTable(waves);
addPlayButton(btable);
wavesMain.add(stack).width(dsize * 5 + 4f);
wavesMain.row();
wavesMain.table(Tex.button, t -> t.margin(10f).add(new Bar("boss.health", Pal.health, () -> state.boss() == null ? 0f : state.boss().healthf()).blink(Color.white))
.grow()).fillX().visible(() -> state.rules.waves && state.boss() != null).height(60f).get();
wavesMain.row();
}
//table with button to skip wave
s.button(Icon.play, Styles.righti, 30f, () -> {
if(net.client() && player.admin){
Call.adminRequest(player, AdminAction.wave);
}else if(inLaunchWave()){
ui.showConfirm("@confirm", "@launch.skip.confirm", () -> !canSkipWave(), () -> logic.skipWave());
}else{
logic.skipWave();
}
}).growY().fillX().right().width(40f).disabled(b -> !canSkipWave());
}).width(dsize * 5 + 4f);
{
editorMain.table(Tex.buttonEdge4, t -> {
//t.margin(0f);
t.add("@editor.teams").growX().left();
t.row();
t.table(teams -> {
teams.left();
int i = 0;
for(Team team : Team.baseTeams){
ImageButton button = teams.button(Tex.whiteui, Styles.clearTogglePartiali, 40f, () -> Call.setPlayerTeamEditor(player, team))
.size(50f).margin(6f).get();
button.getImageCell().grow();
button.getStyle().imageUpColor = team.color;
button.update(() -> button.setChecked(player.team() == team));
wavesMain.row();
if(++i % 3 == 0){
teams.row();
}
wavesMain.table(Tex.button, t -> t.margin(10f).add(new Bar("boss.health", Pal.health, () -> state.boss() == null ? 0f : state.boss().healthf()).blink(Color.white))
.grow()).fillX().visible(() -> state.rules.waves && state.boss() != null).height(60f).get();
wavesMain.row();
editorMain.table(Tex.buttonEdge4, t -> {
//t.margin(0f);
t.add("@editor.teams").growX().left();
t.row();
t.table(teams -> {
teams.left();
int i = 0;
for(Team team : Team.baseTeams){
ImageButton button = teams.button(Tex.whiteui, Styles.clearTogglePartiali, 40f, () -> Call.setPlayerTeamEditor(player, team))
.size(50f).margin(6f).get();
button.getImageCell().grow();
button.getStyle().imageUpColor = team.color;
button.update(() -> button.setChecked(player.team() == team));
if(++i % 3 == 0){
teams.row();
}
}).left();
}).width(dsize * 5 + 4f);
editorMain.visible(() -> shown && state.isEditor());
}
}
}).left();
}).width(dsize * 5 + 4f);
editorMain.visible(() -> shown && state.isEditor());
//fps display
cont.table(info -> {
@ -598,7 +606,9 @@ public class HudFragment extends Fragment{
shown = !shown;
}
private void addWaveTable(Button table){
private Table makeStatusTable(){
Button table = new Button(Styles.waveb);
StringBuilder ibuild = new StringBuilder();
IntFormat wavef = new IntFormat("wave");
@ -625,6 +635,90 @@ public class HudFragment extends Fragment{
StringBuilder builder = new StringBuilder();
table.name = "waves";
table.marginTop(0).marginBottom(4).marginLeft(4);
class Bar extends Element{
public final Floatp amount;
public final boolean flip;
public Bar(Floatp amount, boolean flip){
this.amount = amount;
this.flip = flip;
setColor(Pal.health);
}
@Override
public void draw(){
drawInner(Pal.darkishGray);
Draw.beginStencil();
Fill.crect(x, y, width, height * amount.get());
Draw.beginStenciled();
drawInner(color);
Draw.endStencil();
}
void drawInner(Color color){
if(flip){
x += width;
width = -width;
}
float stroke = width * 0.35f;
float bh = height/2f;
Draw.color(color);
Fill.quad(
x, y,
x + stroke, y,
x + width, y + bh,
x + width - stroke, y + bh
);
Fill.quad(
x + width, y + bh,
x + width - stroke, y + bh,
x, y + height,
x + stroke, y + height
);
Draw.reset();
if(flip){
width = -width;
x -= width;
}
}
}
table.stack(
new Element(){
@Override
public void draw(){
Draw.color(Pal.darkerGray);
Fill.poly(x + width/2f, y + height/2f, 6, height / Mathf.sqrt3);
Draw.reset();
Drawf.shadow(x + width/2f, y + height/2f, height * 1.1f);
}
},
new Table(t -> {
float bw = 40f;
float pad = -30;
t.margin(0);
t.add(new Bar(() -> player.unit().healthf(), true)).width(bw).growY().padRight(pad);
t.image(() -> player.icon()).scaling(Scaling.bounded).grow();
t.add(new Bar(() -> player.dead() ? 0f : state.rules.unitAmmo ? player.unit().ammof() : player.unit().healthf(), false)).width(bw).growY().padLeft(pad).update(b -> {
b.color.set(state.rules.unitAmmo ? Pal.ammo : Pal.health);
});
})).size(120f, 80).padRight(4);
table.labelWrap(() -> {
builder.setLength(0);
builder.append(wavef.get(state.wave));
@ -671,22 +765,12 @@ public class HudFragment extends Fragment{
showLaunchConfirm();
}
});
return table;
}
private boolean canSkipWave(){
return state.rules.waves && ((net.server() || player.admin) || !net.active()) && state.enemies == 0 && !spawner.isSpawning() && !state.rules.tutorial;
}
private void addPlayButton(Table table){
table.right().button(Icon.play, Styles.righti, 30f, () -> {
if(net.client() && player.admin){
Call.adminRequest(player, AdminAction.wave);
}else if(inLaunchWave()){
ui.showConfirm("@confirm", "@launch.skip.confirm", () -> !canSkipWave(), () -> logic.skipWave());
}else{
logic.skipWave();
}
}).growY().fillX().right().width(40f)
.visible(this::canSkipWave);
}
}

View File

@ -32,7 +32,7 @@ public class MinimapFragment extends Fragment{
if(renderer.minimap.getTexture() != null){
Draw.color();
float ratio = (float)renderer.minimap.getTexture().height / renderer.minimap.getTexture().width;
float ratio = (float)renderer.minimap.getTexture().height / renderer.minimap.getTexture().getWidth();
TextureRegion reg = Draw.wrap(renderer.minimap.getTexture());
Draw.rect(reg, w/2f + panx*zoom, h/2f + pany*zoom, size, size * ratio);
renderer.minimap.drawEntities(w/2f + panx*zoom - size/2f, h/2f + pany*zoom - size/2f * ratio, size, size * ratio, zoom, true);
@ -113,7 +113,7 @@ public class MinimapFragment extends Fragment{
public void toggle(){
if(Core.settings.getBool("mapcenter")){
float size = baseSize * zoom * world.width();
float ratio = (float)renderer.minimap.getTexture().height / renderer.minimap.getTexture().width;
float ratio = (float)renderer.minimap.getTexture().height / renderer.minimap.getTexture().getWidth();
panx = (size/2f - player.x() / (world.width() * tilesize) * size) / zoom;
pany = (size*ratio/2f - player.y() / (world.height() * tilesize) * size*ratio) / zoom;
}

View File

@ -62,6 +62,7 @@ public class ItemTurret extends Turret{
}
public class ItemTurretBuild extends TurretBuild{
@Override
public void onProximityAdded(){
super.onProximityAdded();
@ -72,6 +73,13 @@ public class ItemTurret extends Turret{
}
}
@Override
public void updateTile(){
unit.ammo((float)unit.type().ammoCapacity * totalAmmo / maxAmmo);
super.updateTile();
}
@Override
public void displayBars(Table bars){
super.displayBars(bars);

View File

@ -72,6 +72,13 @@ public class LiquidTurret extends Turret{
return target != null && hasAmmo();
}
@Override
public void updateTile(){
unit.ammo(unit.type().ammoCapacity * liquids.currentAmount() / liquidCapacity);
super.updateTile();
}
@Override
protected void findTarget(){
if(liquids.current().canExtinguish()){

View File

@ -28,6 +28,13 @@ public class PowerTurret extends Turret{
public class PowerTurretBuild extends TurretBuild{
@Override
public void updateTile(){
unit.ammo(power.status * unit.type().ammoCapacity);
super.updateTile();
}
@Override
public BulletType useAmmo(){
//nothing used directly

View File

@ -967,7 +967,9 @@ public class ServerControl implements ApplicationListener{
for(Player p : players){
if(p.con == null) continue;
boolean wasAdmin = p.admin;
p.reset();
p.admin = wasAdmin;
if(state.rules.pvp){
p.team(netServer.assignTeam(p, new SeqIterable<>(players)));
}