Added weapon upgrades, bugfixes
This commit is contained in:
@@ -16,7 +16,6 @@ public class Player extends DestructibleEntity{
|
||||
float speed = 1f;
|
||||
float rotation;
|
||||
float reload;
|
||||
Weapon weapon = Weapon.blaster;
|
||||
|
||||
public Player(){
|
||||
hitsize = 5;
|
||||
@@ -74,14 +73,14 @@ public class Player extends DestructibleEntity{
|
||||
boolean shooting = Inputs.buttonDown(Buttons.LEFT) && recipe == null && !ui.hasMouse();
|
||||
|
||||
if(shooting && reload <= 0){
|
||||
weapon.shoot(this);
|
||||
currentWeapon.shoot(this);
|
||||
Sounds.play("shoot");
|
||||
reload = weapon.reload;
|
||||
reload = currentWeapon.reload;
|
||||
}
|
||||
|
||||
vector.limit(speed);
|
||||
|
||||
move(vector.x*delta, vector.y*delta);
|
||||
move(vector.x*delta, vector.y*delta, 4);
|
||||
|
||||
if(!shooting){
|
||||
direction.add(vector.scl(delta));
|
||||
|
||||
@@ -1,28 +1,54 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.resource.ItemStack;
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
|
||||
public enum Weapon{
|
||||
blaster(15, BulletType.shot){
|
||||
blaster(15, BulletType.shot, "Shoots a slow, weak bullet."){
|
||||
{
|
||||
unlocked = true;
|
||||
}
|
||||
},
|
||||
trishot(15, BulletType.shot, "Shoots 3 bullets in a spread.", stack(Item.iron, 40)){
|
||||
|
||||
@Override
|
||||
public void shoot(Player p){
|
||||
float ang = mouseAngle(p);
|
||||
float space = 12;
|
||||
|
||||
bullet(p, p.x, p.y, ang);
|
||||
bullet(p, p.x, p.y, ang+space);
|
||||
bullet(p, p.x, p.y, ang-space);
|
||||
}
|
||||
};
|
||||
public float reload;
|
||||
public BulletType type;
|
||||
public boolean unlocked;
|
||||
public ItemStack[] requirements;
|
||||
public String description = "no desc for you";
|
||||
|
||||
private Weapon(float reload, BulletType type){
|
||||
private Weapon(float reload, BulletType type, String desc, ItemStack... requirements){
|
||||
this.reload = reload;
|
||||
this.type = type;
|
||||
this.requirements = requirements;
|
||||
this.description = desc;
|
||||
}
|
||||
|
||||
public void shoot(Player p){
|
||||
bullet(p, p.x, p.y);
|
||||
bullet(p, p.x, p.y, mouseAngle(p));
|
||||
}
|
||||
|
||||
void bullet(Entity owner, float x, float y){
|
||||
new Bullet(type, owner, x, y, Angles.mouseAngle(owner.x, owner.y)).add();
|
||||
float mouseAngle(Entity owner){
|
||||
return Angles.mouseAngle(owner.x, owner.y);
|
||||
}
|
||||
|
||||
void bullet(Entity owner, float x, float y, float angle){
|
||||
new Bullet(type, owner, x, y, angle).add();
|
||||
}
|
||||
|
||||
private static ItemStack stack(Item item, int amount){
|
||||
return new ItemStack(item, amount);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user