Added more weapons

This commit is contained in:
Anuken
2017-05-05 17:05:29 -04:00
parent c9019dd2eb
commit eef909db3e
18 changed files with 144 additions and 17 deletions

View File

@@ -68,6 +68,14 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
Draw.rect("bullet", b.x, b.y, b.angle());
Draw.clear();
}
},
shot2 = new BulletType(2.5f, 2){
{lifetime=40;}
public void draw(Bullet b){
Draw.color(Color.SKY);
Draw.rect("bullet", b.x, b.y, b.angle());
Draw.clear();
}
};
private BulletType(float speed, int damage){

View File

@@ -29,13 +29,9 @@ public class Player extends DestructibleEntity{
remove();
Effects.effect("explosion", this);
Effects.shake(4f, 5f);
Effects.effect("respawn", this);
Effects.sound("die", this);
Timers.run(respawntime, ()->{
set(core.worldx(), core.worldy()-8);
heal();
add();
});
respawntime = respawnduration;
}
@Override
@@ -74,7 +70,7 @@ public class Player extends DestructibleEntity{
if(shooting && reload <= 0){
currentWeapon.shoot(this);
Sounds.play("shoot");
Sounds.play(currentWeapon.shootsound);
reload = currentWeapon.reload;
}

View File

@@ -1,17 +1,29 @@
package io.anuke.mindustry.entities;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.resource.Item;
import io.anuke.mindustry.resource.ItemStack;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
public enum Weapon{
blaster(15, BulletType.shot, "Shoots a slow, weak bullet."){
{
unlocked = true;
}
@Override
public void shoot(Player p){
super.shoot(p);
Effects.effect("shoot3", p.x + vector.x, p.y+vector.y);
}
},
trishot(15, BulletType.shot, "Shoots 3 bullets in a spread.", stack(Item.iron, 40)){
trishot(13, BulletType.shot, "Shoots 3 bullets in a spread.", stack(Item.iron, 40)){
@Override
public void shoot(Player p){
@@ -21,14 +33,46 @@ public enum Weapon{
bullet(p, p.x, p.y, ang);
bullet(p, p.x, p.y, ang+space);
bullet(p, p.x, p.y, ang-space);
Effects.effect("shoot", p.x + vector.x, p.y+vector.y);
}
},
multigun(6, BulletType.shot2, "Shoots inaccurate bullets with a high\nrate of fire.", stack(Item.iron, 60), stack(Item.steel, 20)){
@Override
public void shoot(Player p){
float ang = mouseAngle(p);
MathUtils.random.setSeed(Gdx.graphics.getFrameId());
bullet(p, p.x, p.y, ang + Mathf.range(8));
Effects.effect("shoot2", p.x + vector.x, p.y+vector.y);
}
},
flamethrower(5, BulletType.flame, "Shoots a stream of fire.", stack(Item.steel, 60), stack(Item.coal, 60)){
{
shootsound = "flame2";
}
@Override
public void shoot(Player p){
float ang = mouseAngle(p);
//????
MathUtils.random.setSeed(Gdx.graphics.getFrameId());
bullet(p, p.x, p.y, ang + Mathf.range(12));
}
};
public float reload;
public BulletType type;
float reload;
BulletType type;
public String shootsound = "shoot";
public boolean unlocked;
public ItemStack[] requirements;
public String description = "no desc for you";
Vector2 vector = new Vector2();
private Weapon(float reload, BulletType type, String desc, ItemStack... requirements){
this.reload = reload;
this.type = type;
@@ -45,7 +89,8 @@ public enum Weapon{
}
void bullet(Entity owner, float x, float y, float angle){
new Bullet(type, owner, x, y, angle).add();
vector.set(3, 0).rotate(mouseAngle(owner));
new Bullet(type, owner, x+vector.x, y+vector.y, angle).add();
}
private static ItemStack stack(Item item, int amount){