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

Binary file not shown.

BIN
core/assets/sounds/die.wav Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -403,10 +403,24 @@ weapon-blaster
orig: 8, 8 orig: 8, 8
offset: 0, 0 offset: 0, 0
index: -1 index: -1
weapon-trishot weapon-flamethrower
rotate: false rotate: false
xy: 178, 3 xy: 178, 3
size: 8, 8 size: 8, 8
orig: 8, 8 orig: 8, 8
offset: 0, 0 offset: 0, 0
index: -1 index: -1
weapon-multigun
rotate: false
xy: 188, 3
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1
weapon-trishot
rotate: false
xy: 198, 3
size: 8, 8
orig: 8, 8
offset: 0, 0
index: -1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

View File

@ -25,7 +25,9 @@ public class Control extends RendererModule{
atlas = new Atlas("mindustry.atlas"); atlas = new Atlas("mindustry.atlas");
Sounds.load("shoot.wav", "place.wav", "explosion.wav", "enemyshoot.wav", "corexplode.wav", "break.wav", "spawn.wav", "flame.wav"); Sounds.load("shoot.wav", "place.wav", "explosion.wav", "enemyshoot.wav",
"corexplode.wav", "break.wav", "spawn.wav", "flame.wav", "die.wav",
"respawn.wav", "purchase.wav", "flame2.wav");
Musics.load("1.mp3", "2.mp3", "3.mp3"); Musics.load("1.mp3", "2.mp3", "3.mp3");
Generator.loadMaps(); Generator.loadMaps();
@ -83,6 +85,18 @@ public class Control extends RendererModule{
if(!paused){ if(!paused){
if(respawntime > 0){
respawntime -= delta();
if(respawntime <= 0){
player.set(core.worldx(), core.worldy()-8);
player.heal();
player.add();
Effects.sound("respawn");
}
}
if(enemies <= 0) if(enemies <= 0)
wavetime -= delta(); wavetime -= delta();

View File

@ -45,6 +45,27 @@ public class EffectLoader{
Draw.spikes(e.x, e.y, e.ifract() * 3f, 2, 8); Draw.spikes(e.x, e.y, e.ifract() * 3f, 2, 8);
Draw.clear(); Draw.clear();
}); });
Effect.create("shoot", 8, e -> {
Draw.thickness(1f);
Draw.color(Hue.mix(Color.WHITE, Color.GOLD, e.ifract()));
Draw.spikes(e.x, e.y, e.ifract() * 2f, 2, 5);
Draw.clear();
});
Effect.create("shoot2", 8, e -> {
Draw.thickness(1f);
Draw.color(Hue.mix(Color.WHITE, Color.SKY, e.ifract()));
Draw.spikes(e.x, e.y, e.ifract() * 2f, 1, 5);
Draw.clear();
});
Effect.create("shoot3", 8, e -> {
Draw.thickness(1f);
Draw.color(Hue.mix(Color.WHITE, Color.GOLD, e.ifract()));
Draw.spikes(e.x, e.y, e.ifract() * 2f, 1, 5);
Draw.clear();
});
Effect.create("explosion", 15, e -> { Effect.create("explosion", 15, e -> {
Draw.thickness(2f); Draw.thickness(2f);
@ -76,7 +97,7 @@ public class EffectLoader{
Draw.clear(); Draw.clear();
}); });
Effect.create("respawn", respawntime, e -> { Effect.create("respawn", respawnduration, e -> {
Draw.tcolor(Color.SCARLET); Draw.tcolor(Color.SCARLET);
Draw.tscl(0.25f); Draw.tscl(0.25f);
Draw.text("Respawning in " + (int)((e.lifetime-e.time)/60), e.x, e.y); Draw.text("Respawning in " + (int)((e.lifetime-e.time)/60), e.x, e.y);

View File

@ -16,6 +16,7 @@ public class Inventory{
items.put(Item.stone, 2000); items.put(Item.stone, 2000);
items.put(Item.iron, 2000); items.put(Item.iron, 2000);
items.put(Item.steel, 2000); items.put(Item.steel, 2000);
items.put(Item.coal, 2000);
} }
} }

View File

@ -370,7 +370,26 @@ public class UI extends SceneModule{
}).width(w); }).width(w);
get().setVisible(nplay); get().setVisible(nplay);
}}; }}.end();
new table(){{
//atop();
new table(){{
get().background("button");
new label("Respawning in"){{
get().update(()->{
get().setText("[crimson]Respawning in " + (int)(respawntime/60));
});
get().setFontScale(0.75f);
}};
visible(()->{
return respawntime > 0;
});
}};
}}.end();
updateItems(); updateItems();

