Added more enemies
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package io.anuke.moment.entities;
|
||||
|
||||
import io.anuke.ucore.core.Draw;
|
||||
|
||||
public class BossEnemy extends Enemy{
|
||||
|
||||
public BossEnemy(int spawn) {
|
||||
super(spawn);
|
||||
|
||||
reload = 8;
|
||||
bullet = BulletType.smallfast;
|
||||
maxhealth = 260;
|
||||
hitsize = 8;
|
||||
speed = 0.27f;
|
||||
heal();
|
||||
|
||||
range = 70;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect("bossmech", x, y, direction.angle()-90);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,6 +34,14 @@ public enum BulletType{
|
||||
Draw.clear();
|
||||
}
|
||||
},
|
||||
smallfast(1.6f, 2){
|
||||
Color color = new Color(0x8b5ec9ff);
|
||||
public void draw(Bullet b){
|
||||
Draw.color(color);
|
||||
Draw.rect("bullet", b.x, b.y, b.angle());
|
||||
Draw.clear();
|
||||
}
|
||||
},
|
||||
flame(0.6f, 4){
|
||||
public void draw(Bullet b){
|
||||
Draw.color(Color.YELLOW, Color.SCARLET, b.time/lifetime);
|
||||
@@ -42,6 +50,14 @@ public enum BulletType{
|
||||
Draw.clear();
|
||||
}
|
||||
},
|
||||
flameshot(0.5f, 3){
|
||||
public void draw(Bullet b){
|
||||
Draw.color(Color.ORANGE, Color.SCARLET, b.time/lifetime);
|
||||
float size = 6f-b.time/lifetime*5f;
|
||||
Draw.rect("circle", b.x, b.y, size, size);
|
||||
Draw.clear();
|
||||
}
|
||||
},
|
||||
shot(2.4f, 2){
|
||||
{lifetime=40;}
|
||||
public void draw(Bullet b){
|
||||
|
||||
@@ -19,6 +19,9 @@ public class Enemy extends DestructibleEntity{
|
||||
public Entity target;
|
||||
public int spawn;
|
||||
public float reload = 40;
|
||||
public float range = 60;
|
||||
public BulletType bullet = BulletType.small;
|
||||
public float length = 4;
|
||||
|
||||
public Enemy(int spawn){
|
||||
this.spawn = spawn;
|
||||
@@ -37,16 +40,22 @@ public class Enemy extends DestructibleEntity{
|
||||
|
||||
Moment.module(Control.class).tryMove(this, vec.x*delta, vec.y*delta);
|
||||
|
||||
target = Entities.getClosest(x, y, 60, e->{
|
||||
target = Entities.getClosest(x, y, range, e->{
|
||||
return (e instanceof TileEntity || e instanceof Player);
|
||||
});
|
||||
|
||||
if(target != null){
|
||||
if(Timers.get(this, reload))
|
||||
new Bullet(BulletType.small, this, x, y, direction.angle()).add();
|
||||
shoot();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void shoot(){
|
||||
vector.set(length, 0).rotate(direction.angle());
|
||||
new Bullet(bullet, this, x+vector.x, y+vector.y, direction.angle()).add();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean collides(SolidEntity other){
|
||||
return (other instanceof Bullet) && !(((Bullet)other).owner instanceof Enemy);
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package io.anuke.moment.entities;
|
||||
|
||||
import io.anuke.ucore.core.Draw;
|
||||
|
||||
public class FastEnemy extends Enemy{
|
||||
|
||||
public FastEnemy(int spawn) {
|
||||
super(spawn);
|
||||
|
||||
speed = 0.7f;
|
||||
reload = 30;
|
||||
|
||||
maxhealth = 20;
|
||||
heal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect("fastmech", x, y, direction.angle()-90);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package io.anuke.moment.entities;
|
||||
|
||||
import io.anuke.ucore.core.Draw;
|
||||
|
||||
public class FlameEnemy extends Enemy{
|
||||
|
||||
public FlameEnemy(int spawn) {
|
||||
super(spawn);
|
||||
speed = 0.25f;
|
||||
|
||||
maxhealth = 100;
|
||||
reload = 6;
|
||||
bullet = BulletType.flameshot;
|
||||
|
||||
range = 30;
|
||||
|
||||
heal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect("firemech", x, y, direction.angle()-90);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,9 @@ import io.anuke.moment.UI;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.UInput;
|
||||
import io.anuke.ucore.entities.DestructibleEntity;
|
||||
import io.anuke.ucore.entities.Effects;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Timers;
|
||||
|
||||
public class Player extends DestructibleEntity{
|
||||
Vector2 direction = new Vector2();
|
||||
@@ -25,6 +27,20 @@ public class Player extends DestructibleEntity{
|
||||
heal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(){
|
||||
remove();
|
||||
Effects.effect("explosion", this);
|
||||
Effects.shake(4f, 5f);
|
||||
Effects.effect("respawn", this);
|
||||
|
||||
Timers.run(Moment.i.respawntime, ()->{
|
||||
set(Moment.i.core.worldx(), Moment.i.core.worldy()+8);
|
||||
heal();
|
||||
add();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed(){
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user