Fixed turrets hitting friendly players / Fixed android compile error

This commit is contained in:
Anuken
2018-04-06 10:33:11 -04:00
parent c6efa6ca2e
commit 2191437f39
9 changed files with 67 additions and 34 deletions
@@ -99,12 +99,6 @@ public class Player extends Unit{
@Override
public boolean collides(SolidEntity other){
if(other instanceof Bullet){
Bullet b = (Bullet)other;
if(!state.friendlyFire && b.owner instanceof Player){
return false;
}
}
return !isDead() && super.collides(other) && !mech.flying;
}
@@ -2,6 +2,9 @@ package io.anuke.mindustry.entities;
import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.game.Team;
import io.anuke.ucore.entities.SolidEntity;
import static io.anuke.mindustry.Vars.state;
public abstract class Unit extends SyncEntity {
//total duration of hit effect
@@ -18,6 +21,11 @@ public abstract class Unit extends SyncEntity {
hitTime = hitDuration;
}
@Override
public boolean collides(SolidEntity other){
return other instanceof Bullet && state.teams.areEnemies((((Bullet) other).team), team);
}
public void damage(float amount, boolean withEffect){
if(withEffect){
damage(amount);
@@ -0,0 +1,34 @@
package io.anuke.mindustry.entities.effect;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.game.Team;
import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.entities.SolidEntity;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
public class Lightning extends Entity {
private Array<Vector2> lines = new Array<Vector2>();
public Lightning(Team team, SolidEntity damager, float x, float y, float angle, int length){
float step = 3f;
for(int i = 0; i < length; i ++){
lines.add(new Vector2(x, y));
float x2 = x + Angles.trnsx(angle, step);
float y2 = y + Angles.trnsy(angle, step);
angle += Mathf.range(30f);
if(Mathf.chance(0.1)){
new Lightning(team, damager, x2, y2, angle + Mathf.range(100f), length/2).add();
}
x = x2;
y = y2;
}
lines.add(new Vector2(x, y));
}
}
@@ -5,13 +5,11 @@ import io.anuke.mindustry.entities.BulletType;
import io.anuke.mindustry.entities.Unit;
import io.anuke.mindustry.game.Team;
import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.entities.SolidEntity;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Timer;
import java.nio.ByteBuffer;
import static io.anuke.mindustry.Vars.state;
import static io.anuke.mindustry.Vars.unitGroups;
public class BaseUnit extends Unit {
@@ -74,11 +72,6 @@ public class BaseUnit extends Unit {
return 14;
}
@Override
public boolean collides(SolidEntity other){
return other instanceof Bullet && state.teams.areEnemies((((Bullet) other).team), team);
}
@Override
public void onRemoteShoot(BulletType type, float x, float y, float rotation, short data) {
new Bullet(type, this, x, y, rotation).add().damage = data;