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

View File

@@ -13,13 +13,6 @@ public class Liquids {
heatCapacity = 0.4f;
}
},
plasma = new Liquid("plasma", Color.CORAL) {
{
flammability = 0.4f;
viscosity = 0.1f;
heatCapacity = 0.2f;
}
},
lava = new Liquid("lava", Color.valueOf("e37341")) {
{
temperature = 0.7f;
@@ -38,12 +31,5 @@ public class Liquids {
heatCapacity = 0.75f;
temperature = 0.5f;
}
},
sulfuricAcid = new Liquid("sulfuricAcid", Color.YELLOW) {
{
flammability = 0.4f;
explosiveness = 0.4f;
heatCapacity = 0.4f;
}
};
}

View File

@@ -131,17 +131,18 @@ public class WeaponBlocks{
};
}},
chainturret = new Turret("chainturret"){
chainturret = new Turret("chainturret"){{
},
}},
titanturret = new Turret("titancannon"){
titanturret = new Turret("titancannon"){{
},
}},
fornaxcannon = new PowerTurret("fornaxcannon") {
},
missileturret = new PowerTurret("missileturret") {
};

View File

@@ -8,6 +8,7 @@ import io.anuke.mindustry.content.fx.Fx;
import io.anuke.mindustry.entities.Bullet;
import io.anuke.mindustry.entities.BulletType;
import io.anuke.mindustry.entities.effect.DamageArea;
import io.anuke.mindustry.entities.effect.Lightning;
import io.anuke.mindustry.graphics.Palette;
import io.anuke.mindustry.resource.Liquid;
import io.anuke.ucore.core.Effects;
@@ -168,6 +169,21 @@ public class TurretBullets {
status = StatusEffects.oiled;
statusIntensity = 0.5f;
}
},
lightning = new BulletType(0.001f, 5) {
{
lifetime = 1;
}
@Override
public void draw(Bullet b) {
}
@Override
public void init(Bullet b) {
new Lightning(b.team, b, b.x, b.y, b.angle(), 30);
}
};
private static void drawBullet(Color first, Color second, String name, float x, float y, float w, float h, float rot){

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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));
}
}

View File

@@ -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;