Progress on implementing unit teams
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 251 B After Width: | Height: | Size: 264 B |
@@ -7,13 +7,12 @@ uniform sampler2D u_texture;
|
|||||||
|
|
||||||
uniform vec4 u_color;
|
uniform vec4 u_color;
|
||||||
uniform vec2 u_texsize;
|
uniform vec2 u_texsize;
|
||||||
uniform float u_lighten;
|
|
||||||
|
|
||||||
varying vec4 v_color;
|
varying vec4 v_color;
|
||||||
varying vec2 v_texCoord;
|
varying vec2 v_texCoord;
|
||||||
|
|
||||||
bool id(vec4 v){
|
bool id(vec4 v){
|
||||||
return v.a > 0.1 && !(v.r < 0.01 && v.g < 0.01 && v.b < 0.01);
|
return v.a > 0.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
@@ -39,6 +38,6 @@ void main() {
|
|||||||
if((c.r < 0.01 && c.g < 0.01 && c.b < 0.01)){
|
if((c.r < 0.01 && c.g < 0.01 && c.b < 0.01)){
|
||||||
c = vec4(0.0);
|
c = vec4(0.0);
|
||||||
}
|
}
|
||||||
gl_FragColor = mix(c, vec4(1.0, 1.0, 1.0, c.a), u_lighten) * v_color;
|
gl_FragColor = mix(c, vec4(1.0, 1.0, 1.0, c.a), c.a) * v_color;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 91 KiB |
@@ -1,7 +1,7 @@
|
|||||||
#Autogenerated file. Do not modify.
|
#Autogenerated file. Do not modify.
|
||||||
#Wed Mar 14 22:59:39 EDT 2018
|
#Wed Mar 14 23:06:35 EDT 2018
|
||||||
version=release
|
version=release
|
||||||
androidBuildCode=520
|
androidBuildCode=521
|
||||||
name=Mindustry
|
name=Mindustry
|
||||||
code=3.4
|
code=3.4
|
||||||
build=custom build
|
build=custom build
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import io.anuke.mindustry.entities.Player;
|
|||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.entities.effect.Shield;
|
import io.anuke.mindustry.entities.effect.Shield;
|
||||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||||
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.io.Platform;
|
import io.anuke.mindustry.io.Platform;
|
||||||
import io.anuke.mindustry.net.ClientDebug;
|
import io.anuke.mindustry.net.ClientDebug;
|
||||||
import io.anuke.mindustry.net.ServerDebug;
|
import io.anuke.mindustry.net.ServerDebug;
|
||||||
@@ -136,9 +137,15 @@ public class Vars{
|
|||||||
public static Player player;
|
public static Player player;
|
||||||
|
|
||||||
public static final EntityGroup<Player> playerGroup = Entities.addGroup(Player.class).enableMapping();
|
public static final EntityGroup<Player> playerGroup = Entities.addGroup(Player.class).enableMapping();
|
||||||
public static final EntityGroup<BaseUnit> enemyGroup = Entities.addGroup(BaseUnit.class).enableMapping();
|
|
||||||
public static final EntityGroup<TileEntity> tileGroup = Entities.addGroup(TileEntity.class, false);
|
public static final EntityGroup<TileEntity> tileGroup = Entities.addGroup(TileEntity.class, false);
|
||||||
public static final EntityGroup<Bullet> bulletGroup = Entities.addGroup(Bullet.class);
|
public static final EntityGroup<Bullet> bulletGroup = Entities.addGroup(Bullet.class);
|
||||||
public static final EntityGroup<Shield> shieldGroup = Entities.addGroup(Shield.class, false);
|
public static final EntityGroup<Shield> shieldGroup = Entities.addGroup(Shield.class, false);
|
||||||
public static final EntityGroup<EffectEntity> effectGroup = Entities.addGroup(EffectEntity.class, false);
|
public static final EntityGroup<EffectEntity> effectGroup = Entities.addGroup(EffectEntity.class, false);
|
||||||
|
public static final EntityGroup<BaseUnit>[] unitGroups = new EntityGroup[Team.values().length];
|
||||||
|
|
||||||
|
static{
|
||||||
|
for(Team team : Team.values()){
|
||||||
|
unitGroups[team.ordinal()] = Entities.addGroup(BaseUnit.class).enableMapping();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
|||||||
import io.anuke.ucore.core.Events;
|
import io.anuke.ucore.core.Events;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.entities.Entities;
|
import io.anuke.ucore.entities.Entities;
|
||||||
|
import io.anuke.ucore.entities.EntityGroup;
|
||||||
import io.anuke.ucore.modules.Module;
|
import io.anuke.ucore.modules.Module;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
@@ -115,12 +116,17 @@ public class Logic extends Module {
|
|||||||
|
|
||||||
Entities.update(Entities.defaultGroup());
|
Entities.update(Entities.defaultGroup());
|
||||||
Entities.update(bulletGroup);
|
Entities.update(bulletGroup);
|
||||||
Entities.update(enemyGroup);
|
for(EntityGroup group : unitGroups){
|
||||||
|
if(!group.isEmpty()) Entities.update(group);
|
||||||
|
}
|
||||||
Entities.update(tileGroup);
|
Entities.update(tileGroup);
|
||||||
Entities.update(shieldGroup);
|
Entities.update(shieldGroup);
|
||||||
Entities.update(playerGroup);
|
Entities.update(playerGroup);
|
||||||
|
|
||||||
Entities.collideGroups(bulletGroup, enemyGroup);
|
for(EntityGroup group : unitGroups){
|
||||||
|
if(!group.isEmpty()) Entities.collideGroups(bulletGroup, group);
|
||||||
|
}
|
||||||
|
|
||||||
Entities.collideGroups(bulletGroup, playerGroup);
|
Entities.collideGroups(bulletGroup, playerGroup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import io.anuke.mindustry.entities.Player;
|
|||||||
import io.anuke.mindustry.entities.SyncEntity;
|
import io.anuke.mindustry.entities.SyncEntity;
|
||||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||||
import io.anuke.mindustry.game.SpawnPoint;
|
import io.anuke.mindustry.game.SpawnPoint;
|
||||||
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.graphics.BlockRenderer;
|
import io.anuke.mindustry.graphics.BlockRenderer;
|
||||||
import io.anuke.mindustry.graphics.Shaders;
|
import io.anuke.mindustry.graphics.Shaders;
|
||||||
import io.anuke.mindustry.input.InputHandler;
|
import io.anuke.mindustry.input.InputHandler;
|
||||||
@@ -29,11 +30,11 @@ import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
|||||||
import io.anuke.ucore.core.*;
|
import io.anuke.ucore.core.*;
|
||||||
import io.anuke.ucore.entities.EffectEntity;
|
import io.anuke.ucore.entities.EffectEntity;
|
||||||
import io.anuke.ucore.entities.Entities;
|
import io.anuke.ucore.entities.Entities;
|
||||||
|
import io.anuke.ucore.entities.EntityGroup;
|
||||||
import io.anuke.ucore.function.Callable;
|
import io.anuke.ucore.function.Callable;
|
||||||
import io.anuke.ucore.graphics.*;
|
import io.anuke.ucore.graphics.*;
|
||||||
import io.anuke.ucore.modules.RendererModule;
|
import io.anuke.ucore.modules.RendererModule;
|
||||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||||
import io.anuke.ucore.util.Angles;
|
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Tmp;
|
import io.anuke.ucore.util.Tmp;
|
||||||
|
|
||||||
@@ -182,18 +183,12 @@ public class Renderer extends RendererModule{
|
|||||||
blocks.processBlocks();
|
blocks.processBlocks();
|
||||||
blocks.drawBlocks(false);
|
blocks.drawBlocks(false);
|
||||||
|
|
||||||
Graphics.shader(Shaders.outline, false);
|
drawAllTeams(false);
|
||||||
Entities.draw(enemyGroup);
|
|
||||||
Graphics.shader();
|
|
||||||
Entities.draw(playerGroup, p -> !p.mech.flying);
|
|
||||||
|
|
||||||
Entities.draw(Entities.defaultGroup());
|
Entities.draw(Entities.defaultGroup());
|
||||||
|
|
||||||
blocks.drawBlocks(true);
|
blocks.drawBlocks(true);
|
||||||
|
|
||||||
Graphics.shader(Shaders.outline, false);
|
drawAllTeams(true);
|
||||||
Entities.draw(playerGroup, p -> p.mech.flying);
|
|
||||||
Graphics.shader();
|
|
||||||
|
|
||||||
Entities.draw(bulletGroup);
|
Entities.draw(bulletGroup);
|
||||||
Entities.draw(effectGroup);
|
Entities.draw(effectGroup);
|
||||||
@@ -214,6 +209,24 @@ public class Renderer extends RendererModule{
|
|||||||
batch.end();
|
batch.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void drawAllTeams(boolean flying){
|
||||||
|
for(Team team : Team.values()){
|
||||||
|
EntityGroup<BaseUnit> group = unitGroups[team.ordinal()];
|
||||||
|
if(group.all().size() < 0) continue;
|
||||||
|
|
||||||
|
Shaders.outline.color.set(team.color);
|
||||||
|
|
||||||
|
Graphics.beginShaders(Shaders.outline);
|
||||||
|
drawTeam(team, flying);
|
||||||
|
Graphics.endShaders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawTeam(Team team, boolean flying){
|
||||||
|
Entities.draw(unitGroups[team.ordinal()], u -> u.isFlying() == flying);
|
||||||
|
Entities.draw(playerGroup, p -> p.isFlying() == flying && p.team == team);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resize(int width, int height){
|
public void resize(int width, int height){
|
||||||
super.resize(width, height);
|
super.resize(width, height);
|
||||||
@@ -278,7 +291,9 @@ public class Renderer extends RendererModule{
|
|||||||
Draw.tscl(fontscale);
|
Draw.tscl(fontscale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO implement
|
||||||
void drawEnemyMarkers(){
|
void drawEnemyMarkers(){
|
||||||
|
/*
|
||||||
Graphics.surface(indicatorSurface);
|
Graphics.surface(indicatorSurface);
|
||||||
Draw.color(Color.RED);
|
Draw.color(Color.RED);
|
||||||
|
|
||||||
@@ -298,7 +313,7 @@ public class Renderer extends RendererModule{
|
|||||||
Draw.color();
|
Draw.color();
|
||||||
Draw.alpha(0.4f);
|
Draw.alpha(0.4f);
|
||||||
Graphics.flushSurface();
|
Graphics.flushSurface();
|
||||||
Draw.color();
|
Draw.color();*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawShield(){
|
void drawShield(){
|
||||||
@@ -499,7 +514,10 @@ public class Renderer extends RendererModule{
|
|||||||
target.block().drawSelect(target);
|
target.block().drawSelect(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO draw health bars
|
||||||
|
|
||||||
|
/*
|
||||||
if((!debug || showUI) && Settings.getBool("healthbars")){
|
if((!debug || showUI) && Settings.getBool("healthbars")){
|
||||||
|
|
||||||
//draw entity health bars
|
//draw entity health bars
|
||||||
@@ -510,7 +528,7 @@ public class Renderer extends RendererModule{
|
|||||||
for(Player player : playerGroup.all()){
|
for(Player player : playerGroup.all()){
|
||||||
if(!player.isDead()) drawHealth(player);
|
if(!player.isDead()) drawHealth(player);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawHealth(SyncEntity dest){
|
void drawHealth(SyncEntity dest){
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package io.anuke.mindustry.entities;
|
|||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.graphics.Shaders;
|
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.net.NetEvents;
|
import io.anuke.mindustry.net.NetEvents;
|
||||||
import io.anuke.mindustry.resource.Mech;
|
import io.anuke.mindustry.resource.Mech;
|
||||||
@@ -63,9 +62,15 @@ public class Player extends Unit{
|
|||||||
return mech.mass;
|
return mech.mass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFlying(){
|
||||||
|
return mech.flying;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void damage(int amount){
|
public void damage(int amount){
|
||||||
if(debug || mech.flying) return;
|
if(debug || mech.flying) return;
|
||||||
|
hitTime = hitDuration;
|
||||||
|
|
||||||
health -= amount;
|
health -= amount;
|
||||||
if(health <= 0 && !dead && isLocal){ //remote players don't die normally
|
if(health <= 0 && !dead && isLocal){ //remote players don't die normally
|
||||||
@@ -118,15 +123,10 @@ public class Player extends Unit{
|
|||||||
public void drawSmooth(){
|
public void drawSmooth(){
|
||||||
if((debug && (!showPlayer || !showUI)) || dead) return;
|
if((debug && (!showPlayer || !showUI)) || dead) return;
|
||||||
|
|
||||||
Graphics.beginShaders(Shaders.outline);
|
|
||||||
|
|
||||||
boolean snap = snapCamera && Settings.getBool("smoothcam") && Settings.getBool("pixelate") && isLocal;
|
boolean snap = snapCamera && Settings.getBool("smoothcam") && Settings.getBool("pixelate") && isLocal;
|
||||||
|
|
||||||
String mname = mech.name;
|
String mname = mech.name;
|
||||||
|
|
||||||
Shaders.outline.color.set(getColor());
|
|
||||||
Shaders.outline.lighten = 0f;
|
|
||||||
|
|
||||||
float px = x, py =y;
|
float px = x, py =y;
|
||||||
|
|
||||||
if(snap){
|
if(snap){
|
||||||
@@ -136,6 +136,8 @@ public class Player extends Unit{
|
|||||||
|
|
||||||
float ft = Mathf.sin(walktime, 6f, 2f);
|
float ft = Mathf.sin(walktime, 6f, 2f);
|
||||||
|
|
||||||
|
Draw.alpha(hitTime / hitDuration);
|
||||||
|
|
||||||
for(int i : Mathf.signs){
|
for(int i : Mathf.signs){
|
||||||
tr.trns(footRotation, ft * i);
|
tr.trns(footRotation, ft * i);
|
||||||
Draw.rect(mname + "-leg", x + tr.x, y + tr.y, 12f * i, 12f - Mathf.clamp(ft*i, 0, 2), footRotation- 90);
|
Draw.rect(mname + "-leg", x + tr.x, y + tr.y, 12f * i, 12f - Mathf.clamp(ft*i, 0, 2), footRotation- 90);
|
||||||
@@ -152,8 +154,7 @@ public class Player extends Unit{
|
|||||||
Draw.rect(weapon.name + "-equip", x + tr.x, y + tr.y, w, 8, rotation - 90);
|
Draw.rect(weapon.name + "-equip", x + tr.x, y + tr.y, w, 8, rotation - 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Draw.alpha(1f);
|
||||||
Graphics.endShaders();
|
|
||||||
|
|
||||||
x = px;
|
x = px;
|
||||||
y = py;
|
y = py;
|
||||||
@@ -161,6 +162,12 @@ public class Player extends Unit{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
|
if(hitTime > 0){
|
||||||
|
hitTime -= Timers.delta();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(hitTime < 0) hitTime = 0;
|
||||||
|
|
||||||
if(!isLocal){
|
if(!isLocal){
|
||||||
interpolate();
|
interpolate();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -12,4 +12,5 @@ public abstract class Unit extends SyncEntity {
|
|||||||
public float hitTime;
|
public float hitTime;
|
||||||
|
|
||||||
public abstract float getMass();
|
public abstract float getMass();
|
||||||
|
public abstract boolean isFlying();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import io.anuke.ucore.util.Timer;
|
|||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.enemyGroup;
|
import static io.anuke.mindustry.Vars.unitGroups;
|
||||||
|
|
||||||
public class BaseUnit extends Unit {
|
public class BaseUnit extends Unit {
|
||||||
public UnitType type;
|
public UnitType type;
|
||||||
@@ -27,6 +27,11 @@ public class BaseUnit extends Unit {
|
|||||||
return type.mass;
|
return type.mass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isFlying() {
|
||||||
|
return type.isFlying;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
type.update(this);
|
type.update(this);
|
||||||
@@ -76,7 +81,7 @@ public class BaseUnit extends Unit {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseUnit add(){
|
public BaseUnit add(){
|
||||||
return add(enemyGroup);
|
return add(unitGroups[team.ordinal()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ public class Shaders{
|
|||||||
|
|
||||||
public static class Outline extends Shader{
|
public static class Outline extends Shader{
|
||||||
public Color color = new Color();
|
public Color color = new Color();
|
||||||
public float lighten = 0f;
|
|
||||||
|
|
||||||
public Outline(){
|
public Outline(){
|
||||||
super("outline", "default");
|
super("outline", "default");
|
||||||
@@ -29,7 +28,6 @@ public class Shaders{
|
|||||||
@Override
|
@Override
|
||||||
public void apply(){
|
public void apply(){
|
||||||
shader.setUniformf("u_color", color);
|
shader.setUniformf("u_color", color);
|
||||||
shader.setUniformf("u_lighten", lighten);
|
|
||||||
shader.setUniformf("u_texsize", vec.set(region.getTexture().getWidth(), region.getTexture().getHeight()));
|
shader.setUniformf("u_texsize", vec.set(region.getTexture().getWidth(), region.getTexture().getHeight()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ public class Weapon extends Upgrade{
|
|||||||
p.timer.reset(t2, reload/2f);
|
p.timer.reset(t2, reload/2f);
|
||||||
}
|
}
|
||||||
float ang = Angles.mouseAngle(p.x, p.y);
|
float ang = Angles.mouseAngle(p.x, p.y);
|
||||||
tr.trns(ang - 90, 3f * Mathf.sign(left), length);
|
tr.trns(ang - 90, 4f * Mathf.sign(left), length + 1f);
|
||||||
shoot(p, p.x + tr.x, p.y + tr.y, Angles.mouseAngle(p.x + tr.x, p.y + tr.y));
|
shoot(p, p.x + tr.x, p.y + tr.y, Angles.mouseAngle(p.x + tr.x, p.y + tr.y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user