Re-coded everything
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import io.anuke.mindustry.Moment;
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
import io.anuke.mindustry.World;
|
||||
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;
|
||||
@@ -24,9 +25,9 @@ public class Bullet extends BulletEntity{
|
||||
@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);
|
||||
int tilex = Mathf.scl2(x, tilesize);
|
||||
int tiley = Mathf.scl2(y, tilesize);
|
||||
Tile tile = World.tile(tilex, tiley);
|
||||
|
||||
if(tile != null && tile.entity != null &&
|
||||
tile.entity.collide(this) && !tile.entity.dead){
|
||||
|
||||
@@ -25,7 +25,7 @@ public abstract class BulletType extends BaseBulletType<Bullet>{
|
||||
},
|
||||
sniper = new BulletType(3f, 17){
|
||||
public void draw(Bullet b){
|
||||
Draw.color("light gray");
|
||||
Draw.color("lightgray");
|
||||
Draw.rect("bullet", b.x, b.y, b.angle());
|
||||
Draw.clear();
|
||||
}
|
||||
|
||||
@@ -2,19 +2,15 @@ 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.Vars;
|
||||
import io.anuke.mindustry.World;
|
||||
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;
|
||||
@@ -27,6 +23,7 @@ public class Enemy extends DestructibleEntity{
|
||||
public float length = 4;
|
||||
public float rotatespeed = 8f;
|
||||
public String shootsound = "enemyshoot";
|
||||
public boolean dead = false;
|
||||
|
||||
public Enemy(int spawn){
|
||||
this.spawn = spawn;
|
||||
@@ -35,18 +32,16 @@ public class Enemy extends DestructibleEntity{
|
||||
|
||||
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);
|
||||
move(vec.x*delta, vec.y*delta);
|
||||
|
||||
//if(Timers.get(this, 10))
|
||||
target = TileType.findTileTarget(x, y, null, range, false);
|
||||
target = World.findTileTarget(x, y, null, range, false);
|
||||
|
||||
//no tile found
|
||||
if(target == null)
|
||||
@@ -57,7 +52,7 @@ public class Enemy extends DestructibleEntity{
|
||||
if(target != null){
|
||||
if(Timers.get(this, reload)){
|
||||
shoot();
|
||||
Sounds.play(shootsound);
|
||||
Effects.sound(shootsound, this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -78,13 +73,15 @@ public class Enemy extends DestructibleEntity{
|
||||
public void onDeath(){
|
||||
Effects.effect("explosion", this);
|
||||
Effects.shake(3f, 4f);
|
||||
Sounds.play("explosion");
|
||||
Effects.sound("explosion", this);
|
||||
remove();
|
||||
dead = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed(){
|
||||
amount --;
|
||||
if(!dead)
|
||||
Vars.enemies --;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
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.mindustry.Vars;
|
||||
import io.anuke.ucore.core.*;
|
||||
import io.anuke.ucore.entities.DestructibleEntity;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
@@ -32,8 +32,8 @@ public class Player extends DestructibleEntity{
|
||||
Effects.shake(4f, 5f);
|
||||
Effects.effect("respawn", this);
|
||||
|
||||
Timers.run(Moment.i.respawntime, ()->{
|
||||
set(Moment.i.core.worldx(), Moment.i.core.worldy()-8);
|
||||
Timers.run(respawntime, ()->{
|
||||
set(core.worldx(), core.worldy()-8);
|
||||
heal();
|
||||
add();
|
||||
});
|
||||
@@ -50,6 +50,11 @@ public class Player extends DestructibleEntity{
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
float speed = this.speed;
|
||||
|
||||
if(Vars.debug)
|
||||
speed = 3f;
|
||||
|
||||
if(health < maxhealth && Timers.get(this, 50))
|
||||
health ++;
|
||||
|
||||
@@ -66,7 +71,7 @@ public class Player extends DestructibleEntity{
|
||||
|
||||
reload -= delta;
|
||||
|
||||
boolean shooting = Inputs.buttonDown(Buttons.LEFT) && Moment.i.recipe == null && !Moment.module(UI.class).hasMouse();
|
||||
boolean shooting = Inputs.buttonDown(Buttons.LEFT) && recipe == null && !ui.hasMouse();
|
||||
|
||||
if(shooting && reload <= 0){
|
||||
weapon.shoot(this);
|
||||
@@ -76,7 +81,7 @@ public class Player extends DestructibleEntity{
|
||||
|
||||
vector.limit(speed);
|
||||
|
||||
Moment.module(Control.class).tryMove(this, vector.x*delta, vector.y*delta);
|
||||
move(vector.x*delta, vector.y*delta);
|
||||
|
||||
if(!shooting){
|
||||
direction.add(vector.scl(delta));
|
||||
|
||||
@@ -1,48 +1,47 @@
|
||||
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.GameState;
|
||||
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.mindustry.world.blocks.Blocks;
|
||||
import io.anuke.mindustry.world.blocks.ProductionBlocks;
|
||||
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 Tile tile;
|
||||
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){
|
||||
|
||||
public TileEntity init(Tile tile){
|
||||
this.tile = tile;
|
||||
x = tile.worldx();
|
||||
y = tile.worldy();
|
||||
|
||||
maxhealth = tile.block().health;
|
||||
health = maxhealth;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void onDeath(){
|
||||
dead = true;
|
||||
|
||||
if(tile.block() == TileType.core){
|
||||
Moment.i.coreDestroyed();
|
||||
if(tile.block() == ProductionBlocks.core){
|
||||
GameState.coreDestroyed();
|
||||
}
|
||||
tile.setBlock(TileType.air);
|
||||
|
||||
tile.setBlock(Blocks.air);
|
||||
Pathfind.updatePath();
|
||||
Effects.shake(4f, 4f);
|
||||
Effects.effect("explosion", this);
|
||||
|
||||
Sounds.play("break");
|
||||
Effects.sound("break", this);
|
||||
}
|
||||
|
||||
public void collision(Bullet other){
|
||||
@@ -79,27 +78,4 @@ public class TileEntity extends Entity{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user