mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-25 05:58:14 +07:00
Changed spawn system
This commit is contained in:
parent
465c4b39f3
commit
446e70c52b
@ -2,4 +2,5 @@
|
||||
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "https://raw.githubusercontent.com/gwtproject/gwt/master/distro-source/core/src/gwt-module.dtd">
|
||||
<module>
|
||||
<source path="io/anuke/mindustry" />
|
||||
<extend-configuration-property name="gdx.reflect.include" value="io.anuke.mindustry.entities.enemies" />
|
||||
</module>
|
@ -7,11 +7,14 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.input.GestureDetector;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
|
||||
import io.anuke.mindustry.GameState.State;
|
||||
import io.anuke.mindustry.ai.Pathfind;
|
||||
import io.anuke.mindustry.entities.EnemySpawn;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.enemies.*;
|
||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||
import io.anuke.mindustry.entities.enemies.TestEnemy;
|
||||
import io.anuke.mindustry.input.AndroidInput;
|
||||
import io.anuke.mindustry.input.GestureHandler;
|
||||
import io.anuke.mindustry.input.Input;
|
||||
@ -36,6 +39,7 @@ public class Control extends ControlModule{
|
||||
|
||||
final Array<Weapon> weapons = new Array<>();
|
||||
|
||||
Array<EnemySpawn> spawns = new Array<>();
|
||||
int wave = 1;
|
||||
float wavetime;
|
||||
int enemies = 0;
|
||||
@ -165,38 +169,31 @@ public class Control extends ControlModule{
|
||||
}
|
||||
|
||||
void runWave(){
|
||||
int amount = wave;
|
||||
Sounds.play("spawn");
|
||||
|
||||
Pathfind.updatePath();
|
||||
|
||||
for(int i = 0; i < amount; i ++){
|
||||
int pos = i;
|
||||
|
||||
for(int w = 0; w < World.spawnpoints.size; w ++){
|
||||
int point = w;
|
||||
Tile tile = World.spawnpoints.get(w);
|
||||
for(EnemySpawn spawn : spawns){
|
||||
for(int lane = 0; lane < World.spawnpoints.size; lane ++){
|
||||
Tile tile = World.spawnpoints.get(lane);
|
||||
int spawnamount = spawn.evaluate(wave, lane);
|
||||
|
||||
Timers.run(i*30f, ()->{
|
||||
for(int i = 0; i < spawnamount; i ++){
|
||||
int index = i;
|
||||
|
||||
Enemy enemy = null;
|
||||
|
||||
if(wave%5 == 0 & pos < wave/5){
|
||||
enemy = new BossEnemy(point);
|
||||
}else if(wave > 3 && pos < amount/2){
|
||||
enemy = new FastEnemy(point);
|
||||
}else if(wave > 8 && pos % 3 == 0 && wave%2==1){
|
||||
enemy = new FlameEnemy(point);
|
||||
}else{
|
||||
enemy = new Enemy(point);
|
||||
}
|
||||
|
||||
enemy.set(tile.worldx(), tile.worldy());
|
||||
Effects.effect("spawn", enemy);
|
||||
enemy.add();
|
||||
});
|
||||
|
||||
enemies ++;
|
||||
Timers.run(index*30f, ()->{
|
||||
try{
|
||||
Enemy enemy = (Enemy)ClassReflection.newInstance(spawn.type);
|
||||
enemy.set(tile.worldx(), tile.worldy());
|
||||
Effects.effect("spawn", enemy);
|
||||
enemy.add();
|
||||
|
||||
enemies ++;
|
||||
}catch (Exception e){
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
18
core/src/io/anuke/mindustry/entities/EnemySpawn.java
Normal file
18
core/src/io/anuke/mindustry/entities/EnemySpawn.java
Normal file
@ -0,0 +1,18 @@
|
||||
package io.anuke.mindustry.entities;
|
||||
|
||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||
|
||||
public class EnemySpawn{
|
||||
public final Class<? extends Enemy> type;
|
||||
int before = Integer.MAX_VALUE;
|
||||
int after;
|
||||
int spacing;
|
||||
|
||||
public EnemySpawn(Class<? extends Enemy> type){
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int evaluate(int wave, int lane){
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -48,8 +48,6 @@ public enum Recipe{
|
||||
liquidrouter(distribution, ProductionBlocks.liquidrouter, stack(Item.steel, 5)),
|
||||
pump(production, ProductionBlocks.pump, stack(Item.steel, 20));
|
||||
|
||||
|
||||
|
||||
public Block result;
|
||||
public ItemStack[] requirements;
|
||||
public Section section;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package io.anuke.mindustry.world.blocks.types;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
|
||||
import io.anuke.mindustry.resource.Liquid;
|
||||
@ -42,7 +41,9 @@ public class LiquidRouter extends Conduit{
|
||||
ConduitEntity entity = tile.entity();
|
||||
Draw.rect(name(), tile.worldx(), tile.worldy());
|
||||
|
||||
Draw.color(Color.ROYAL);
|
||||
if(entity.liquid == null) return;
|
||||
|
||||
Draw.color(entity.liquid.color);
|
||||
Draw.alpha(entity.liquidAmount / liquidCapacity);
|
||||
Draw.rect("blank", tile.worldx(), tile.worldy(), 2, 2);
|
||||
Draw.color();
|
||||
|
@ -32,7 +32,9 @@ public class Purifier extends Conduit{
|
||||
ConduitEntity entity = tile.entity();
|
||||
Draw.rect(name(), tile.worldx(), tile.worldy());
|
||||
|
||||
Draw.color(Color.ROYAL);
|
||||
if(entity.liquid == null) return;
|
||||
|
||||
Draw.color(entity.liquid.color);
|
||||
Draw.alpha(entity.liquidAmount / liquidCapacity);
|
||||
Draw.rect("blank", tile.worldx(), tile.worldy(), 2, 2);
|
||||
Draw.color();
|
||||
|
Loading…
Reference in New Issue
Block a user