Everything has been broken

This commit is contained in:
Anuken
2018-03-17 12:22:21 -04:00
parent ba84bb82b4
commit 713875100b
22 changed files with 78 additions and 112 deletions

View File

@@ -1,10 +1,8 @@
package io.anuke.mindustry.entities;
import io.anuke.mindustry.entities.units.BaseUnit;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.entities.BulletEntity;
import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.util.Timer;
import static io.anuke.mindustry.Vars.*;
@@ -12,7 +10,7 @@ import static io.anuke.mindustry.Vars.*;
public class Bullet extends BulletEntity{
public Timer timer = new Timer(3);
public Bullet(BulletType type, Entity owner, float x, float y, float angle){
public Bullet(BulletType type, Unit owner, float x, float y, float angle){
super(type, owner, angle);
set(x, y);
this.type = type;
@@ -38,7 +36,11 @@ public class Bullet extends BulletEntity{
}
public boolean collidesTiles(){
return owner instanceof BaseUnit;
return true;
}
public Unit owner(){
return (Unit)owner;
}
public Team team(){
@@ -56,7 +58,7 @@ public class Bullet extends BulletEntity{
if (tile == null) return false;
tile = tile.target();
if (tile.entity != null && tile.entity.collide(this) && !tile.entity.dead) {
if (tile.entity != null && tile.entity.collide(this) && !tile.entity.dead && tile.entity.tile.getTeam() != team()) {
tile.entity.collision(this);
remove();
type.hit(this);

View File

@@ -148,7 +148,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
public void hit(Bullet b, float hitx, float hity) {
Effects.effect(shellsmoke, b);
for(int i = 0; i < 3; i ++){
Bullet bullet = new Bullet(flakspark, b.owner, hitx, hity, b.angle() + Mathf.range(120f));
Bullet bullet = new Bullet(flakspark, b.owner(), hitx, hity, b.angle() + Mathf.range(120f));
bullet.add();
}
}
@@ -255,7 +255,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
//TODO remove translation() usage
Angles.circleVectors(30, 6f, (nx, ny) -> {
float ang = Mathf.atan2(nx, ny);
Bullet o = new Bullet(blastshot, b.owner, b.x + nx, b.y + ny, ang).add();
Bullet o = new Bullet(blastshot, b.owner(), b.x + nx, b.y + ny, ang).add();
o.damage = b.damage/9;
});
}
@@ -419,7 +419,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
public void hit(Bullet b, float hitx, float hity) {
for(int i = 0; i < 4; i ++){
Bullet bullet = new Bullet(scrap, b.owner, b.x, b.y, b.angle() + Mathf.range(80f));
Bullet bullet = new Bullet(scrap, b.owner(), b.x, b.y, b.angle() + Mathf.range(80f));
bullet.add();
}
}

View File

@@ -143,7 +143,7 @@ public class Player extends Unit{
float ft = Mathf.sin(walktime, 6f, 2f);
//Draw.alpha(hitTime / hitDuration);
Draw.alpha(hitTime / hitDuration);
if(!mech.flying) {
for (int i : Mathf.signs) {
@@ -163,7 +163,7 @@ public class Player extends Unit{
Draw.rect(weapon.name + "-equip", x + tr.x, y + tr.y, w, 8, rotation - 90);
}
//Draw.alpha(1f);
Draw.alpha(1f);
x = px;
y = py;

View File

@@ -103,7 +103,7 @@ public class BaseUnit extends Unit {
public void added(){
maxhealth = type.health;
//hitbox.solid = true;
hitbox.solid = true;
hitbox.setSize(type.hitsize);
hitboxTile.setSize(type.hitsizeTile);

View File

@@ -1,5 +1,6 @@
package io.anuke.mindustry.entities.units;
import io.anuke.mindustry.entities.Unit;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Translator;
@@ -16,6 +17,8 @@ public abstract class GroundUnitType extends UnitType{
@Override
public void draw(BaseUnit unit) {
Draw.alpha(unit.hitTime / Unit.hitDuration);
float walktime = unit.walkTime; //TODO!
float ft = Mathf.sin(walktime, 6f, 2f);
@@ -28,6 +31,8 @@ public abstract class GroundUnitType extends UnitType{
Draw.rect(name + "-base", unit.x, unit.y, unit.baseRotation- 90);
Draw.rect(name, unit.x, unit.y, unit.rotation -90);
Draw.alpha(1f);
}
@Override

View File

@@ -48,6 +48,12 @@ public abstract class UnitType {
}
public void update(BaseUnit unit){
if(unit.hitTime > 0){
unit.hitTime -= Timers.delta();
}
if(unit.hitTime < 0) unit.hitTime = 0;
if(Net.client()){
unit.interpolate();
return;