Additional bullet effects / Rotational replacement

This commit is contained in:
Anuken 2018-04-03 18:36:18 -04:00
parent 94f2e880cd
commit 636da8f95f
9 changed files with 29 additions and 8 deletions

View file

@ -1,5 +1,5 @@
#Autogenerated file. Do not modify.
#Mon Apr 02 23:01:45 EDT 2018
#Tue Apr 03 18:35:41 EDT 2018
version=release
androidBuildCode=815
name=Mindustry

View file

@ -12,7 +12,7 @@ public class TurretBullets {
@Override
public void draw(Bullet b) {
Draw.color(Color.valueOf("f3d47f"));
Draw.rect("bullet", b.x, b.y, b.angle() - 90);
Draw.rect("bullet", b.x, b.y, 9f, 5f + b.fract()*7f, b.angle() - 90);
Draw.color();
}
};

View file

@ -188,7 +188,7 @@ public class NetServer extends Module{
Block block = Block.getByID(packet.block);
if(!Placement.validPlace(placer.team, packet.x, packet.y, block)) return;
if(!Placement.validPlace(placer.team, packet.x, packet.y, block, packet.rotation)) return;
Recipe recipe = Recipes.getByResult(block);

View file

@ -7,14 +7,21 @@ import io.anuke.ucore.entities.BaseBulletType;
public abstract class BulletType extends BaseBulletType<Bullet>{
public Effect hitEffect = BulletFx.hit;
public Effect despawnEffect = BulletFx.despawn;
public BulletType(float speed, int damage){
this.speed = speed;
this.damage = damage;
lifetime = 40f;
}
@Override
public void hit(Bullet b, float hitx, float hity){
Effects.effect(hitEffect, hitx, hity, b.angle());
}
@Override
public void despawned(Bullet b){
Effects.effect(despawnEffect, b.x, b.y, b.angle());
}
}

View file

@ -54,6 +54,18 @@ public class BulletFx {
Lines.lineAngle(e.x + x, e.y + y, ang, e.fract()*3 + 1f);
});
Draw.reset();
}),
despawn = new Effect(12, e -> {
Draw.color(lighterOrange, Color.GRAY, e.ifract());
Lines.stroke(e.fract());
Angles.randLenVectors(e.id, 7, e.ifract()*7f, e.rotation, 40f, (x, y) -> {
float ang = Mathf.atan2(x, y);
Lines.lineAngle(e.x + x, e.y + y, ang, e.fract()*2 + 1f);
});
Draw.reset();
});
}

View file

@ -91,7 +91,7 @@ public abstract class InputHandler extends InputAdapter{
return false;
}
return Placement.validPlace(player.team, x, y, type);
return Placement.validPlace(player.team, x, y, type, rotation);
}
public boolean validBreak(int x, int y){

View file

@ -181,7 +181,7 @@ public class Block extends BaseBlock {
}
public boolean canReplace(Block other){
return other != this && this.group != BlockGroup.none && other.group == this.group;
return (other != this || rotate) && this.group != BlockGroup.none && other.group == this.group;
}
public int handleDamage(Tile tile, int amount){

View file

@ -89,7 +89,7 @@ public class Placement {
if(effects && sound) threads.run(() -> Effects.sound("place", x * tilesize, y * tilesize));
}
public static boolean validPlace(Team team, int x, int y, Block type){
public static boolean validPlace(Team team, int x, int y, Block type, int rotation){
Recipe recipe = Recipes.getByResult(type);
if(recipe == null || !state.inventory.hasItems(recipe.requirements)){
@ -134,8 +134,8 @@ public class Placement {
}
return true;
}else {
return tile.block() != type && (tile.getTeam() == Team.none || tile.getTeam() == team)
&& (type.canReplace(tile.block()) || tile.block().alwaysReplace)
return (tile.getTeam() == Team.none || tile.getTeam() == team)
&& ((type.canReplace(tile.block()) && !(type == tile.block() && rotation == tile.getRotation() && type.rotate)) || tile.block().alwaysReplace)
&& tile.block().isMultiblock() == type.isMultiblock() || tile.block() == Blocks.air;
}
}

View file

@ -2,6 +2,7 @@ package io.anuke.mindustry.world.blocks.types.distribution;
import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.BlockGroup;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.util.Mathf;
@ -13,6 +14,7 @@ public class Splitter extends Block{
instantTransfer = true;
destructible = true;
hasInventory = false;
group = BlockGroup.transportation;
}
@Override