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.scepter.name = Scepter
unit.reign.name = Reign unit.reign.name = Reign
block.resupply-point.name = Resupply Point
block.parallax.name = Parallax block.parallax.name = Parallax
block.cliff.name = Cliff block.cliff.name = Cliff
block.sand-boulder.name = Sand Boulder 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){ if(loadLocales){
//load locales //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]; locales = new Locale[stra.length];
for(int i = 0; i < locales.length; i++){ for(int i = 0; i < locales.length; i++){
String code = stra[i]; String code = stra[i];

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -122,7 +122,7 @@ public class MinimapRenderer implements Disposable{
float dy = (Core.camera.position.y / tilesize); float dy = (Core.camera.position.y / tilesize);
dx = Mathf.clamp(dx, sz, world.width() - sz); dx = Mathf.clamp(dx, sz, world.width() - sz);
dy = Mathf.clamp(dy, sz, world.height() - 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 invTexHeight = 1f / texture.height;
float x = dx - sz, y = world.height() - dy - sz, width = sz * 2, height = sz * 2; 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); 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"), lightishGray = Color.valueOf("a2a2a2"),
darkishGray = new Color(0.3f, 0.3f, 0.3f, 1f), darkishGray = new Color(0.3f, 0.3f, 0.3f, 1f),
darkerGray = new Color(0.2f, 0.2f, 0.2f, 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"), ammo = Color.valueOf("ff8947"),
rubble = Color.valueOf("1c1817"), rubble = Color.valueOf("1c1817"),

View File

@@ -154,7 +154,7 @@ public class Shaders{
setUniformf("u_progress", progress); setUniformf("u_progress", progress);
setUniformf("u_uv", region.u, region.v); setUniformf("u_uv", region.u, region.v);
setUniformf("u_uv2", region.u2, region.v2); 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_uv", region.u, region.v);
setUniformf("u_uv2", region.u2, region.v2); setUniformf("u_uv2", region.u2, region.v2);
setUniformf("u_time", Time.time()); 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(){{ waveb = new ButtonStyle(){{
up = buttonEdge4; up = wavepane;
over = buttonEdgeOver4; over = wavepane; //TODO wrong
disabled = buttonEdge4; disabled = wavepane;
}}; }};
defaultt = new TextButtonStyle(){{ defaultt = new TextButtonStyle(){{
@@ -183,6 +183,9 @@ public class Styles{
over = buttonRightOver; over = buttonRightOver;
down = buttonRightDown; down = buttonRightDown;
up = buttonRight; up = buttonRight;
disabled = buttonRightDisabled;
imageDisabledColor = Color.clear;
imageUpColor = Color.white;
}}; }};
emptyi = new ImageButtonStyle(){{ emptyi = new ImageButtonStyle(){{
imageDownColor = Pal.accent; imageDownColor = Pal.accent;

View File

@@ -1,7 +1,9 @@
package mindustry.ui.fragments; package mindustry.ui.fragments;
import arc.*; import arc.*;
import arc.func.*;
import arc.graphics.*; import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.input.*; import arc.input.*;
import arc.math.*; import arc.math.*;
import arc.scene.*; import arc.scene.*;
@@ -29,7 +31,7 @@ import mindustry.ui.dialogs.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
public class HudFragment extends Fragment{ public class HudFragment extends Fragment{
private static final float dsize = 47f; private static final float dsize = 65f;
public final PlacementFragment blockfrag = new PlacementFragment(); 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()); cont.stack(wavesMain = new Table(), editorMain = new Table()).height(wavesMain.getPrefHeight());
{ wavesMain.visible(() -> shown && !state.isEditor());
wavesMain.visible(() -> shown && !state.isEditor()); wavesMain.top().left();
wavesMain.top().left();
Stack stack = new Stack();
Button waves = new Button(Styles.waveb);
Table btable = new Table().margin(0);
stack.add(waves); wavesMain.table(s -> {
stack.add(btable); //wave info button with text
s.add(makeStatusTable()).grow();
addWaveTable(waves); //table with button to skip wave
addPlayButton(btable); s.button(Icon.play, Styles.righti, 30f, () -> {
wavesMain.add(stack).width(dsize * 5 + 4f); if(net.client() && player.admin){
wavesMain.row(); Call.adminRequest(player, AdminAction.wave);
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)) }else if(inLaunchWave()){
.grow()).fillX().visible(() -> state.rules.waves && state.boss() != null).height(60f).get(); ui.showConfirm("@confirm", "@launch.skip.confirm", () -> !canSkipWave(), () -> logic.skipWave());
wavesMain.row(); }else{
} logic.skipWave();
}
}).growY().fillX().right().width(40f).disabled(b -> !canSkipWave());
}).width(dsize * 5 + 4f);
{ 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){ 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))
teams.row(); .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); }).left();
editorMain.visible(() -> shown && state.isEditor()); }).width(dsize * 5 + 4f);
} editorMain.visible(() -> shown && state.isEditor());
//fps display //fps display
cont.table(info -> { cont.table(info -> {
@@ -598,7 +606,9 @@ public class HudFragment extends Fragment{
shown = !shown; shown = !shown;
} }
private void addWaveTable(Button table){ private Table makeStatusTable(){
Button table = new Button(Styles.waveb);
StringBuilder ibuild = new StringBuilder(); StringBuilder ibuild = new StringBuilder();
IntFormat wavef = new IntFormat("wave"); IntFormat wavef = new IntFormat("wave");
@@ -625,6 +635,90 @@ public class HudFragment extends Fragment{
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
table.name = "waves"; 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(() -> { table.labelWrap(() -> {
builder.setLength(0); builder.setLength(0);
builder.append(wavef.get(state.wave)); builder.append(wavef.get(state.wave));
@@ -671,22 +765,12 @@ public class HudFragment extends Fragment{
showLaunchConfirm(); showLaunchConfirm();
} }
}); });
return table;
} }
private boolean canSkipWave(){ private boolean canSkipWave(){
return state.rules.waves && ((net.server() || player.admin) || !net.active()) && state.enemies == 0 && !spawner.isSpawning() && !state.rules.tutorial; 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){ if(renderer.minimap.getTexture() != null){
Draw.color(); 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()); TextureRegion reg = Draw.wrap(renderer.minimap.getTexture());
Draw.rect(reg, w/2f + panx*zoom, h/2f + pany*zoom, size, size * ratio); 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); 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(){ public void toggle(){
if(Core.settings.getBool("mapcenter")){ if(Core.settings.getBool("mapcenter")){
float size = baseSize * zoom * world.width(); 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; panx = (size/2f - player.x() / (world.width() * tilesize) * size) / zoom;
pany = (size*ratio/2f - player.y() / (world.height() * tilesize) * size*ratio) / 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{ public class ItemTurretBuild extends TurretBuild{
@Override @Override
public void onProximityAdded(){ public void onProximityAdded(){
super.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 @Override
public void displayBars(Table bars){ public void displayBars(Table bars){
super.displayBars(bars); super.displayBars(bars);

View File

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

View File

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

View File

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