Renaming before uploading new code
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import io.anuke.ucore.core.Draw;
|
||||
|
||||
public class BossEnemy extends Enemy{
|
||||
|
||||
public BossEnemy(int spawn) {
|
||||
super(spawn);
|
||||
|
||||
reload = 8;
|
||||
bullet = BulletType.smallfast;
|
||||
rotatespeed = 30f;
|
||||
maxhealth = 260;
|
||||
hitsize = 8;
|
||||
speed = 0.27f;
|
||||
heal();
|
||||
|
||||
range = 70;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect("bossmech", x, y, direction.angle()-90);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import io.anuke.mindustry.Moment;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.TileType;
|
||||
import io.anuke.ucore.entities.BulletEntity;
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
import io.anuke.ucore.entities.SolidEntity;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class Bullet extends BulletEntity{
|
||||
BulletType type;
|
||||
|
||||
public Bullet(BulletType type, Entity owner, float x, float y, float angle){
|
||||
super(type, owner, angle);
|
||||
set(x, y);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void draw(){
|
||||
type.draw(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
|
||||
int tilex = Mathf.scl2(x, TileType.tilesize);
|
||||
int tiley = Mathf.scl2(y, TileType.tilesize);
|
||||
Tile tile = Moment.i.tile(tilex, tiley);
|
||||
|
||||
if(tile != null && tile.entity != null &&
|
||||
tile.entity.collide(this) && !tile.entity.dead){
|
||||
tile.entity.collision(this);
|
||||
remove();
|
||||
type.removed(this);
|
||||
}
|
||||
|
||||
super.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void collision(SolidEntity other){
|
||||
super.collision(other);
|
||||
type.removed(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDamage(){
|
||||
return type.damage;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.entities.BaseBulletType;
|
||||
|
||||
public abstract class BulletType extends BaseBulletType<Bullet>{
|
||||
public static final BulletType
|
||||
|
||||
stone = new BulletType(1.5f, 2){
|
||||
public void draw(Bullet b){
|
||||
Draw.color("gray");
|
||||
Draw.square(b.x, b.y, 1f);
|
||||
Draw.clear();
|
||||
}
|
||||
},
|
||||
iron = new BulletType(1.7f, 2){
|
||||
public void draw(Bullet b){
|
||||
Draw.color("gray");
|
||||
Draw.rect("bullet", b.x, b.y, b.angle());
|
||||
Draw.clear();
|
||||
}
|
||||
},
|
||||
sniper = new BulletType(3f, 17){
|
||||
public void draw(Bullet b){
|
||||
Draw.color("light gray");
|
||||
Draw.rect("bullet", b.x, b.y, b.angle());
|
||||
Draw.clear();
|
||||
}
|
||||
},
|
||||
small = new BulletType(1.5f, 1){
|
||||
public void draw(Bullet b){
|
||||
Draw.color("orange");
|
||||
Draw.rect("bullet", b.x, b.y, b.angle());
|
||||
Draw.clear();
|
||||
}
|
||||
},
|
||||
smallfast = new BulletType(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 = new BulletType(0.6f, 4){
|
||||
public void draw(Bullet b){
|
||||
Draw.color(Color.YELLOW, Color.SCARLET, b.time/lifetime);
|
||||
float size = 6f-b.time/lifetime*5f;
|
||||
Draw.rect("circle", b.x, b.y, size, size);
|
||||
Draw.clear();
|
||||
}
|
||||
},
|
||||
flameshot = new BulletType(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 = new BulletType(2.4f, 2){
|
||||
{lifetime=40;}
|
||||
public void draw(Bullet b){
|
||||
Draw.color(Color.GOLD);
|
||||
Draw.rect("bullet", b.x, b.y, b.angle());
|
||||
Draw.clear();
|
||||
}
|
||||
};
|
||||
|
||||
private BulletType(float speed, int damage){
|
||||
this.speed = speed;
|
||||
this.damage = damage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed(Bullet b){
|
||||
Effects.effect("hit", b);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import io.anuke.mindustry.Control;
|
||||
import io.anuke.mindustry.Moment;
|
||||
import io.anuke.mindustry.ai.Pathfind;
|
||||
import io.anuke.mindustry.world.TileType;
|
||||
import io.anuke.ucore.core.Draw;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Sounds;
|
||||
import io.anuke.ucore.entities.*;
|
||||
import io.anuke.ucore.util.Timers;
|
||||
|
||||
public class Enemy extends DestructibleEntity{
|
||||
public static int amount = 0;
|
||||
|
||||
public Vector2 direction = new Vector2();
|
||||
public float xvelocity, yvelocity;
|
||||
public float speed = 0.3f;
|
||||
public int node = -1;
|
||||
public Entity target;
|
||||
public int spawn;
|
||||
public float reload = 40;
|
||||
public float range = 60;
|
||||
public BulletType bullet = BulletType.small;
|
||||
public float length = 4;
|
||||
public float rotatespeed = 8f;
|
||||
public String shootsound = "enemyshoot";
|
||||
|
||||
public Enemy(int spawn){
|
||||
this.spawn = spawn;
|
||||
|
||||
hitsize = 5;
|
||||
|
||||
maxhealth = 30;
|
||||
heal();
|
||||
|
||||
amount ++;
|
||||
}
|
||||
|
||||
void move(){
|
||||
Vector2 vec = Pathfind.find(this);
|
||||
vec.sub(x, y).setLength(speed);
|
||||
|
||||
Moment.module(Control.class).tryMove(this, vec.x*delta, vec.y*delta);
|
||||
|
||||
//if(Timers.get(this, 10))
|
||||
target = TileType.findTileTarget(x, y, null, range, false);
|
||||
|
||||
//no tile found
|
||||
if(target == null)
|
||||
target = Entities.getClosest(x, y, range, e->{
|
||||
return e instanceof Player;
|
||||
});
|
||||
|
||||
if(target != null){
|
||||
if(Timers.get(this, reload)){
|
||||
shoot();
|
||||
Sounds.play(shootsound);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeath(){
|
||||
Effects.effect("explosion", this);
|
||||
Effects.shake(3f, 4f);
|
||||
Sounds.play("explosion");
|
||||
remove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed(){
|
||||
amount --;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
float lastx = x, lasty = y;
|
||||
|
||||
move();
|
||||
|
||||
xvelocity = x - lastx;
|
||||
yvelocity = y-lasty;
|
||||
|
||||
if(target == null){
|
||||
direction.add(xvelocity, yvelocity);
|
||||
direction.limit(speed*rotatespeed);
|
||||
}else{
|
||||
float angle = angleTo(target);
|
||||
direction.lerp(vector.set(0, 1).setAngle(angle), 0.25f);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect("mech1", x, y, direction.angle()-90);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package io.anuke.mindustry.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,27 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import io.anuke.ucore.core.Draw;
|
||||
|
||||
public class FlameEnemy extends Enemy{
|
||||
|
||||
public FlameEnemy(int spawn) {
|
||||
super(spawn);
|
||||
|
||||
speed = 0.35f;
|
||||
|
||||
maxhealth = 150;
|
||||
reload = 6;
|
||||
bullet = BulletType.flameshot;
|
||||
shootsound = "flame";
|
||||
|
||||
range = 40;
|
||||
|
||||
heal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect("firemech", x, y, direction.angle()-90);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import com.badlogic.gdx.Input.Buttons;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import io.anuke.mindustry.Control;
|
||||
import io.anuke.mindustry.Moment;
|
||||
import io.anuke.mindustry.UI;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.entities.DestructibleEntity;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Timers;
|
||||
|
||||
public class Player extends DestructibleEntity{
|
||||
Vector2 direction = new Vector2();
|
||||
float speed = 1f;
|
||||
float rotation;
|
||||
float reload;
|
||||
Weapon weapon = Weapon.blaster;
|
||||
|
||||
public Player(){
|
||||
hitsize = 5;
|
||||
|
||||
maxhealth = 100;
|
||||
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(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect("player", x, y, direction.angle()-90);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
if(health < maxhealth && Timers.get(this, 50))
|
||||
health ++;
|
||||
|
||||
vector.set(0, 0);
|
||||
|
||||
if(Inputs.keyDown("up"))
|
||||
vector.y += speed;
|
||||
if(Inputs.keyDown("down"))
|
||||
vector.y -= speed;
|
||||
if(Inputs.keyDown("left"))
|
||||
vector.x -= speed;
|
||||
if(Inputs.keyDown("right"))
|
||||
vector.x += speed;
|
||||
|
||||
reload -= delta;
|
||||
|
||||
boolean shooting = Inputs.buttonDown(Buttons.LEFT) && Moment.i.recipe == null && !Moment.module(UI.class).hasMouse();
|
||||
|
||||
if(shooting && reload <= 0){
|
||||
weapon.shoot(this);
|
||||
Sounds.play("shoot");
|
||||
reload = weapon.reload;
|
||||
}
|
||||
|
||||
vector.limit(speed);
|
||||
|
||||
Moment.module(Control.class).tryMove(this, vector.x*delta, vector.y*delta);
|
||||
|
||||
if(!shooting){
|
||||
direction.add(vector.scl(delta));
|
||||
direction.limit(speed*6);
|
||||
}else{
|
||||
float angle = Angles.mouseAngle(x, y);
|
||||
direction.lerp(vector.set(0, 1).setAngle(angle), 0.26f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import com.badlogic.gdx.utils.DelayedRemovalArray;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
|
||||
import io.anuke.mindustry.Moment;
|
||||
import io.anuke.mindustry.ai.Pathfind;
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.TileType;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Sounds;
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
|
||||
public class TileEntity extends Entity{
|
||||
public final Tile tile;
|
||||
public DelayedRemovalArray<ItemPos> convey = new DelayedRemovalArray<>();
|
||||
public ObjectMap<Item, Integer> items = new ObjectMap<>();
|
||||
public int shots;
|
||||
public TileEntity link;
|
||||
public float rotation;
|
||||
public int maxhealth, health;
|
||||
public boolean dead = false;
|
||||
|
||||
public TileEntity(Tile tile){
|
||||
this.tile = tile;
|
||||
x = tile.worldx();
|
||||
y = tile.worldy();
|
||||
|
||||
maxhealth = tile.block().health;
|
||||
health = maxhealth;
|
||||
}
|
||||
|
||||
public void onDeath(){
|
||||
dead = true;
|
||||
|
||||
if(tile.block() == TileType.core){
|
||||
Moment.i.coreDestroyed();
|
||||
}
|
||||
tile.setBlock(TileType.air);
|
||||
Pathfind.updatePath();
|
||||
Effects.shake(4f, 4f);
|
||||
Effects.effect("explosion", this);
|
||||
|
||||
Sounds.play("break");
|
||||
}
|
||||
|
||||
public void collision(Bullet other){
|
||||
health -= other.getDamage();
|
||||
if(health <= 0) onDeath();
|
||||
}
|
||||
|
||||
public boolean collide(Bullet other){
|
||||
return other.owner instanceof Enemy;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
tile.block().update(tile);
|
||||
}
|
||||
|
||||
public int totalItems(){
|
||||
int sum = 0;
|
||||
for(Item item : Item.values()){
|
||||
sum += items.get(item, 0);
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
public boolean hasItem(Item item){
|
||||
return items.get(item, 0) > 0;
|
||||
}
|
||||
|
||||
public void addItem(Item item, int amount){
|
||||
items.put(item, items.get(item, 0) + amount);
|
||||
}
|
||||
|
||||
public void removeItem(Item item, int amount){
|
||||
items.put(item, items.get(item, 0) - amount);
|
||||
}
|
||||
|
||||
public void addConvey(Item item){
|
||||
addConvey(item, 0);
|
||||
}
|
||||
|
||||
public void addConvey(Item item, float pos){
|
||||
ItemPos posa = new ItemPos(item);
|
||||
posa.pos = pos;
|
||||
convey.add(posa);
|
||||
}
|
||||
|
||||
public void removeConvey(ItemPos pos){
|
||||
convey.removeValue(pos, true);
|
||||
}
|
||||
|
||||
static public class ItemPos{
|
||||
public Item item;
|
||||
public float pos;
|
||||
|
||||
public ItemPos(Item item){
|
||||
this.item = item;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
|
||||
public enum Weapon{
|
||||
blaster(15, BulletType.shot){
|
||||
{
|
||||
unlocked = true;
|
||||
}
|
||||
};
|
||||
public float reload;
|
||||
public BulletType type;
|
||||
public boolean unlocked;
|
||||
|
||||
private Weapon(float reload, BulletType type){
|
||||
this.reload = reload;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void shoot(Player p){
|
||||
bullet(p, p.x, p.y);
|
||||
}
|
||||
|
||||
void bullet(Entity owner, float x, float y){
|
||||
new Bullet(type, owner, x, y, Angles.mouseAngle(owner.x, owner.y)).add();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user