View File

@ -15,7 +15,7 @@ import io.anuke.mindustry.world.Tile;
/**ick, global state*/ /**ick, global state*/
public class Vars{ public class Vars{
public static final float placerange = 66; public static final float placerange = 66;
public static final float respawntime = 60*4; public static final float respawnduration = 60*4;
public static final float wavespace = 20*60; public static final float wavespace = 20*60;
public static final float enemyspawnspace = 65; public static final float enemyspawnspace = 65;
public static final float breakduration = 30; public static final float breakduration = 30;
@ -49,6 +49,8 @@ public class Vars{
public static int wave = 1; public static int wave = 1;
public static float wavetime; public static float wavetime;
public static int enemies = 0; public static int enemies = 0;
public static float respawntime;
public static Tile core; public static Tile core;
public static Array<Tile> spawnpoints = new Array<Tile>(); public static Array<Tile> spawnpoints = new Array<Tile>();

View File

@ -68,6 +68,14 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
Draw.rect("bullet", b.x, b.y, b.angle()); Draw.rect("bullet", b.x, b.y, b.angle());
Draw.clear(); 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){ private BulletType(float speed, int damage){

View File

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

View File

@ -1,17 +1,29 @@
package io.anuke.mindustry.entities; 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.Item;
import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.resource.ItemStack;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.entities.Entity; import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.util.Angles; import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
public enum Weapon{ public enum Weapon{
blaster(15, BulletType.shot, "Shoots a slow, weak bullet."){ blaster(15, BulletType.shot, "Shoots a slow, weak bullet."){
{ {
unlocked = true; 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 @Override
public void shoot(Player p){ 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);
bullet(p, p.x, p.y, ang+space); bullet(p, p.x, p.y, ang+space);
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; float reload;
public BulletType type; BulletType type;
public String shootsound = "shoot";
public boolean unlocked; public boolean unlocked;
public ItemStack[] requirements; public ItemStack[] requirements;
public String description = "no desc for you"; public String description = "no desc for you";
Vector2 vector = new Vector2();
private Weapon(float reload, BulletType type, String desc, ItemStack... requirements){ private Weapon(float reload, BulletType type, String desc, ItemStack... requirements){
this.reload = reload; this.reload = reload;
this.type = type; this.type = type;
@ -45,7 +89,8 @@ public enum Weapon{
} }
void bullet(Entity owner, float x, float y, float angle){ 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){ private static ItemStack stack(Item item, int amount){

View File

@ -8,6 +8,7 @@ import io.anuke.mindustry.Inventory;
import io.anuke.mindustry.entities.Weapon; import io.anuke.mindustry.entities.Weapon;
import io.anuke.mindustry.resource.ItemStack; import io.anuke.mindustry.resource.ItemStack;
import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.scene.event.Touchable; import io.anuke.ucore.scene.event.Touchable;
import io.anuke.ucore.scene.ui.*; import io.anuke.ucore.scene.ui.*;
import io.anuke.ucore.scene.ui.layout.Table; import io.anuke.ucore.scene.ui.layout.Table;
@ -37,6 +38,7 @@ public class UpgradeDialog extends Dialog{
weptab.background("button"); weptab.background("button");
weptab.pad(20); weptab.pad(20);
int i = 0;
for(Weapon weapon : Weapon.values()){ for(Weapon weapon : Weapon.values()){
TextButton button = new TextButton(weapon.name()); TextButton button = new TextButton(weapon.name());
@ -60,8 +62,12 @@ public class UpgradeDialog extends Dialog{
button.setDisabled(!Inventory.hasItems(weapon.requirements)); button.setDisabled(!Inventory.hasItems(weapon.requirements));
}); });
if(i > 0 && (i)%2==0)
weptab.row();
weptab.add(button).width(160); i++;
weptab.add(button).width(210);
Table tiptable = new Table(); Table tiptable = new Table();
@ -107,6 +113,7 @@ public class UpgradeDialog extends Dialog{
weapons.put(weapon, true); weapons.put(weapon, true);
ui.updateWeapons(); ui.updateWeapons();
run.run(); run.run();
Effects.sound("purchase");
}); });
} }